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 CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
61 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
34 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
198 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
364 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
283 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|

Comment