Download MetaTrader 5

Is OnChartEvent() actually called during a "Stratagy Tester - Visual Testing" mode session?

To add comments, please log in or register
cowil
826
cowil  

Hi,

I've written an Expert that contains a few graphical buttons to enable me to change certain trading parameters "on-the-fly". I then want to be able to press these buttons during a Strategy Tester - Visual Tester mode session.

According to the documentation in https://www.mql5.com/en/docs/runtime/testing#objects :

"When testing in an EA, we can handle custom events using the OnChartEvent() function..."

and:

"

Graphical Objects in Testing

During testing/optimization graphical objects are not plotted. Thus, when referring to the properties of a created object during testing/optimization, an Expert Advisor will receive zero values.

This limitation does not apply to testing in visual mode.


"

Having created the Expert, I'm unfortunately running into problems trying to use it within the visual tester. The buttons are created in the OnInit() handler of the Expert and these buttons appear as they should in the visual tester. However, when the buttons are pressed, the coded button functionality doesn't run (it obviously does run if I attach the Expert to a normal live chart).

After a bit of playing around, it appears that contrary to the documentation, the OnChartEvent() handler doesn't actually appear to be called during a chart event when the Expert is run within the visual tester? For instance, if I run the following Expert on a normal chart, the messages  "*** Expert Started ***" and "***Chart Event received***" get printed in the log when the Expert is started and the chart is clicked on. If the Expert is run in the visual tester however, the message "*** Expert Started ***" is printed in the log but any clicks on the chart result in nothing...


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit() {
    Print("*** Expert Started ***");
    return 0;
}

//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) {
    Print("*** Chart Event received ***");
}    


Am I missing something here or is this a bug? Any help with this would be greatly appreciated..

Documentation on MQL5: MQL5 programs / Testing Trading Strategies
Documentation on MQL5: MQL5 programs / Testing Trading Strategies
  • www.mql5.com
MQL5 programs / Testing Trading Strategies - Reference on algorithmic/automated trading language for MetaTrader 5
Alain Verleyen
Moderator
31439
Alain Verleyen  

Bugs should be reported to ServiceDesk.

Please keep us posted.

cowil
826
cowil  
Alain Verleyen:

Bugs should be reported to ServiceDesk.

Please keep us posted.


Thanks Alain - have passed this onto the Service Desk. Will keep you updated re. the outcome...
To add comments, please log in or register