if(CurrentBar < 1) { return; }
Values[0][0] = (Time[0]-Time[1]).TotalSeconds;
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
The time of the first 10 bars are not processed
Collapse
X
-
The time of the first 10 bars are not processed
I have a very simple indicator that reads:
However, it does not plot for the first 10 bars or so and then afterward it works correctly. I cannot figure out what the issue is. Appreciate any suggestions.Code:Tags: None
-
Hello Photon66,
Thank you for your post.
Do you have a BarsRequiredToPlot setting specified in State.SetDefaults? If you set this to the following do you see it plot starting on the first bar from the left:
Thanks in advance; I look forward to assisting you further.Code:if (State == State.SetDefaults) { BarsRequiredToPlot = 1; }
-
Hi Kate, Thank you for the comment. I did not have BarsRequiredToPlot option in my code and even by adding it and setting it to 1, it did not correct it. The entire indicator is shown below:
Thank you.Code:namespace NinjaTrader.NinjaScript.Indicators { public class timeBet : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "timeBet"; Calculate = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; BarsRequiredToPlot = 1; // -- > Added but did not make any diffrence AddPlot(Brushes.Orange, "TimeBetweenBars"); } else if (State == State.Configure) { } } protected override void OnBarUpdate() { if(CurrentBar < 1) { return; } Values[0][0] = (Time[0]-Time[1]).TotalSeconds; }
Comment
-
Hello Photon66,
Thank you for your reply.
I'm seeing this plotting all the way back to the 2nd bar on the chart (the first would be skipped since there's nothing to compare that first bar to). Have you removed the indicator from the chart and re-added it to ensure all changes are in place?
Thanks in advance; I look forward to assisting you further.
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
44 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
58 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
35 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
95 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
59 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment