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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.
Code:1 PhotoTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by kujista, Today, 06:23 AM
|
2 responses
6 views
0 likes
|
Last Post
by kujista
Today, 08:08 AM
|
||
Started by f.saeidi, Today, 08:03 AM
|
0 responses
4 views
0 likes
|
Last Post
by f.saeidi
Today, 08:03 AM
|
||
Started by cre8able, 04-17-2024, 04:16 PM
|
7 responses
64 views
0 likes
|
Last Post Today, 08:01 AM | ||
Started by Aviram Y, 08-09-2023, 09:04 AM
|
11 responses
299 views
0 likes
|
Last Post
by arjandezeeuw
Today, 08:00 AM
|
||
Started by Christopher Leggit, 02-15-2024, 09:00 AM
|
3 responses
47 views
0 likes
|
Last Post
by rdtdale
Today, 07:57 AM
|
Comment