Colour change sma with a lookback period
- Help with changing an indicator
- Need some help.
- Indicators: Volumes
//+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { //--- const int toCopy=(rates_total==prev_calculated)?1:rates_total-prev_calculated; if(CopyBuffer(handle,0,0,toCopy,MABuffer)!=toCopy) return(0); //--- const int limit=(rates_total==prev_calculated)?prev_calculated-1:(!prev_calculated)?Period+Lookback:prev_calculated; for(int i=limit;i<rates_total;i++) MAColors[i]=(MABuffer[i]>MABuffer[i-Lookback])?0:(MABuffer[i]<MABuffer[i-Lookback])?1:2; //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Forum on trading, automated trading systems and testing trading strategies
Showing color iMA using iCustom, is this the solution?
Vladimir Karputov, 2020.08.17 15:28
Indicator idea
The iMA (Moving Average, MA) indicator on the ' MA: trend N Bars ' segment will define the trend. DRAW_COLOR_LINE paints the indicator in three colors using the graphical plotting style. The first color - the trend is not defined, the second - the uptrend and the third - the downward trend.

Figure: 1. MA Color N Bars
The indicator allows you to more visually highlight trend areas.
Thank you, I've seen that one but I didn't like it as much.