Request()

View as Markdown

Definition

Performs the bars request for a BarsRequest object

Syntax

BarsRequest.Request(Action\<barsrequest, errorcode, string\> callback)

Properties

PropertyDescription
BarsRequestA BarsRequest representing the bars
ErrorCodeAn ErrorCode representing error status
stringA string representing error message

Examples

1// Request the bars
2barsRequest.Request(new Action<barsrequest, errorcode, string>((bars, errorCode, errorMessage) =>
3{
4 if (errorCode != ErrorCode.NoError)
5 {
6 // Handle any errors in requesting bars here
7 NinjaTrader.Code.Output.Process(string.Format("Error on requesting bars: {0}, {1}",
8 errorCode, errorMessage), PrintTo.OutputTab1);
9 return;
10 }
11
12 // Do something with the returned bars here.
13 for (int i = 0; i < bars.Bars.Count; i++)
14 {
15 // Output the bars
16 NinjaTrader.Code.Output.Process(string.Format("Time: {1} Open: {2} High: {3} Low: {4} Close: {5} Volume: {6}",
17 bars.Bars.GetTime(i),
18 bars.Bars.GetOpen(i),
19 bars.Bars.GetHigh(i),
20 bars.Bars.GetLow(i),
21 bars.Bars.GetClose(i),
22 bars.Bars.GetVolume(i)), PrintTo.OutputTab1);
23 }
24}));