I created a new indicator using the original NT's code for the ATR indicator, my aim is simply to plot ATR/Close for each bar on a chart.
Using the original NT's code with the required adjustments to the properties region, etc. works nicely. if I set my variable to ATR it plots ATR exactly as plotted using the original NT's indicator. If I set my variable to Close[0], it plots the close correctly too. BUT, when I set my variable to ATR/Close[0] it plots wrong values.
If I print ATR/Close[0] to the output window for debugging while my variable is set to (say...) ATR, then it prints the right values on the window, but if I set my variable to ATR/Close[0] then the output window gives the same wrong valus as the plot.
What am I doing wrong?
Attached is the code for my indicator. Below the key part of the OnBarUpdate:
double trueRange = High[0] - Low[0];
trueRange = Math.Max(Math.Abs(Low[0]... as in NT's original code
double ATRtemp;
ATRtemp = (((Math.Min(CurrentBar + 1, ... as in NT's original code
double todayClose = Close[0];
double ATRpctg = ATRtemp/todayClose;
Print(ATRpctg);
ATRPercentage.Set(ATRpctg); <--- if I set this to a different value (say Close[0]) the output window prints ATRpctg correctly
Thank you for your help!
Comment