With the help of some prior works of art, I created an indicator which changes the background color for a bar when the volume of that bar is above a minimum threshold and it is also greater than a certain percentage of the prior bars volume.
The problem, I'm having is that the indicator seems to work fine when I'm using the "CME US Index Futures ETH" Session template... but when I'm using the "CME US Index Futures RTH" Session template, the indicator does not plot anything....
From my troubleshooting, it appears that as soon as I include the the reference to Volume (which should be the prior bars volume, according to the NinjaTrader help manual) then the indicator will not plot on the RTH session template. If I remove this reference and just have the indicator plot if the CURRENT bars volume is higher than a threshold (disregarding the prior bars volume) then it works on BOTH the RTH and ETH session templates.
I find this very strange and I'm sure I'm just not doing something basic! Any help would be greatly appreciated.
Here is a screenshot of the code as well as showing the indicator working on the top right ETH session template chart and NOT working on the bottom right RTH session template chart:
You cannot reference the prior bar, when CurrentBar == 0. With the ETH session you were just lucky that the first bar usually is a low volume bar, such that lines 61 and 76 of your code were never executed.
All you need to do is to add the following lines of code in the beginning of OnBarUpdate():
The following 2 users say Thank You to Fat Tails for this post: