search Nothing found
Main Algotrading documentation Access to quote history

Bars.Select

The Select method allows you to get the historical data of the Bar structure in the array of bars_array 

int Bars.Select(string SymbolName, int Timeframe, int lenght, out Bar bars_array)

Input parameters:

Parameter
Type
Description
SymbolName
string
Symbol
Timeframe
int
Period
lenght
int
How much do we copy
bars_array
out Bar
Array where the data will be copied

In this case, the current bar will be written to the first element of the array with index 0, the previous bar will be written to the second element of the array with index 1, and so on.

 Return value:

an array with historical data of type Bar, or -1 in case of an error.

 

Example:

string line = "";
Bar[] bars;
int err = Bars.Select(Symbol.SymbolName, TimeFrame.M15, 10, out bars);
if (err == 0) {
line = "Bars: " + bars.Length.ToString() + Environment.NewLine;

for (var i = 0; i < bars.Length; i++) {
line = line +
bars[i].Time.ToString() + ", " +
bars[i].Open.ToString() + ", " +
bars[i].High.ToString() + ", " +
bars[i].Low.ToString() + ", " +
bars[i].Close.ToString() + ", " +
bars[i].Volume.ToString() + ", " + Environment.NewLine;
}
}



Subscribe to our newsletter and stay up to date with all the news!