Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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[1] (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():