OnChartEvent in Strategy Tester

 

"When testing in an EA, we can handle custom events using the OnChartEvent() function, but in the indicators, this function can not be called in the tester. Even if the indicator has the OnChartEvent() event handler and this indicator is used in the tested EA, the indicator itself will not receive any custom events."

Source: https://www.mql5.com/en/docs/runtime/testing#events 

Any other way to send information from the EA to the indicator?

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
 
Use iCustom() to pass a parameter to the indicator and return the handle
 
PhantonTrader:

"When testing in an EA, we can handle custom events using the OnChartEvent() function, but in the indicators, this function can not be called in the tester. Even if the indicator has the OnChartEvent() event handler and this indicator is used in the tested EA, the indicator itself will not receive any custom events."

Source: https://www.mql5.com/en/docs/runtime/testing#events 

Any other way to send information from the EA to the indicator?

You can use Global Variables of the Client Terminal.

May I ask why you want to communicate from EA to indicator ?

 
Mohamed Hamdy:
Use iCustom() to pass a parameter to the indicator and return the handle

This way I can only send data to the indicator during the initialization.

Alain Verleyen:

You can use Global Variables of the Client Terminal.

May I ask why you want to communicate from EA to indicator ?

That's not instant, but it's a good option, thanks.

It's not a real indicator, I want to use it to display some information calculated by the Expert.

 
"When testing in an EA, we can handle custom events using the OnChartEvent() function," is this true? I can NOT get a OnChartEvent to work in the tester at all. It will work on a live chart but not in the tester. Is there some secret setting that makes it work in tester? Or is this completely false?
 
James Hodges:
"When testing in an EA, we can handle custom events using the OnChartEvent() function," is this true? I can NOT get a OnChartEvent to work in the tester at all. It will work on a live chart but not in the tester. Is there some secret setting that makes it work in tester? Or is this completely false?

i'm facing the same problem, any workaround

 
mbol8309:

i'm facing the same problem, any workaround

Simply emulate it. 

Catch the OnTick() (MT4) or OnTimer() (MT5), use the Windows functions the check the mouse position and the window-size, translate into such variables which OnChartEvent() needs and do it like that. Not such a big deal, at least not in MT4. In MT5 you have do so some loops to the whole windows-structure to find the window-handle of the chart. 

Reason: