//| 1.  Take RSI(14) on close.
//| 2.  Take Momentum(9) of that RSI.
//| 3.  Take RSI(3) on close.
//| 4.  Take an SMA(3) of point 3.
//| 5.  Add together point 2 and point 4.
//| 6.  Take SMA(4) of point 5.
//| 7.  Take EMA(45) of point 5.
//| 8.  Print points 5, 6 & 7.
#property  copyright "Copyright © 2010, Robert Hill"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Gold
#property indicator_color3 Lime

//
//

extern int  RSI.Price       = PRICE_CLOSE;
extern int  RSI.SlowLength  = 14;
extern int  RSI.FastLength  =  3;
extern int  Momentum.Length =  9;
extern int  SMA.Length1     =  3;
extern int  SMA.Length2     = 4;
extern int  EMA.Length3     = 45;

//
//
// working buffers
double RSI_14[];
double RSI_Momentum_9[];
double RSI_3[];
double RSI_3_SMA_3[];

// display buffers
double Composite[];
double Composite_SMA4[];
double Composite_EMA45[];

//+----------------------------------------------------------------------------------+
//|                                                                                  |
//+----------------------------------------------------------------------------------+
//
//

int init()
{
   IndicatorBuffers(7);
   SetIndexBuffer(0,Composite);
   SetIndexBuffer(1,Composite_SMA4);
   SetIndexBuffer(2,Composite_EMA45);
   SetIndexBuffer(3,RSI_14);
   SetIndexBuffer(4,RSI_Momentum_9);
   SetIndexBuffer(5,RSI_3);
   SetIndexBuffer(6,RSI_3_SMA_3);
   return(0);
}
int deinit()
{
   return(0);
}

//+----------------------------------------------------------------------------------+
//|                                                                                  |
//+----------------------------------------------------------------------------------+
//
//

//| 8.  Print points 5, 6 & 7.

int start()
{
   int counted_bars=IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit = Bars-counted_bars;

   //
           
   for(i=limit; i >= 0; i--)
   {
//| 1.  Take RSI(14) on close.
      RSI_14[i] = iRSI(NULL,0,RSI.SlowLength,RSI.Price,i);
      
//| 3.  Take RSI(3) on close.
      RSI_3[i] = iRSI(NULL,0,RSI.FastLength,RSI.Price,i);
   }
      
//| 2.  Take Momentum(9) of RSI_14.
   for(i=0; i<limit; i++)
      RSI_Momentum_9[i]=iMomentumOnArray(RSI_14,Bars,Momentum.Length,i);
      
//| 4.  Take an SMA(3) of point 3.
   for(i=0; i<limit; i++)
      RSI_3_SMA_3[i]=iMAOnArray(RSI_3,Bars,SMA.Length1,0,MODE_SMA,i);
      
//----------------
// Display Time
//----------------
//| 5.  Add together point 2 and point 4.
   for(i=0; i<limit; i++)
      Composite[i] = RSI_Momentum_9[i] + RSI_3_SMA_3[i];
      
//| 6.  Take SMA(4) of point 5.
   for(i=0; i<limit; i++)
      Composite_SMA4[i]=iMAOnArray(Composite,Bars,SMA.Length2,0,MODE_SMA,i);

//| 7.  Take EMA(45) of point 5.
   for(i=0; i<limit; i++)
      Composite_EMA45[i]=iMAOnArray(Composite,Bars,EMA.Length3,0,MODE_EMA,i);
      
   return(0);
}

//+----------------------------------------------------------------------------------+



