Feeding custom values to OnCalculate() (eg. for calculating indicator of an indicator, calculating an indicator on different price data, etc)



I'm sure there's an article out there but I can't quite find the appropriate reference.

In the documentation for OnCalculate()(https://www.mql5.com/en/docs/event_handlers/oncalculate), for the price[] parameter, the documentation mentions "One of the price timeseries or a calculated indicator buffer can be passed as the price[] array."

What's the best practice to pass such a calculated indicator buffer as the parameter? Would you copy the OnCalculate function to a header/include file, and then call the function in the EA?

Grateful if anyone can point me in the right direction


Documentation on MQL5: Event Handling / OnCalculate
Documentation on MQL5: Event Handling / OnCalculate
  • www.mql5.com
The function is called in the indicators when the Calculate event occurs for processing price data changes. There are two function types. Only one of them can be used within a single indicator. [in]  Size of the price[] array or input series available to the indicator for calculation. In the second function type, the parameter value corresponds...