Multibars
Multibars
An indicator or a strategy will always have the same underlying timeframe-units as those units being displayed within the chart. The values of an SMA(14) indicator displayed in a 5 minute chart will be calculated based on the last fourteen 5 minute bars. A daily chart, on the other hand, would use the closing prices of the past 14 days in order to calculate this value. The same method applies for your self-programmed indicators. A 5 minute chart will call up the OnCalculate() for each 5 minute bar. If you want your self-created indicator to use a different timeframe, this is possible using multibars.
Example
Additional Notes
When using additional timeframes, a further entry with the respective data series for the bars of the new timeframe will be added to the arrays Opens, Highs, Lows, Closes, Medians, Typicals, Weighteds, Times and Volumes. The indexing will occur in the order of the addition of the new timeframes. Closes[0][0] is equivalent to Close[0]. Closes[1][0] equals the current closing price for the daily data series Closes[2][0] equals the current closing price for the weekly data series
"Closes" is, of course, interchangeable with Opens, Highs, Lows etc.
See ProcessingBarIndexes, ProcessingBarSeriesIndex, TimeFrames.
Additional syntax methods are available for multibars:
ProcessingBarIndexes
Description
ProcessingBarIndexes is an array of int values that contains the number of ProcessingBarIndex for each bar.
This array is only of value for indicators or strategies that use data from multiple timeframes.
A new entry is added to the array whenever a new timeframe is added to an indicator or strategy.
With [TimeFrameRequirements(("1 Day"), ("1 Week"))] the array will contain 3 entries:
ProcessingBarIndexes[0] Current bar for the primary data series (chart timeframe) ProcessingBarIndexes[1] Current bar for the daily bars ProcessingBarIndexes[2] Current bar for the weekly bars
ProcessingBarIndexes[0] is equivalent to ProcessingBarIndex.
Also see MultiBars.
Parameter
barSeriesIndex Index value for the various timeframes
Usage
Example
ProcessingBarSeriesIndex
Description
Within a multibars script, multiple bars objects are available. The OnCalculate() method will therefore also be called up for every bar within your script. In order to include/exclude events of specific data series, you can use the ProcessingBarSeriesIndex property.
ProcessingBarSeriesIndex is only of value for indicators or strategies that use data from multiple timeframes. With [TimeFrameRequirements("1 Day", "1 Week")] two timeframes will be added to the primary chart timeframe.
If OnCalculate() is called up by the primary data series, then ProcessingBarSeriesIndex will equal zero. If OnCalculate() is called up by the daily bars, then ProcessingBarSeriesIndex will equal 1. Weekly bars will have a value of 2.
See Multibars and ProcessingBarIndexes.
Parameter
none
Usage
ProcessingBarSeriesIndex
More Information
Within a script that only works with primary timeframes, the value will always equal zero.
Example
Last updated