Navigation:Home > Content >

RSI_Filter_vX2D2alert_mtf_(2).mq4

Time: 2016-04-16 | Download file:RSI_Filter_vX2D2alert_mtf_(2).mq4

//+------------------------------------------------------------------+
//|RSI_Filter                                       CCIFilter vX.mq4 |
//|                                                                  |                                      
//|                                                      mod by Raff |   
//+------------------------------------------------------------------+
// mtf 2008fxtsd  ki 

#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 SlateGray
#property indicator_color2 Lime
#property indicator_color3 DarkTurquoise
#property indicator_color4 Tomato
#property indicator_color5 Red
#property indicator_color6 Magenta
#property indicator_color7 ForestGreen
#property indicator_color8 Yellow

#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width6 1
#property indicator_width7 1
#property indicator_width8 1
//#property  indicator_level1  0
#property indicator_level1  70
#property indicator_level2  50
#property indicator_level3  30

#property indicator_levelcolor DarkSlateGray


//---- input parameters
extern int    RSI_Period             = 14;
extern int    RSI_Price              = 0;
extern int    UpperTriggerLevel     =  70;
extern int    LowerTriggerLevel     =  30;
//extern int    CriticalLevel         = 250;
extern int    TimeFrame = 0;
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";

extern bool   ShowBARS             = false;
extern int    BarWidth             = 4;
extern int    LineWidth            = 2;

extern bool   Show_Dots            = true;

extern bool   ZeroCrossAlerts                = true;
extern bool   LevelCrossAlerts               = true;

//extern string CriticalLevelAlert    = "CCI Critical Level";
extern string ZeroCrossUpAlert          = "RSI Level 50 Cross Up; ";
extern string ZeroCrossDnAlert          = "RSI Level 50 Cross Dn; ";
extern string UpperTriggerBuyAlert  = "RSI Upper Trigger CrossUp; ";
extern string UpperTriggerSellAlert = "RSI Upper Trigger CrossDn; ";
extern string LowerTriggerBuyAlert  = "RSI Lower Trigger CrossUp; ";
extern string LowerTriggerSellAlert = "RSI Lower Trigger CrossDn; ";
extern int    MaxBarsToCount           = 1500;
extern string note_Price = "Price(C O1 H2 3L 4M 5T W6)";

//---- indicator buffers
double RSI[];
double UpBuffer1[];
double UpBuffer2[];
double DnBuffer1[];
double DnBuffer2[];
double DnArr[];
double UpArr[];
double RSI_Dot[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  int init()
  {
   IndicatorBuffers(8);
   

   SetIndexStyle(0,DRAW_LINE,0,LineWidth);
   SetIndexStyle(1,DRAW_LINE,0,LineWidth);
   SetIndexStyle(2,DRAW_LINE,0,LineWidth);
   SetIndexStyle(3,DRAW_LINE,0,LineWidth);
   SetIndexStyle(4,DRAW_LINE,0,LineWidth);
   if (ShowBARS) 
   {
   SetIndexStyle(1,DRAW_HISTOGRAM,0,BarWidth);
   SetIndexStyle(2,DRAW_HISTOGRAM,0,BarWidth);
   SetIndexStyle(3,DRAW_HISTOGRAM,0,BarWidth);
   SetIndexStyle(4,DRAW_HISTOGRAM,0,BarWidth);
   }
   
   SetIndexEmptyValue(5,EMPTY_VALUE);
   SetIndexEmptyValue(6,EMPTY_VALUE);
   
   SetIndexStyle  (5,DRAW_ARROW);
   SetIndexArrow  (5,159);
   SetIndexBuffer (5,DnArr);
   SetIndexStyle  (6,DRAW_ARROW);
   SetIndexArrow  (6,159);
   SetIndexBuffer (6,UpArr);
   
   SetIndexEmptyValue(7,EMPTY_VALUE);
   SetIndexArrow(7,158);     //159 115
   SetIndexStyle(7,DRAW_NONE);
   if(Show_Dots && !ShowBARS)     
   SetIndexStyle(7,DRAW_ARROW);

   

   SetIndexBuffer(0,RSI);
   SetIndexBuffer(1,UpBuffer1);
   SetIndexBuffer(2,UpBuffer2);
   SetIndexBuffer(3,DnBuffer1);
   SetIndexBuffer(4,DnBuffer2);
   SetIndexBuffer(5,DnArr);
   SetIndexBuffer(6,UpArr);
   SetIndexBuffer(7,RSI_Dot);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
      
      TimeFrame= MathMax(TimeFrame,Period());

      switch(TimeFrame)
     {
      case 1 : string TimeFrameStr= "M1";  break;
      case 5 : TimeFrameStr=        "M5";  break;
      case 15 : TimeFrameStr=       "M15"; break;
      case 30 : TimeFrameStr=       "M30"; break;
      case 60 : TimeFrameStr=       "H1";  break;
      case 240 : TimeFrameStr=      "H4";  break;
      case 1440 : TimeFrameStr=     "D1";  break;
      case 10080 : TimeFrameStr=    "W1";  break;
      case 43200 : TimeFrameStr=    "MN1"; break;
      default : TimeFrameStr= "TF0";
     }

   string short_name;
   short_name="RSI Filter ("+RSI_Period+") ["+TimeFrameStr+"] L("+UpperTriggerLevel+", "+LowerTriggerLevel+")";
   IndicatorShortName(short_name);
   
   SetIndexLabel(0,"RSI ("+RSI_Period+")["+TimeFrameStr+"]");
   SetIndexLabel(1,"UpTrend");
   SetIndexLabel(2,"Mild UpTrend");
   SetIndexLabel(3,"Mild DownTrend");
   SetIndexLabel(4,"DownTrend");
   SetIndexLabel(5,"RSI ("+RSI_Period+")["+TimeFrameStr+"]Dn");
   SetIndexLabel(6,"RSI ("+RSI_Period+")["+TimeFrameStr+"]Up");
  
   SetIndexDrawBegin(0,RSI_Period);
   SetIndexDrawBegin(1,RSI_Period);
   SetIndexDrawBegin(2,RSI_Period);
   SetIndexDrawBegin(3,RSI_Period);  
   SetIndexDrawBegin(4,RSI_Period);
   SetIndexDrawBegin(5,RSI_Period);  
   SetIndexDrawBegin(6,RSI_Period);
   SetIndexDrawBegin(7,RSI_Period);  

   return(0);
  }

//+------------------------------------------------------------------+
//| CCIFilter                                                        |
//+------------------------------------------------------------------+
int start()
  {
   int shift,trend;
   datetime TimeArray[];
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 

   
   double CCI0, CCI1;
   double UpDnZero, UpDnBuffer;
   

   int    limit,y, counted_bars=IndicatorCounted();
   limit= Bars-counted_bars;
   limit= MathMax(limit,TimeFrame/Period());
   limit= MathMin(limit,MaxBarsToCount);

   for(shift=0,y=0;shiftUpperTriggerLevel)  UpBuffer1[shift]=UpDnBuffer;
	  if (CCI0>50 && CCI0<=UpperTriggerLevel) UpBuffer2[shift]=UpDnBuffer;
	  if (CCI0<50 && CCI0>=LowerTriggerLevel) DnBuffer1[shift]=UpDnBuffer;
	  if (CCI050 && CCI1<=50) {if(!ShowBARS) UpArr[shift]=50; if(shift==0 && ZeroCrossAlerts) Alerts(ZeroCrossUpAlert);}
     if (CCI0<50 && CCI1>=50) {if(!ShowBARS) DnArr[shift]=50; if(shift==0 && ZeroCrossAlerts) Alerts(ZeroCrossDnAlert);}
     if (CCI0>UpperTriggerLevel && CCI1<=UpperTriggerLevel) {if(!ShowBARS) UpArr[shift]=UpperTriggerLevel; if(shift==0 && LevelCrossAlerts) Alerts(UpperTriggerBuyAlert);}
     if (CCI0=UpperTriggerLevel) {if(!ShowBARS) DnArr[shift]=UpperTriggerLevel; if(shift==0 && LevelCrossAlerts) Alerts(UpperTriggerSellAlert);}
     if (CCI0>LowerTriggerLevel && CCI1<=LowerTriggerLevel) {if(!ShowBARS) UpArr[shift]=LowerTriggerLevel; if(shift==0 && LevelCrossAlerts) Alerts(LowerTriggerBuyAlert);}
     if (CCI0=LowerTriggerLevel) {if(!ShowBARS) DnArr[shift]=LowerTriggerLevel; if(shift==0 && LevelCrossAlerts) Alerts(LowerTriggerSellAlert);}
//     if (MathAbs(CCI0)>CriticalLevel && MathAbs(CCI1)<=CriticalLevel) {if(shift==0) Alerts(CriticalLevelAlert);}
//     if (MathAbs(CCI0)=CriticalLevel) {if(shift==0) Alerts(CriticalLevelAlert);}
	}

	return(0);	
 }

void Alerts(string AlertText)
  {

    static datetime timeprev;
    if(timeprev        

Recommend