Navigation:Home > Content >

Alligator_работает_с_отложкой.mq4

Time: 2011-04-03 | Download file:Alligator_работает_с_отложкой.mq4

#property copyright "Drew Nya"
#property link      "[email protected]"

extern string Type = "EMPTY";
int TFrame = PERIOD_M1;
int TFrame2 = PERIOD_M5;

int init()
  {
      return(0);
  }
//-------------------------------------------------------------------------------
int deinit()
  {
      return(0);
  }
//-------------------------------------------------------------------------------
int start()
  {
      // ставим отложку ± 50 (otlStep) и ставим стоп у основной позиции на ± 70 (mainSLoss)
      // таким образом у отложки ставим т.профит на 100 (otlTProf)
  
  
      int Al;
      int total,cnt;
      double MA2,MA1;
      double K;
      
      double otlStep = 0.0040;
      double mainSLoss = 0.0040;
      double otlTProf = 0.0060;
      
      
      
      MA1 = iMA(NULL,TFrame2,13,0,MODE_SMA,PRICE_CLOSE,1);
      MA2 = iMA(NULL,TFrame2,13,0,MODE_SMA,PRICE_CLOSE,0);
      
      K = (MA2 - MA1)/0.05;
      
      Al = Alligator();      
           
     
      if(OrdersTotal() == 0)
      {
         if(Al == 1)
         {  
            if(Type != "BUY")
            {
               if((Hour() >= 9) && (Hour() <= 20)) 
                  if(MathAbs(K) <= 0.01)
                  {
                     OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+mainSLoss,Bid-0.0013,"",1,0,Red);
                     OrderSend(Symbol(),OP_BUYSTOP,1,Bid+otlStep,3,0,Bid+otlStep+otlTProf,"",0,0,Aqua);
                  }
               if((Hour() >= 9) && (Hour() <= 20))
                  if(MathAbs(K) > 0.01)
                  {
                     OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-mainSLoss,Ask+0.0013,"",2,0,Blue);
                     OrderSend(Symbol(),OP_SELLSTOP,1,Ask-otlStep,3,0,Ask-otlStep-otlTProf,"",0,0,Orange); 
                  }
               Type = "BUY";
               //Print("K: ", MathAbs(K));
               //Print("Time", TimeToStr(Time[0]));
               //Print("-------------------");
            }
         }
      }
      
      if(OrdersTotal() == 0)
      {
         if(Al == 2)
         {
            if(Type != "SELL")
            {               
               if((Hour() >= 9) && (Hour() <= 20))
                  if(MathAbs(K) <= 0.01)
                  {
                     OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-mainSLoss,Ask+0.0013,"",2,0,Blue);
                     OrderSend(Symbol(),OP_SELLSTOP,1,Ask-otlStep,3,0,Ask-otlStep-otlTProf,"",0,0,Orange); 
                  }
               if((Hour() >= 9) && (Hour() <= 20))
                  if(MathAbs(K) > 0.01)
                  {
                     OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+mainSLoss,Bid-0.0013,"",1,0,Red);
                     OrderSend(Symbol(),OP_BUYSTOP,1,Bid+otlStep,3,0,Bid+otlStep+otlTProf,"",0,0,Aqua);
                  }
               Type = "SELL";
               //Print("K: ", MathAbs(K));
               //Print("Time", TimeToStr(Time[0]));
               //Print("-------------------");
            }
         }
      }
      
      /*if(OrdersTotal() != 0)
      {
         //if(Al == 3)
         //{  
            total = OrdersTotal();
            for(cnt=0;cnt= 13)
                  {
                     OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);   
                  }
               }
               if(OrderType()==OP_SELL)
               {
                  if((OrderProfit() / 10) >= 13)
                  {
                     OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
                  }
               }
            }
         //}
      }*/


      if(OrdersTotal() == 1)
      {
         total = OrdersTotal();
         for(cnt=0;cnt Teeth) && (Teeth > Lips))
      {
         return(2);
      }
      else return(3);
  }
//-------------------------------------------------------------------------------
/*bool Tralingstop()//необходимо чтобы ордер был выбран
   {
      int TralingStop = 10;
      if(OrderType()==OP_BUY)
      {
         if(Open[0]-TralingStop*Point>OrderStopLoss()){OrderModify(OrderTicket(),OrderOpenPrice(),Open[0]-TralingStop*Point-0.0010,Open[0]+TralingStop*Point,0);return(true);}
      }
      if(OrderType()==OP_SELL)
         if(Open[0]+TralingStop*Point

Recommend