Navigation´╝ÜHome > Content >

SOT_DOT.mq4

Time: 2013-09-13 | Download file:SOT_DOT.mq4

//+------------------------------------------------------------------+
//|                                            Trade SpeedoMETER.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red 
#property indicator_width1 1
#property indicator_width2 1
 
extern bool Alerts = False;
double CrossUp[];
double CrossDown[];
bool  CrossedUp = false;
bool  CrossedDown = false;

int SignalLabeled = 0; // 0: initial state; 1: up; 2: down.
int upalert=false,downalert=false;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 225);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 226);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
  
  
  
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   
  
    
  
   double pnow;
   double p1, p2, p3, p4, p5, p6;
   double SOT,SOT1,SOT2,SOT3,SOT4,SOT5,SOT6;
   double SOTAV6;
   double SOTAV2;
   double Range, AvgRange;

   
   

   int counted_bars=IndicatorCounted();
//---- 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;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+12;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/18;
   
   
    // current price Close and Open
   double OpenPricenow = Open [i];
   double ClosePricenow = Close [i];
   double Volumenow = Volume [i]+1;
   
   // candle 1
   double OpenPrice1 = Open [i+1];
   double ClosePrice1 = Close [i+1];
   double Volume1    = Volume [i+1]+1;
   
   
   // candle 2
   double OpenPrice2 = Open [i+2];
   double ClosePrice2 = Close [i+2];
   double Volume2     = Volume [i+2]+1;
   
   
   
   
   // candle 3
   double OpenPrice3 = Open [i+3];
   double ClosePrice3 = Close [i+3];
   double Volume3     = Volume [i+3]+1;
   
   // candle 4
   
   double OpenPrice4 = Open [i+4];
   double ClosePrice4 = Close [i+4];
   double Volume4     = Volume [i+4]+1;
   
   
   
   //  candle 5
   
   double OpenPrice5 = Open [i+5];
   double ClosePrice5 = Close [i+5];
   double Volume5    = Volume [i+5]+1;
   
   
   //  candle 6
   
   double OpenPrice6 = Open [i+6];
   double ClosePrice6 = Close [i+6];
   double Volume6   =  Volume [i+6]+1;
   
   
   
   
   pnow = (ClosePricenow - OpenPricenow); 
   SOT  =  (pnow / Volumenow)*10000;
   
   
    p1   = (ClosePrice1 - OpenPrice1);
   SOT1 = (p1 / Volume1) *10000;
   
   
    p2   = (ClosePrice2 - OpenPrice2);
    SOT2 = (p2 / Volume2) *10000;
   
   
    p3 = (ClosePrice3 - OpenPrice3);
    SOT3 = (p3 / Volume3) *10000;
   
   
    p4 = (ClosePrice4 - OpenPrice4);
    SOT4= (p4 / Volume4) *10000;
   
   
    p5 = (ClosePrice5 - OpenPrice5);
    SOT5 = (p5 / Volume5) *10000;
   
   
    p6 = (ClosePrice6 - OpenPrice6);
    SOT6 = (p6 / Volume6) *10000;
   
   
    
   
   
    SOTAV6 = ((SOT1+SOT2+SOT3+SOT4+SOT5+SOT6)/6);
    
    SOTAV2 = (SOTAV6*2);
   
    
  if ((SOT1>SOTAV2) && (ClosePrice2SOTAV2) && (ClosePrice2>OpenPrice2) && (ClosePrice1>OpenPrice1))  {
        CrossedUp = false;
        CrossedDown = true;
        
        }
      
  
  if ((CrossedUp  == true)  && (SignalLabeled != 1)) {
         CrossUp[i] = Low[i] - Range;
         if(i<=2 && Alerts && !upalert)
           {
            Alert (Symbol()," ",Period()," M Price UP ");
            //SendMail("Buy "+Symbol(),"");
            upalert=true;
            downalert=false;
           }
         SignalLabeled = 1;
         
      }   
  
  
  
  if ((CrossedDown  == true) && (SignalLabeled != 2)) {
         CrossDown[i] = High[i] + Range;
         if(i<=2 && Alerts && !downalert)
           {
            Alert (Symbol()," ",Period(),"M  Price DOWN ");
            //SendMail("Sell "+Symbol(),"");
            downalert=true;
            upalert=false;
           }
         SignalLabeled = 2;
      }
   
  
  
   
  
  
  
  
  
  }
  
 
  return(0);
  
  }  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  


Recommend