Navigation:Home > Content >

MA_rsi_(2).mq4

Time: 2016-11-12 | Download file:MA_rsi_(2).mq4

//+------------------------------------------------------------------+
//|                                                       MA rsi.mq4 |
//|                                      Copyright © 2006, Eli hayun |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli hayun"

#property link      "email alert by omelette"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red
//---- input parameters
extern bool      eMailAlerts_On = false;
extern int       maPeriod=1;
extern int       maMethod=MODE_SMMA;
extern int       maPrice=PRICE_CLOSE;
extern int       rsiPeriod=50;
extern int       rsiLevel=50;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int LastTradeType,LastTradeTime;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int limit,TradeType;
   int counted_bars=IndicatorCounted();
   string AlertMsg;
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop
   for(int i=0; i= rsiLevel) {
            ExtMapBuffer1[i] = ma;
            AlertMsg = "BUY Signal";
            TradeType = 1; }
         else { ExtMapBuffer2[i] = ma;
            AlertMsg = "SELL Signal";
            TradeType = -1; }
         if (eMailAlerts_On && LastTradeType != TradeType && LastTradeTime != Time[0]) {
           LastTradeType = TradeType;
           LastTradeTime = Time[0];
           SendMail("Expert-Advisor Generated Alert (MA-RSI) - ",Symbol()+" - "+AlertMsg); }                 
     }
     
   return(0);
  }
//+------------------------------------------------------------------+

Recommend