When State == State.RealTime in the OnStateChange() method I am trying to access historical values of the Buys Series but I am getting argumentOutOfRange exceptions. The Count is > 0. Why is this throwing an error?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Accessing Historical Values from AddPlot
Collapse
X
-
Accessing Historical Values from AddPlot
I have a plot I have added to my indicator AddPlot(new Stroke(Brushes.AliceBlue, 0), PlotStyle.Dot, "Buys");
When State == State.RealTime in the OnStateChange() method I am trying to access historical values of the Buys Series but I am getting argumentOutOfRange exceptions. The Count is > 0. Why is this throwing an error?1 PhotoTags: None
-
Hello habibalex, thanks for writing in.
There should not be any access to any Series<T> object before data starts processing. If you need to iterate through all of the historical values, it should be done in OnBarUpdate when State == State.Historical. By the time State == State.RealTime, the indicator would have ran through every bar on the chart.
Please let me know if I can assist any further.
-
When State == State.RealTime, I thought all processing is complete? I am doing a BarsRequest when State == State.RealTime to process tick data for the current day. I cannot use TickReplay or Add 1 Tick Data series, as I need to load about 180 days of minute data on the chart. I only need tick data for the last couple days so that is why I am using a BarsRequest.
Comment
-
That still is not working for me. I am in the State.RealTime when I do the BarsRequest
Code:barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) => { if (errorCode != ErrorCode.NoError) { // Handle any errors in requesting bars here //NinjaTrader.Code.Output.Process(string.Format("Err or on requesting bars: {0}, {1}", errorCode, errorMessage), PrintTo.OutputTab1); return; } try{ completeProcessing(bars.Bars, startAVPTime); } catch(Exception ex){ Print(ex.Message + " Delta_Regression.cs"); } for (int i = closeD.Count - 1, j = 0; i > 0; i--, j++) { Print("getBars: " + i + " " + j); Values[0][j] = closeD[i]; } dataRequestState = 1; }));Last edited by habibalex; 10-22-2020, 03:59 PM.
Comment
-
Hello habibalex, thanks for your reply.
Could you send me an example script to platformsupport at ninjatrader.com? Please Export the script and attach it to your email, referencing "Attn ChrisL 2792451" in the body of the email. Please make sure the test script does not include any third party scripts so I will be able to compile it properly.
I look forward to hearing from you.
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
548 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
549 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment