Returns the number of bars in history for a given symbol and timeframe
await Bar.size(timeFrame:string, symbol:string)
Parameters
Name |
Type |
Действие |
Значение по умолчанию |
timeFrame |
string |
TimeFrame. It can be any of TimeFrame enumeration values. 0 means the current chart timeFrame. |
— |
symbol |
string |
Symbol name. null means the current symbol. |
— |
Return value
The number of bars on the specified chart.
Description
If a symbol or timeframe is not specified, then the current one for the chart is used.
We recommend using this method only when you are using the method Bar.load, since number of bars
can be found from the number of elements in the array of any of the properties it returns.
Example
// write to the barsSize variable the number of bars of the current timeframe TimeFrame of the current symbol
let barsSize = await Bar.size()
// write to the barsSize variable the number of bars by the timeframe D1 of the current symbol
let barsSize = await Bar.size(TimeFrame.D1)
// write to the barsSize variable the number of bars by the timeframe D1 of the EURUSD symbol
let barsSize = await Bar.size(TimeFrame.D1, "EURUSD");
// Alternative option
const {Close} = await Bar.load([Bar.Mode.Close], PriceType.Bid);
let barsSize = Close.length;