Questions from Beginners MQL5 MT5 MetaTrader 5 - page 674

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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):
and in the tester I get the result:
Vladimir Karputov:
Next, I set a breakpoint (step 1) and run a history test (step 2):
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 ?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.
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 debug in MT4, and calmly, step by step, debug and watch variables change? What am I doing wrong?
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 ?
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):
And in the tester I get the result:
The above has already been explained. It worked and it works. And I gave you an example.
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 ?
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:
In the strategy tester, we get the following results: