Navigation:Home > Content >

RMO_cross.mq4

Time: 2015-05-05 | Download file:RMO_cross.mq4

//+------------------------------------------------------------------+
//|                                                    Rmo Cross.mq4 |
//|                         Copyright © 2008-2010, TradingSytemForex |
//|                                http://www.tradingsystemforex.com |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2008-2010, TradingSytemForex"
#property link "http://www.tradingsystemforex.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1  Lime
#property indicator_color2  Red

double CrossUp[];
double CrossDown[];
double prevtime;
double Range,AvgRange;
double LimeRmonow,LimeRmoprevious;
double GoldRmonow,GoldRmoprevious;

extern int MainFilterSpeed=8;
extern int MainFilterSlow=16;
extern int SmallFilterSpeed=3;
extern int SmallFilterSlow=12;

double MainFiltersMultipleFactor=1.0;
double SmallFiltersMultipleFactor=1.0;

int SlowFilterOffset=0;

double emaBuffer[999];
double emaRes[999];

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
//---- indicators
   SetIndexStyle(0,DRAW_ARROW,EMPTY);
   SetIndexArrow(0,225);
   SetIndexBuffer(0,CrossUp);
   SetIndexStyle(1,DRAW_ARROW,EMPTY);
   SetIndexArrow(1,226);
   SetIndexBuffer(1,CrossDown);
//----
   return(0);
}
  
//+------------------------------------------------------------------+
//| Deinitialization                                                 |
//+------------------------------------------------------------------+

int deinit()
{
//---- 

//----
   return(0);
}

double getAbsEMACO(int period, int shift){
  if(iMA(NULL,0,1,0,MODE_SMA,PRICE_CLOSE,shift+period+1)==0)return(0);
  else{
    int i=0;
    for(i=0;i0)counted_bars--;
   
   limit=Bars-counted_bars;
   
   for(i=0;i<=limit;i++)
   {
      counter=i;
      Range=0;
      AvgRange=0;
      for(counter=i;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;

      int signal=0;
      int currOffSet=i;

      if(getAbsEMACO(MainFilterSpeed,currOffSet)>getAbsEMACO(MainFilterSlow,currOffSet+SlowFilterOffset)){

      double _smallFilterSpeed=getEMACO(SmallFilterSpeed,currOffSet);      
      double _SmallFilterSlow=getAbsEMACO(SmallFilterSlow,currOffSet);

      if(_smallFilterSpeed>_SmallFilterSlow*SmallFiltersMultipleFactor)signal=1;
      else if(_smallFilterSpeed<-_SmallFilterSlow*SmallFiltersMultipleFactor)signal=-1;
    }
      
      if(signal==1)
      {
         CrossUp[i]=Low[i]-Range*0.5;
       }
       
      if(signal==-1)
      {
         CrossDown[i]=High[i]+Range*0.5;
      }
   }
   if((CrossUp[0]>2000) && (CrossDown[0]>2000)){prevtime=0;}
   if((CrossUp[0]==Low[0]-Range*0.5) && (prevtime!=Time[0]))
   {
      prevtime=Time[0];
      Alert(Symbol()," ELVP Cross Up @  Hour ",Hour(),"  Minute ",Minute());
   } 
   if((CrossDown[0]==High[0]+Range*0.5) && (prevtime!=Time[0]))
   {
      prevtime=Time[0];
      Alert(Symbol()," ELVP Cross Down @  Hour ",Hour(),"  Minute ",Minute());
   }
   return(0);
 }

Recommend