Forum on trading, automated trading systems and testing trading strategies
use of MQLInfoInteger(MQL_OPTIMIZATION)
fxsaber, 2024.10.15 16:09
MQLInfoInteger(MQL_FRAME_MODE) == true
Hi, sorry but I am not sure what you mean with this. Just because FRAME_MODE is true, does that means that OPTIMIZATION or FORWARD will not true? I have several functions in the EA that is using those variables, for example to avoid creating the panel when optimising.
So when OnTesterPass() executes, how can I find out if it's currently in the OPTIMIZATION phase or the FORWARD phase?
Hi, sorry but I am not sure what you mean with this. Just because FRAME_MODE is true, does that means that OPTIMIZATION or FORWARD will not true? I have several functions in the EA that is using those variables, for example to avoid creating the panel when optimising.
So when OnTesterPass() executes, how can I find out if it's currently in the OPTIMIZATION phase or the FORWARD phase?
So when in OnTesterPass(), is there a way to find out whether I am currently in the OPTIMIZATION phase or the FORWARD phase?
Cause even if FRAME_MODE is true, we will be in one of those phases, so I am surprised that they would both show false. The doc says that FRAME_MODE and TESTER can not be true at the same time, and OPTIMISATION and VISUAL can't be true at the same time, but I haven't seen anything saying that FRAME_MODE and OPTIMIZATION can't be true at the same time.
Hi, sorry but I am not sure what you mean with this. Just because FRAME_MODE is true, does that means that OPTIMIZATION or FORWARD will not true?
You can find more details in the docs or the algotrading book:

- www.mql5.com
So when in OnTesterPass(), is there a way to find out whether I am currently in the OPTIMIZATION phase or the FORWARD phase?
Cause even if FRAME_MODE is true, we will be in one of those phases, so I am surprised that they would both show false. The doc says that FRAME_MODE and TESTER can not be true at the same time, and OPTIMISATION and VISUAL can't be true at the same time, but I haven't seen anything saying that FRAME_MODE and OPTIMIZATION can't be true at the same time.
If FRAME_MODE is true, you are running an optimization by definition, there is no need to check it.
To know if a pass come from forward or "normal" optimization, pass it with your frame data.
If FRAME_MODE is true, you are running an optimization by definition, there is no need to check it.
To know if a pass come from forward or "normal" optimization, pass it with your frame data.
Thank you Alain, I tried to do what you describe, but so far I have not got it to work.
In OnTester() I set one of the values in the array to MQLInfoInteger(MQL_FORWARD) before the array is passed with a new frame.
In OnTesterPass() I receive the value. But it is false for frames coming both from OPTIMIZATION and from FORWARD. I print all the frames to a CSV file together with a timestamp that let's me know if it came from OPT or FORWARD, and isForward is false for all frames.
A pointer to what I might be doing wrong would be very appreciated.
Thanks
double OnTester() { // stat_values is an array of double stat_values[0] = maxSeqNo; stat_values[1] = r4; stat_values[2] = pipsPerTrade; stat_values[3] = tradesPerWeek; stat_values[4] = avgHoldingHours; stat_values[5] = OptimizationMinTradesPerWeek; stat_values[6] = OptimizationMaxTradesPerWeek; stat_values[7] = OptimizationMaxAvgDuration; stat_values[8] = OptimizationMinProfitFactor; stat_values[9] = OptimizationMaxSequenceLevels; stat_values[10] = OptimizationMinR2; stat_values[11] = OptimizationMinPipsPerTrade; stat_values[12] = MQLInfoInteger(MQL_FORWARD); FrameAdd("Statistics",1,0,stat_values); ... return(0); } void OnTesterPass () { ... FrameNext(pass,name,id,value,stat_values); FrameInputs(pass,parameters_list,parameters_count); bool isForward = (bool)stat_values[12]; ... }
Thank you Alain, I tried to do what you describe, but so far I have not got it to work.
In OnTester() I set one of the values in the array to MQLInfoInteger(MQL_FORWARD) before the array is passed with a new frame.
In OnTesterPass() I receive the value. But it is false for frames coming both from OPTIMIZATION and from FORWARD. I print all the frames to a CSV file together with a timestamp that let's me know if it came from OPT or FORWARD, and isForward is false for all frames.
A pointer to what I might be doing wrong would be very appreciated.
Thanks

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I run an EA in the Strategy Tester in Optimization Mode. From OnTesterPass() I open a CSV file, that should have a different name depending on whether it's the Optimisation phase or Forward phase. I use MQLInfoInterger() to find this out. But even though OnTesterPass could only be triggered when optimising, MQLInfoInteger(MQL_OPTIMIZATION) is false. See code below. Has anyone seen this before? Idea ideas?
When it's run in optimisation mode or forward mode, the file name end up like this: TEST_Opt_0_Forw_0_Tester_0.csv