Download MetaTrader 5

EMA over RSI EA code help

To add comments, please log in or register
Publish your programs in the Market. Make money with your knowledge!
timmytrade
6
timmytrade 2014.10.07 18:53 

The code below is RSI indicator with SMA on it. 

I need a sentence something like this:

if (SMA is above RSI) {

do whatever }

 

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Red

#property indicator_color2 Lime

#property indicator_level1 -150000

#property indicator_level2 150000



//---- input parameters



extern int rsi_p = 14;

extern int MA_Period=20;

extern int MA_Shift=0;

extern int MA_Method=0;

extern int NumberOfBarsToCalculate = 10000;



//---- indicator buffers



double Buffer0[];

double Buffer1[];

double Ma[];

double RSi[];



  int init()

  {

   IndicatorBuffers(4);

 

//---- indicator line



   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);

   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);

   SetIndexStyle(2,DRAW_NONE);

   SetIndexStyle(3,DRAW_NONE);



   SetIndexBuffer(0,Buffer0);

   SetIndexBuffer(1,Buffer1);

   SetIndexBuffer(2,Ma);

   SetIndexBuffer(3,RSi);



   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));



//----

   SetIndexEmptyValue(0,0);

   SetIndexEmptyValue(1,0);

   SetIndexEmptyValue(2,0);

   SetIndexEmptyValue(3,0);

//----

   return(0);

  }

 

int start() {



      string short_name;

      short_name = "RSI["+rsi_p+"] \ MA => Max bars to count: |"+(Bars-1)+"| ";

      IndicatorShortName(short_name);



      int shift;

      double rsi = 0;



      for(shift=NumberOfBarsToCalculate-1;shift>=0;shift--){

         RSi[shift] = iRSI(NULL,0,rsi_p,PRICE_CLOSE,shift);    

         }

      for(shift=NumberOfBarsToCalculate-1;shift>=0;shift--){

         Ma[shift] = iMAOnArray(RSi,0,MA_Period,MA_Shift,MA_Method,shift);

 

        Buffer0[shift] = RSi[shift];

         Buffer1[shift] = Ma[shift];

         }

      return(0);

}
To add comments, please log in or register