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
Ask for it at everyOnInit, 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:
VolTotList[0]: AskVol, BidVol, …) exist only when an indicator asks for them, in OnInit:
needVbp: true to have the volume by price too.
Looking ahead
On the server
The server has, for now, only the resolution of the chart itself: asking for another one throwsNotSupportedException. 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.