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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
581 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
338 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment