The documentation says that:
When testing in the Expert Advisor, you can handle user events using the OnChartEvent () function, but this function is not called in the tester in indicators. Even if the indicator has an OnChartEvent() handler and this indicator is used in the Expert Advisor under test, the indicator itself will not receive any custom events.
At the moment, this statement is not relevant – in indicators, this function is called in the tester, at least one indicator can receive events generated by another indicator in the tester.
The problem is that after receiving a call to this function, the indicator does not have access to data stored in variables declared at the global level, and vice versa – all changes made in this function are not saved in variables of the global access level.
1. The object is declared at the global level and initialized in the OnInit function. It can be accessed from the OnCalculate function, but in the OnChartEvent function we get an error message – invalid pointer
2. There is a function that outputs the contents of a variable to the log (the variable is declared at the global level). When calling this function from OnCalculate, we get the expected value, when calling the same function from OnChartEvent, we get nonsense.
There is no such behavior in the Expert Advisor, and the indicator works correctly in real time.
MetaTester 5, build 1100.