Questions from Beginners MQL5 MT5 MetaTrader 5 - page 674

 
Leo59:

I can't get something to print() into the tester's log. How do you do it?

Here is the code of OnInit() from the Expert Advisor:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   SymbolSelect("EURJPY",true);
   Print(__FUNCTION__,", ",TimeToString(TimeCurrent()));
   SymbolSelect("USDJPY",true);
//---
   return(INIT_SUCCEEDED);
  }


Then I set a breakpoint (step 1) and run the test on the history (step 2):

OnInit()

and in the tester I get the result:

2016.11.23 13:02:24.191 2016.06.13 00:00:00   OnInit, 2016.06.13 00:00
 

Vladimir Karputov:

Next, I set a breakpoint (step 1) and run a history test (step 2):

Strangely, this blue button, which you point to with the number "2", is not active for me. Could it be because I am in MT4 ?
 
But, nevertheless, if such a thing is written:


There are restrictions on the operation of some functions in the client terminal strategy tester.

Functions Print() and PrintFormat()

To increase performance when optimizing EA parameters, functionsPrint() andPrintFormat() are not executed. The exception is the use of these functions inside theOnInit() handler. This allows us to facilitate the search of error causes when errors occur.


why thePrint() functions inside theOnInit() handler doesnot work as usual ?

And in general, about other user-defined functions in init() in optimization mode ?
 
Leo59:
Strangely enough, my blue button, which you point to with "2", is not active. Could it be because I am in MT4 ?

Yes, that's why I can freely test any EA on HISTORY, i.e. choose a timeframe, say from 2016.06.20 to 2016.11.11 and quietly, step by step, debug and observe changes in variables, while you cannot do that.

So is it worth continuing to sit on an old terminal whose support has ended? Or maybe you should use the modern MetaTrader 5? In fact, MetaTrader 5 already has hedging:The MetaTrader 5 trading platform has hedging.

 
Vladimir Karputov:

Yes, that's why I can freely test any EA on HISTORY, i.e. choose a timeframe, say from 2016.06.20 to 2016.11.11 and quietly, step by step, debug and observe changes in variables, while you cannot do that.

So is it worth continuing to sit on an old terminal whose support has ended? Or maybe you should use the modern MetaTrader 5? After all, MetaTrader 5 already has hedging:The MetaTrader 5 trading platform has hedging.

Why can I perform debugging in MT4 and observe changes of variables step by step? What am I doing wrong?
 
Artyom Trishkin:
Why can I debug in MT4, and calmly, step by step, debug and watch variables change? What am I doing wrong?
WHAT are you doing wrong: reading very quickly or deliberately skipping text.
 
Dear!!!!

Substantive question:

why does thePrint() function inside theOnInit() handler not work as usual ? And in general, what about other custom functions in init() in optimization mode ?

 
Leo59:
Dear!!!!

Substantive question:

why does thePrint() function inside theOnInit() handler not work as usual ? And in general, what about other user-defined functions in init() in optimization mode ?

Everything is explained above. It worked and works. I showed you an example.

Forum on trading, automated trading systems and strategy testing

Questions from Beginners

Vladimir Karputov, 2016.11.23 12:07

Here is the code of OnInit() from EA:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   SymbolSelect("EURJPY",true);
   Print(__FUNCTION__,", ",TimeToString(TimeCurrent()));
   SymbolSelect("USDJPY",true);
//---
   return(INIT_SUCCEEDED);
  }


I further put a breakpoint (step 1) and start testing on history (step 2):

OnInit()

And in the tester I get the result:

2016.11.23 13:02:24.191 2016.06.13 00:00:00   OnInit, 2016.06.13 00:00

 
Vladimir Karputov:

The above has already been explained. It worked and it works. And I gave you an example.


Vladimir, in your example with breakpoint and running test from MetaEditor, and not from tester in the terminal is not standard.

Let me repeat myself:

1. Why Print() function insideOnInit() handler doesn't work as usual ?

2. How do the other user functions in init() work in optimisation mode ?

 
Leo59:
Vladimir, in your example with the breakpoint and the start of testing from MetaEditor, and not from the tester in the terminal is not standard.

Again:

1. Whydoesn't thePrint() function inside theOnInit() handler work as usual?

2. How do the other user functions in init() work in optimisation mode ?

I have a feeling that you've never turned on the terminal.

Here is the code of the Expert Advisor's OnInit():

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   SymbolSelect("EURJPY",true);
   Print(__FUNCTION__,", ",TimeToString(TimeCurrent()));
   SymbolSelect("USDJPY",true);
//---
   return(INIT_SUCCEEDED);
  }

Step by step. Step One - start the tester from the terminal (a single pass), testing on the history, with visualization:

Step 1

In the strategy tester, we get the following results:

Step 2

Reason: