Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Posts: 49,785 since Jun 2009
Thanks: 32,314 given,
97,577
received
I know many of you are wondering how to know for sure if an indicator repaints the past or not. So I propose we update this thread with indicators that we know for a fact do not repaint, and under what conditions that is true.
What is repainting?
Repainting is when a historical bar (a bar in the past) gets changed after the fact. This usually occurs on multicolor plots, but there are a few exceptions.
Why repaint?
The most popular reason is to connect two different colored plots together. It's a NinjaTrader limitation -- if the second plot were not connected to the first (ie: falling and rising colored plots), then there would be a visible gap between the two lines.
How can I avoid it?
The only way to absolutely, positively, avoid repainting is to examine the source code of the indicator. Only then can you know for certain if it repaints. The giveaway will look something like this:
The first command "Plot0.Set(1, ma[1]);" is the redraw command. It's taking 1 bar in the past and resetting the value of the plot. This in itself is not the real problem. The real problem is that Up, presumably, is an Rising Color plot. So what if 1 bar ago the MA wasn't rising? What if it was actually falling? Not anymore! It just got repainted to show that it was rising. See the problem?
How can I code to not repaint, but still have multicolor plots?
It's simple really, but it is only going to work on non-Line plots. A line has to be connected, but other plots like Dots don't. So the solution is simply to test to see if the user has selected a Line plot style, and if so, repaint. If not, don't repaint.
First it's better to not repaint every single bar, ie "if (Rising(ma))". That's every single rising bar. So we just look to see if this ma is higher than last bar, and if the prior bar was lower. In other words, a reversal in direction. If so, we then look to see if it's a Line plotstyle. If it is, then we have to repaint 1 bar in the past to connect the two plots. But if it is a Dot plotstyle, no repainting occurs, and you can sleep better at night.
Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Posts: 49,785 since Jun 2009
Thanks: 32,314 given,
97,577
received
If you are going to add an indicator to either list, please include a LINK to the indicator and when possible a version number. Otherwise it is useless because a newer/different version may exist.
mike im looking at a 12 range no gap chart with adxvma alerts set on 2 period, and i changed everything to dots. at 19:03 central time there was a yellow dot on a down bar at 19:26 central time the next bar closed down and both dots changed to red . i read somewhere you said to use dots and not lines and they wont repaint. am i doing something wrong?
Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Posts: 49,785 since Jun 2009
Thanks: 32,314 given,
97,577
received
I took another look at the code real quick. Seems I only took out the repainting for Conservative Mode. If you are not using conservative mode, it still repaints.
I will try to come back and fix this later, I just have no time right now.
I am working on a strategy that requires the exact status of a slope of an indicator in realtime at the time the trade is called to get triggered. In other words, no trigger from the close of the bar.
The indicator, in its current incarnation, does repaint the last bar. What I'm wondering is, does that repainting, in effect, undermine the integrity of the data that was used by the stategy to open a trade? Does repainting entail re-sloping? In other words, does this repainting change the prior data to render it unreliable?
I'm not a programmer, or a techie type, so forgive me if I'm not making total sense, but your help is greatly appreciated.
no it's the new one where I comment out the repaint code but it only look diff if you have line style = line. If you already use line style = dot you will see no diff.
So what you are saying is that I should have the linestyle=line to see the indicator in NO repaint version.... Can I use bars to have it as NO Repaint.
if linestyle = line; old version will repaint, new version will not
if linestyle = any other style, old version will not repaint, new version will not repaint.
The following 2 users say Thank You to cory for this post:
Thank you for your help on the ADXVMA indicator....I did find this indicator (T3 Multi), a while back from somewhere on the internet. I put it to test and I do believe that this one also repaints. I would appreciate if you could take a look at it and see if you could fix it if it is repainting.
Does the MACD_ZeroLag_Colors repaint? Based on post #1 and the code I think it might. Today I was testing a strategy in real-time and then later reloaded the chart extending the date; when the chart reloaded the MACD_ZeroLag_Colors did not display as during the realtime test.
I was wondering if someone that more clearly understands repainting can tell me whether ECO2 (attached) repaints?
My guess is yes. However, my backtesting using this indicator versus running live were pretty darn close, so I'm not positive. I'd like to know for sure from one of you experts if you could spare a moment.
In NT7 there is a new method, PlotColors, that allows true multi-color plotting.
Multi-color plotting means that different portions of ONE plot can have different colors. NOT that what looks like one plot is actually assembled from a bunch of different plots that get sort of linked together.
That means NO REPAINTING. EVER. PERIOD. On ANY type of Plot, including LINES.
This has"only" been available for about a year and a half, no wonder nobody knows about it.
Why change the color of a line on the fly programatically, when you can keep switching back and forth between different plots? Oh, I forgot.. can't use NT7, we love the way NT6.5 crashes all the time. Sorry.
I have posted SEVERAL indicators that use this technique. Here's one:
True multi color plotting is available in NT7 so it is no longer necessary to use the ridiculous workaround of switching between three different colored plots. Therefore I have correctly implemented multi-color plotting in this version of the ADXVMA that …
Here is the thread on the Ninjatrader forums where I learned how to do it:
I know many of you are wondering how to know for sure if an indicator repaints the past or not. So I propose we update this thread with indicators that we know for a fact do not repaint, and under what conditions that is true.
What is repainting?
Repainting …
post #22. I would be very grateful if someone could explain what conditions need to be met in order for the yellow diamonds to be displayed on the chart? I've attached the indicator and screenshot of parameter window and chart showing diamonds on it. I hope I've posted this correctly as I'm still learning to navigate the forum. Your assistance is appreciated
It looks like diamonds appear when the signal (adxvma) goes from non flat (rising or falling) to flat. You can confirm it on the screenshort - it always appears on the edge (last bar) of the different background color. When it switches directly from rising to falling (or the opposite) there is no diamond (look in the middle of the chart for an example)
Thank you very much for the reply and for explaining. I'm also trying to understand why there are 2 diamonds? Unfortunately I don't understand programming code but I notice in the code you attached it shows "topdiamond" and "botdiamond"
What is the relationship of the 2 diamonds and what is each one telling us?
There is no distinction between them - the 2 are drawn instead of 1 to stand out better - making a unique 2 diamond shape. Think of it as one object as they are never drawn separately.
This is a better picture, back then the indicator just showed a flat line when slope was neutral then somebody added " neutral zone". The zone is marked by top and bottom diamonds. Note: you set the zone width. Also note neutral = chop zone.
Thanks for the help…….. Unfortunately I'm still not clear on how to read the diamonds. Please bear with me. It's important I understand this correctly.
The diamonds only appear on one bar and that bar is either at the end of the uptrend (ADXVMA blue background) or end of the downtrend (ADXVMA pink background). Are the diamonds indicating that this bar is the START of the neutral zone even though the bar is not showing in ADXVMA neutral zone?
@cory says “The zone is marked by top and bottom diamonds. Note: you set the zone width”?
From what I’m seeing on the chart, the diamonds are not in the’’ zone’’? The diamonds are only displayed on one bar (candlestick), always one bar before the neutral zone starts. Also, what do you mean by ‘’ you set the zone width’’?
So, I’m still not clear on what the diamonds are telling us?
I really appreciate your assistance and patience
Kind regards
Thanks very much Cory. Do you perhaps know the answers to my other questions regarding why the diamonds appear at the end of uptrend/downtrend and not at start of neutral zone?