I'm trying to create a situation where if a bar meets a certain condition it gets painted red, however, if the bar following it fails to meet another condition, the initial bar gets re-painted dark red.
Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Posts: 49,790 since Jun 2009
Thanks: 32,314 given,
97,610
received
Historical is only true while backtesting or while a chart is being loaded/drawn for the first time after you open it. It is not true once it is fully loaded.
That said, I can't help with how to paint backwards on the price bars - don't have ninja installed anymore - but as for making an indicator repaint all you do is modify the array 1 bar back, like:
myArray[1] = newValue;
Probably similar for price bars. Hopefully someone can help.
I did not answer this in the first place because several things are confused. So let me summarize:
-> BarColor will only paint the current bar, you cannot use it to paint back.
-> "Historical" cannot be used this way. "Historical" refers to historical data as stored in the historical data base.If you connect to a data provider, typically NinjaTrader will backfill historical data for the time prior to connection and then collect real-time data. The previous bar, which you wanted to paint, can therefore be a real-time data bar. The use you made of "Historical" does not make any sense.
-> As @bukkan pointed out, if you want to reference the previous value of a BoolSeries, it would be BoolSeries[1], Boolseries[-1] will likely throw an out of range exception as the value has not been set.
What are you actually trying to achieve?
The following user says Thank You to Fat Tails for this post:
I define a Marubozu bar with a certain set of parameters. If the current bar meets those requirements, it gets painted green if it is an up bar or red if it is a down bar. However, the following bar is the confirmation bar. If it doesn't show sufficient follow through as defined by another set of parameters, then the initial Marubozu bar has 'failed' and that bar gets repainted a darker shade to show that status.
"-1" was used on purpose to refer to the next bar (confirmation bar), not the last bar.
The code was supposed to work like this: If this is the current bar, and it meets my definition of Marubozu, paint it red or green. However, if it is not the current bar, but it meets my definition of Marubozu, check the next bar and see if it has been confirmed. If it hasn't been confirmed, paint it the darker shade.
-> BarColor will only paint the current bar, you cannot use it to paint back.
I assume this means I cannot do what I would like to do as described above?
Thanks for your response and patience.
The following user says Thank You to srgtroy for this post: