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
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
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.Chris L.NinjaTrader Customer Service
-
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.
What values are 'j' and 'i' getting up to versus the size of the closeD array? It's a indexing error being experienced that will need to be found through printing these values.
I look forward to hearing of your results.Chris L.NinjaTrader Customer Service
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.Chris L.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wuannetraam, Yesterday, 07:43 AM
|
5 responses
34 views
0 likes
|
Last Post Today, 07:35 AM | ||
Started by pjsmith, 06-30-2021, 02:57 AM
|
2 responses
22 views
0 likes
|
Last Post
by balltrader
Today, 07:29 AM
|
||
Started by Richardmm, 06-05-2018, 08:29 AM
|
5 responses
626 views
0 likes
|
Last Post
by balltrader
Today, 07:27 AM
|
||
Started by armybender, 11-16-2023, 08:38 PM
|
11 responses
178 views
0 likes
|
Last Post
by LogicQuest
Today, 07:17 AM
|
||
Started by arby7, 03-11-2018, 12:36 PM
|
13 responses
1,992 views
0 likes
|
Last Post Today, 07:11 AM |
Comment