indicator on indicator

 

Hi, how is it possible to make an indicator of a (custom) indicator (example: the exp. MA of another exp. MA)? Ive tried iCustom, but not accepted as "Symbol". Also Ive Tryed iMAOnarray, but somehow the iMAOnarray of the fist indicator's array is not giving more than a constant value for all the second indicator.¿ Is it possible to transform icustom in some kind of stringvalue that can be used with indicators? or ¿how should be an indicator array transformed to be used with iMAonarray? (if also tryed ArraySetAsSeries, with no succes by now) Well, if oneone can help me it would be great, cause it is already some days even dreaming about this problem !!! :-)

 

Here is one way:

Here is a Moving Average of RSI indicator.



//+------------------------------------------------------------------+
//|                                                    MA_On_RSI.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red

int rsi_period = 14;
int ma_period = 5;
int ma_method = 0;
int ma_shift = 0;
int applied_price = 0;

//---- buffers
double rsi[];
double rsima[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,rsi);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,rsima);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    repaintable_bars = Bars - IndicatorCounted();
   
   for(int shift = repaintable_bars; shift >= 0; shift--){
   rsi[shift] = iRSI(Symbol(), 0, rsi_period, applied_price, shift);
   }
   for(shift = repaintable_bars; shift >= 0; shift--){
   rsima[shift] = iMAOnArray(rsi, 0, ma_period, ma_shift, ma_method, shift);
   }
   return(0);
  }
//+------------------------------------------------------------------+
 
phy:

Here is one way:

Here is a Moving Average of RSI indicator.

IT WORKS! IT WORKS!!!!! Waw, thank you so much, I will study the code, to fully understand the way iMAOnArray works, cause I had not been able to make it work properly in my previous attempts.

Thank you for your answer and for this efficient elegant pice of code !!!

:-)

Reason: