I've written a basic piece of code which colors bars green if they close above a 20-period SMA, and red if they close below.
When applied to price action, it seems to work ok. But if i add a visual SMA of the same period to the chart, its clear that its not working correctly. Infact the indicator seems to be making its calculations around a 10-period SMA, not 20.
Really don't understand why its halving the input period.. am i overlooking something?
Thanks!! Damien

Comment