Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Zig Zag Indicator doesn't plot until 20 bars
Collapse
X
-
The following indicators change the BarsRequiredToPlot so as to plot sooner then the first 20 bars. The code specifically sets BarsRequiredToPlot to a value other than 20.- Volume Up Down
- Range
- Buy Sell Pressure
- Buy Sell Volume
- Current Day OHL
Code:protected override void OnBarUpdate() { if (CurrentBar < 2) // Need at least 3 bars to calculate Low/High { zigZagHighSeries[0] = 0; zigZagLowSeries[0] = 0; return; } ...
1 Photo
Comment
-
Hello ntbone,
The ZigZag indicator does not actually use a plot set with plot values.
Instead this custom renders the lines in OnRender() in the code starting on line 348.
Because of this, BarsRequiredToPlot does not affect the custom rendered line.
Changing where this indicator starts rendering would require changing the custom logic within a copy of the script.
In your screenshot we can see the line starts on bar 8, 12 bars before bar 20.Chelsea B.NinjaTrader Customer Service
Comment
-
I have attached a screen shot of the exact same chart from my earlier screen shot with BarsRequiredToPlot for ZigZag set to 20 instead of 3. Notice the custom rendered line now starts after the yellow region. BarsRequiredToPlot seems to be impacting this OnRender code. This is the only code change made to the indicator.
I am using AAPL on a 1 minute chart from 2019/11/21 with the ZigZag set to 0.1 points.1 Photo
Comment
-
The yellow region is a drawing I created. The blue line is from the Zig Zag indicator. In my first screen shot in post #3, where BarsRequiredToPlot is set to 3, the blue line shows from the first detected place. In the second screen shot included in post #4 with the code set back to its installed state, the Zig Zag blue line doesn't start until outside the yellow region (which is the first 20 bars). Everything else about the two screen shots is identical.
Comment
-
With the Zig Zag indicator as installed, it won't plot anything prior to 20 bars despite being capable of plotting earlier.
There was no need to print out anything. I apply the indicator to a chart, and notice it won't plot anything for the first 20 bars, then I change the code adding the line BarsRequiredToPlot = 20. I remove the indicator and add it back in (since the code change alone won't apply to the existing indicator) and now I get plots starting much sooner.
I am suggesting that the code be changed with BarsRequiredToPlot set to 3 since the code won't do anything until there CurrentBar >= 2.
To reproduce the problem- Apply the Zig Zag indicator to 1 minute chart of AAPL with 390 bars of history. Set the Deviation value to 0.1
- Notice that nothing will show up in the first 20 bars
- Remove the indicator.
- Add the line BarsRequiredToPlot = 3 to the OnStateChange method SetDefaults state.
- Add the Zig Zag back.
- Notice now that the zig zag line will plot within the 20 bar range.
Comment
-
Hello ntbone,
This is true for all of the system scripts in NinjaTrader that have plots.
Anything with plots start at 20 bars. You can make a copy and change this in any of the indicators supplied with NinjaTrader.
The ZigZag is a different kind of beast because it technically doesn't set plots. (You may notice the values are n/a in the Data Series window)
There might be some logic in there to start the rendering after 20 bars, but its still going to be after the point of where the first leg is calculated to start.Chelsea B.NinjaTrader Customer Service
Comment
-
The Volume indicator has plots and the BarsRequired is set to 0 so I am finding inconsistencies. There is no logic that I have found in the Zig Zag indicator that prevents anything aside from the line of code I pointed out that prevents it from doing any calculates until the CurrentBar > 2. Further- Moving Average indicators (SMA, EMA) can start as soon as the period has passed. If I am looking at a 10 SMA/EMA it can plot as soon as 10 bars into the data. It needs the period # of bars to start plotting. If I am however looking at a 50 SMA, then there won't be any average until 50 bars into the plot. A 200 MA is even further out. In this case BarsRequiredToPlot should ideally be set to the period provided by the user.
- I listed in an earlier post a list of indicators that change the BarsRequiredToPlot to be a value other than the default value of 20. Range and Volume are included in this.
- BarsRequiredToPlot appears to limit the OnRender method from being called until after the chart has BarsRequiredToPlot.
Comment
-
Hello ntbone,
Yes, you are correct, there are some exceptions and there are some indicators that don't use plots at all.
The VOL and Range indicators are exceptions that do set BarsRequiredToPlot to 0, and begin plotting on the first bar.
If you are referring to the unmodified SMA indicator that is supplied by NinjaTrader, this will start plotting after 20 bars, no matter what the Period is set to.
Please add the SMA indicator to a chart and count the number of bars before the plot appears.
I'm happy to submit a feature request to use your script if you would like. It would be up to the NinjaTrader Development to decide if or when that would be implemented.
If you simply want to share this file, you can upload the file for sharing on the User App Share section of the forums.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello ntbone,
We have submitted a request to adjust all NinjaTrader 8 system indicators so their BarsRequiredToPlot property is set to the absolute minimum for each indicator. The tracking ID is SFT-4435.
As Chelsea mentioned, it will be up to Product Management and Development to determine if/when these changes will be made. Your interest and feedback is tracked, however.
We look forward to assisting.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Max Baxter, 03-07-2019, 09:20 PM
|
8 responses
266 views
0 likes
|
Last Post
by Ymcapital
Today, 04:17 PM
|
||
Started by Felix Reichert, 04-26-2024, 02:12 PM
|
9 responses
51 views
0 likes
|
Last Post Today, 03:56 PM | ||
Started by AaronKoRn, 04-27-2024, 09:49 PM
|
3 responses
31 views
0 likes
|
Last Post
by AaronKoRn
Today, 03:47 PM
|
||
Started by f.saeidi, Today, 07:07 AM
|
6 responses
19 views
0 likes
|
Last Post
by f.saeidi
Today, 03:31 PM
|
||
Started by cmtjoancolmenero, Today, 02:31 PM
|
6 responses
17 views
0 likes
|
Last Post Today, 03:29 PM |
Comment