When using the "price[]" variante of OnCalculate(), you can access OHLC bar data, via the normal methods described in Access to Timeseries and Indicator Data. You just have to make sure that your indexing method is properly aligned and synchronised.
Function
Action
Returns the number of bars count in the history for a specified symbol and period
Gets history data of the Rates structure for a specified symbol and period into an array
Gets history data on bar opening time for a specified symbol and period into an array
Gets history data on bar opening price for a specified symbol and period into an array
Gets history data on maximal bar price for a specified symbol and period into an array
Gets history data on minimal bar price for a specified symbol and period into an array
Gets history data on bar closing price for a specified symbol and period into an array
Gets history data on tick volumes for a specified symbol and period into an array
Gets history data on trade volumes for a specified symbol and period into an array
Gets history data on spreads for a specified symbol and period into an array
Returns the number of bars of a corresponding symbol and period, available in history
Returns the index of the bar corresponding to the specified time
Returns the Close price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the High price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the Low price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the Open price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the opening time of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the tick volume of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the real volume of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the tick volume of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the spread value of the bar (indicated by the 'shift' parameter) on the corresponding chart
- www.mql5.com
When using the "price[]" variante of OnCalculate(), you can access OHLC bar data, via the normal methods described in Access to Timeseries and Indicator Data. You just have to make sure that your indexing method is properly aligned and synchronised.
Function
Action
Returns the number of bars count in the history for a specified symbol and period
Gets history data of the Rates structure for a specified symbol and period into an array
Gets history data on bar opening time for a specified symbol and period into an array
Gets history data on bar opening price for a specified symbol and period into an array
Gets history data on maximal bar price for a specified symbol and period into an array
Gets history data on minimal bar price for a specified symbol and period into an array
Gets history data on bar closing price for a specified symbol and period into an array
Gets history data on tick volumes for a specified symbol and period into an array
Gets history data on trade volumes for a specified symbol and period into an array
Gets history data on spreads for a specified symbol and period into an array
Returns the number of bars of a corresponding symbol and period, available in history
Returns the index of the bar corresponding to the specified time
Returns the Close price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the High price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the Low price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the Open price of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the opening time of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the tick volume of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the real volume of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the tick volume of the bar (indicated by the 'shift' parameter) on the corresponding chart
Returns the spread value of the bar (indicated by the 'shift' parameter) on the corresponding chart
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey everyone, I'm currently writing code for an indicator that uses the price[i] version of OnCalculate instead of open[i],high[i],low[i],close[i] version because that's the simplest way I found, so far, to be able to choose to apply the indicator to another indicator if I want, using the parameters tab in the indicator settings. But I just realized that when I apply it to another indicator's buffer, and can no longer use price[i] to access the array of actual prices, which is something I need to do with this indicator. So I'm screwed in a way because now I think switching to the price[i] version of OnCalculate may have been useless afterall. I'm wondering what you think is the best solution for something like this... I'm a bit new to writing indicators and I want to do it the right way so if any of you have any advice, I would really appreciate it.