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 NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
86 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
151 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
79 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
53 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
61 views
0 likes
|
Last Post
|

Comment