void limites(){
//definir suelo i techo
barsRequest = new BarsRequest(Cbi.Instrument.GetInstrument("ES 6-20"), DateTime.Now.AddDays(-1), DateTime.Now);
// Parametrize your request.
barsRequest.BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 };
barsRequest.TradingHours = TradingHours.Get("Default 24 x 7");
//debbug
if(barsRequest==null){Print("no esta bien hecha la request de vars pasadas");}
//request
[COLOR=#FF0000]barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage)[/COLOR] =>
{
Print("no hay error aqui");
if (errorCode != ErrorCode.NoError)
{
// Handle any errors in requesting bars here
NinjaTrader.Code.Output.Process(string.Format("Error on requesting bars: {0}, {1}",
errorCode, errorMessage), PrintTo.OutputTab1);
return;
}
//debbug
//Print("bars: " + bars.Bars.Count);
for (int i = 0; i < bars.Bars.Count; i++)
{
if(bars.Bars.GetHigh(i)>techo){ //calculo techo con RANGO=X
techo=bars.Bars.GetHigh(i);
}
if(bars.Bars.GetLow(i)<suelo){ //calculo suelo con RANGO=X
suelo=bars.Bars.GetLow(i);
}
}
}));
Print("Techo definido en: " + techo + ", suelo definido en: " + suelo);
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Error using barsRequest.Request()
Collapse
X
-
Error using barsRequest.Request()
I'm having trouble geting this code to work. The error says a null reference in the red line. But I can't seem to find what I'm missing. I'll explain what I'm doing in case that what I'm doing is also incorrect. I'm trying to get the past day info and then check for max and min values to define supports and resistances. I'm doing that with the request method from BarsRequest and then iterating the bars requested.
I'm also attaching a photo from the debbuger.Code:1 PhotoTags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
88 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
134 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
68 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
119 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
69 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment