Skip to main content
An indicator reads the bars of its chart from VAn.BarVars. It can also ask for the bars of another resolution of the same symbol, the 30 minutes bars on a 5 minutes chart for example, or the daily ones, and read them next to the bars of the chart.

Asking for a resolution

The resolution is described like the one of a chart. VAn.ParamType, VAn.Param1 and VAn.Param2 are the ones of the chart itself. The same request made twice returns the same data. A resolution asked for with different days to load is still the same resolution: the days of the first request are kept. The three overloads which take a symbol (RequestResolution(symbol, ...)) give the bars of another symbol. They are desktop only: a package which uses them is calculated on the desktop.

Where to call it

Call RequestResolution in OnInit, and only there. Before OnInit the chart drops the resolutions no indicator asks for; after it, it prepares the ones asked for and loads them. A resolution asked for from OnLoad or later is never prepared, and the chart stops.
Ask for it at every OnInit, not only the first time: a resolution which is not asked for again is removed.

When the data is there

Right after the call the resolution has no bars yet: HasBar is false. It is loaded with the history of the chart, before the bars of the chart are calculated, so from OnOpen on the bars are there. A resolution kept from the previous load of the chart has its old bars already. Read it from OnOpen, OnClose and OnEnd, never from OnInit or OnLoad, and check HasBar (or the bar for null) every time: some symbols have no data for some resolutions. OnEnd(false), called once when the whole history is done, is the safe place for anything which needs the complete series.

Reading it

The bar of the resolution a bar of the chart belongs to is found by time. Use exchDt, the time of the exchange: the local time changes with the settings of the user. A time before the first bar of the resolution gives index 0, so check it first:
The volume totals of the bars of another resolution (VolTotList[0]: AskVol, BidVol, …) exist only when an indicator asks for them, in OnInit:
The chart does this by itself for its own bars. Pass needVbp: true to have the volume by price too.

Looking ahead

During the history the bars of a higher resolution are already complete. A bar of a 5 minutes chart in the middle of a 30 minutes bar sees the close of that bar, which in realtime it would not know. An indicator which takes signals from a higher resolution must use the previous bar of the resolution, or only the values known at the time of the bar of the chart. Drawing is not affected.

On the server

The server has, for now, only the resolution of the chart itself: asking for another one throws NotSupportedException. The overload without a symbol is portable, so a package which uses it is still eligible for the server. Test on the desktop, and keep this in mind before publishing. The Higher Timeframe Candles example draws the bars of another resolution over the bars of the chart.