Features of the mql5 language, subtleties and tricks - page 71

 

fxsaber:

Discussion of the article "Visualizing Trading Strategy Optimization in MetaTrader 5"

fxsaber, 2018.02.22 08:39

In frame mode, OnInit, OnDeinit, OnTick, OnTrade, OnTradeTransaction and OnTimer are ignored. Only OnChartEvent works.

Of course, because of the OnChartEvent exception, it requires a mandatory check for the frame mode flag.

Where did you get such an impassioned confidence? :-)

 
Dennis Kirichenko:

How can you be so sure? :-)

From practice, of course.

 

Then a question. Is Frame Mode a mode that generally refers to Testing or not?

 
Dennis Kirichenko:

Then a question. Is Frame Mode a mode that generally refers to Testing or not?

Indirectly, it does. Just in this mode, the Expert Advisor may be started in the Terminal only by the Tester.

 

Ok. And if the Expert Advisor has the OnTick() handler, it will not work in the frame mode?

Imho, we should clarify that the frame handlers are executed by the Terminal itself and all that is usual for testing (OnTick(), OnTrade(), etc.) is passed to testing agents. ) are passed to the testing agents. Hence, the frame mode is a special compound testing mode where Agents interact interact with the Terminal.

So it goes like this...


Forum on trading, automated trading systems and strategy testing

Features of mql5 language, subtleties and tricks

How do you use mql5?fxsaber, 2018.02.22 09:22

Indirectly, it applies. Just in this mode, the Expert Advisor can be run in the Terminal only by the Tester itself.


And why indirectly? For example, normal optimization can also be run only in the Tester.

 
Dennis Kirichenko:

Ok. And if the Expert Advisor has the OnTick() handler, it will not work in the frame mode?

Imho, we should clarify that the frame handlers are executed by the Terminal itself and all that is usual for testing (OnTick(), OnTrade(), etc.) is passed to testing agents. ) are passed to the testing agents. Hence, the Frame mode is a special compound mode of testing where Agents interact interact with the Terminal.

So it goes like this.



And why indirectly? For example, normal optimization can be run only in the Tester.

Because it is a combat Expert Advisor even in the frame mode. That's the reason why you have to check the frame flag in OnChartEvent, otherwise such a trouble could happen

sinput uint Range = 100;

#define  SETRANGE(A, START, STEP, END) ParameterSetRange(#A, true, A, START, STEP, END)

void OnTesterInit() { SETRANGE(Range, 0, 1, Range); }

void OnTesterDeinit() {}

void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
{
  static const bool IsFrame = MQLInfoInteger(MQL_FRAME_MODE);
  
//  if (!IsFrame) // без этой проверки Терминал (не только Агент) начнет выставлять ордера на реальном счете во время запуска Оптимизации
    OrderSend(_Symbol, OP_BUY, 1, Ask, 100, 0, 0);
}


This seems to be the first time this has been voiced. It means that Market Products creates an unpleasant vulnerability. And it's very hard to bypass this vulnerability. To detect it is the same.

 
fxsaber:

Because this is a combat EA even in frame mode. This is the reason why you need to check the frame flag in OnChartEvent, otherwise this kind of trouble could happen

This seems to be the first time this has been voiced. It means that Market Products creates an unpleasant vulnerability. And it's very hard to bypass this vulnerability. Detecting it is similarly difficult.

However! If this is true, then, imho, it is incorrect work of the Expert Advisor in Testing mode...

Well done you for noticing it!

 

Forum on trading, automated trading systems and trading strategies testing

Bugs, bugs, questions

fxsaber, 2018.02.27 08:01

Conclusion about EAs on OBJ_CHART

  • OnInit, OnDeinit, global constructor/destructor and OnChartEvent work.
  • OnTimer, OnTick and OnBookEvent don't work.
  • Only CHARTEVENT_CHART_CHANGE and custom events are caught.
  • Through OnChartEvent+EventChartCustom EA you can create "events" for OnTimer and OnTick, but not OnBookEvent.

Therefore, it is possible to make any trading Expert Advisor complete by including the appropriate plug-in(example) to make it work (OnTimer + OnTick) on any kind of chart.

SPY OBJ_CHART is defined by CHART_IS_OBJECT.

 

Forum on trading, automated trading systems and trading strategies testing

Discussion on the article "Managed optimization: the annealing method"

fxsaber, 2018.02.28 08:45

The tester_file is only read if it existed (content doesn't matter) at the time of compilation.

If mq5 is compiled when there was no corresponding file, even its further existence will not be perceived in EX5.

Therefore, if you generate a file for tester_file in OnTesterInit, make sure that you have compiled the Expert Advisor with at least an empty passing file.

In the presence of the tester_file directive, the Optimizer's caches do not work.

 
And you cannot include files from the Files_Common folder via tester_file...