During optimisation, output from Print() and PrintFormat() is suppressed (and does not go out to the log).
This is stated in the documentation, so please read it ...
- "Print() function does not work during optimization in the Strategy Tester."
- "PrintFormat() function does not work during optimization in the Strategy Tester."
The option was deliberately disabled by MetaQuotes to prevent certain types of "abuse", but one way to work around it is to create a custom symbol with the data offset in time.
Always here to help :) Many thanks, Fernando!
That answers all my questions. Will give the suggested custom symbol a try then.
Eric Emmrich:
Are function calls to Print() and PrintFormat() automatically disabled during optimization, or should I rather check for MQLInfoInteger(MQL_OPTIMIZATION) before using them? My EA is quite verbose when it comes to logging and during normal backtesting I noticed that this can slow down the whole process quite a bit.
Try.
input int inRange = 0; double Calc() { double Sum = 0; for (int i = 0; i < 1e5; i++) Sum += MathSin(MathRand()); return(Sum); } void OnTick() { static const bool Flag = !MQLInfoInteger(MQL_OPTIMIZATION) && !MQLInfoInteger(MQL_FRAME_MODE); // if (Flag) Print(Calc()); }
There will be no printout, but there will be calculations.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I have two questions regarding the Strategy Tester in MT5. Maybe someone knows the answer: