Looking for a specific setup back in time with an EA

I have a question about what’s possible to do with a script or an EA for MT4.

I want to know if a specific setup has happened in 2008 or for the last 6 month and how many times it has happened.

Is it possible to collect this kind of information back in time and write them into a CSV file?

Thank you for your reply in advance.

I don’t use MT4, but I’ve programmed and backtested several systems in Excel. This is what I would do:

Use your “setup” as an entry order. Then run your system over the desired time-period. The amount of filled entries is the amount of time your setup occurred.

Its quite easy. Loop through each bar testing for the set up, and write the bar number, or date/time to a file each time a set up occurs.

Take a look at the MQL help file on writing data to a file.

There’s also loads of examples on various forums of scripts that write our indicator values to a file, these should be easy enough to modify. I do this all the time, and at the time the data being written, I also add a vertical line to the chart to help identify the setups.