Hi folks just chasing coding for colouring bars etc according to the direction of the moving average, ie up or down. I am well aware of codes such as
MA(BARS=50, STYLE=Exponential, CALC=Close) IsUp etc but that code works on where bars are above or below average. I am actually just wanting the direction of the slope irrespective of whether the bars are under or over the moving average. I am able to code etc according to volatility of moving average but again the problme is it always is relative to over or under the moving average.
That example you gave is only for the direction of the slope of the MA50 – it does not look at where the price is in relation to the moving average. As such, this is all you need to set the bar colours for when the 50EMA is sloping up:
MA(BARS=50, STYLE=Exponential, CALC=Close) IsUp
Because of the way exponential moving averages are calculated (ie more weight given to the most recent bars) then it looks like the price is always below the 50EMA when the slope is down. Change to a simple moving average and you will see the difference.
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.