Navigation:Home > Content >

CSP_#3.mq4

Time: 2017-10-13 | Download file:CSP_#3.mq4

#property copyright "DREW"
#property link      "[email protected]"

extern int tHour = 10;
extern int TFrame = PERIOD_H1;
extern int dDay = 0;
extern int nomln = 0;


int init()
{
   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   int total,cnt;
   int quantOTL = 0;

   total = OrdersTotal();
   for(cnt=0;cnt= 23)
   {
      total = OrdersTotal();
      for(cnt=0;cnt= 23)
   {
      total = OrdersTotal();
      for(cnt=0;cnt 16) ATR_end = ATR * 3;
            
      if(Diff > 50)
      {
         BUYlev = ATR_end * 0.0001 + ClosePrice;
         SELLlev = ClosePrice - ATR_end * 0.0001;
      }
      else
      {
         BUYlev = (OpenPrice + ClosePrice) / 2 + (ATR_end * 0.0001);
         BUYlev = MathRound(BUYlev * 10000) * 0.0001;
         SELLlev = (OpenPrice + ClosePrice) / 2 - (ATR_end * 0.0001);
         SELLlev = MathRound(SELLlev * 10000) * 0.0001;
      }

      BUYlev = BUYlev - 0.0015;
      SELLlev = SELLlev + 0.0015;
      
      
      // Блок II: расчет TP и SL
      double stepPlusMinus;
      if((ATR * 3) > 45) stepPlusMinus = 45 * 0.0001;
      else stepPlusMinus = (ATR * 3) * 0.0001;
      
      
      double slBUY = CurPrice - stepPlusMinus;
      double slSELL = CurPrice + stepPlusMinus;
      double tpBUY = CurPrice + 0.0019;
      double tpSELL = CurPrice - 0.0019;
      
      double SL, TP;
      if(CurPrice == BUYlev) SL = slBUY;
      else SL = slSELL; 
      if(CurPrice == SELLlev) TP = tpBUY;
      else TP = tpSELL; 
      
      double TPfact = MathAbs(TP - CurPrice);
      double SLfact = MathAbs(CurPrice - SL);
      
      /*ObjectCreate("LineTPBUY"+nomln,OBJ_TREND,0,iTime(NULL,PERIOD_H1,0),BUYlev+TPfact,iTime(NULL,PERIOD_H1,2),TP);
      ObjectSet("LineTPBUY"+nomln,OBJPROP_TIME1,iTime(NULL,PERIOD_H1,0));
      ObjectSet("LineTPBUY"+nomln,OBJPROP_TIME2,iTime(NULL,PERIOD_H1,2));
      ObjectSet("LineTPBUY"+nomln,OBJPROP_PRICE1,BUYlev+TPfact);
      ObjectSet("LineTPBUY"+nomln,OBJPROP_PRICE2,BUYlev+TPfact);
      ObjectSet("LineTPBUY"+nomln,OBJPROP_COLOR,Blue);
      ObjectSet("LineTPBUY"+nomln,OBJPROP_WIDTH,2);
      ObjectSet("LineTPBUY"+nomln,OBJPROP_RAY,0);
      
      ObjectCreate("LineSLBUY"+nomln,OBJ_TREND,0,iTime(NULL,PERIOD_H1,0),BUYlev-SLfact,iTime(NULL,PERIOD_H1,2),SL);
      ObjectSet("LineSLBUY"+nomln,OBJPROP_TIME1,iTime(NULL,PERIOD_H1,0));
      ObjectSet("LineSLBUY"+nomln,OBJPROP_TIME2,iTime(NULL,PERIOD_H1,2));
      ObjectSet("LineSLBUY"+nomln,OBJPROP_PRICE1,BUYlev-SLfact);
      ObjectSet("LineSLBUY"+nomln,OBJPROP_PRICE2,BUYlev-SLfact);
      ObjectSet("LineSLBUY"+nomln,OBJPROP_COLOR,Blue);
      ObjectSet("LineSLBUY"+nomln,OBJPROP_WIDTH,2);
      ObjectSet("LineSLBUY"+nomln,OBJPROP_RAY,0);

      ObjectCreate("LineTPSELL"+nomln,OBJ_TREND,0,iTime(NULL,PERIOD_H1,0),SELLlev-TPfact,iTime(NULL,PERIOD_H1,2),TP);
      ObjectSet("LineTPSELL"+nomln,OBJPROP_TIME1,iTime(NULL,PERIOD_H1,0));
      ObjectSet("LineTPSELL"+nomln,OBJPROP_TIME2,iTime(NULL,PERIOD_H1,2));
      ObjectSet("LineTPSELL"+nomln,OBJPROP_PRICE1,BUYlev-TPfact);
      ObjectSet("LineTPSELL"+nomln,OBJPROP_PRICE2,BUYlev-TPfact);
      ObjectSet("LineTPSELL"+nomln,OBJPROP_COLOR,Red);
      ObjectSet("LineTPSELL"+nomln,OBJPROP_WIDTH,2);
      ObjectSet("LineTPSELL"+nomln,OBJPROP_RAY,0);
      
      ObjectCreate("LineSLSELL"+nomln,OBJ_TREND,0,iTime(NULL,PERIOD_H1,0),SELLlev+SLfact,iTime(NULL,PERIOD_H1,2),SL);
      ObjectSet("LineSLSELL"+nomln,OBJPROP_TIME1,iTime(NULL,PERIOD_H1,0));
      ObjectSet("LineSLSELL"+nomln,OBJPROP_TIME2,iTime(NULL,PERIOD_H1,2));
      ObjectSet("LineSLSELL"+nomln,OBJPROP_PRICE1,BUYlev+SLfact);
      ObjectSet("LineSLSELL"+nomln,OBJPROP_PRICE2,BUYlev+SLfact);
      ObjectSet("LineSLSELL"+nomln,OBJPROP_COLOR,Red);
      ObjectSet("LineSLSELL"+nomln,OBJPROP_WIDTH,2);
      ObjectSet("LineSLSELL"+nomln,OBJPROP_RAY,0);*/

      ObjectCreate("LineBUY"+nomln,OBJ_TREND,0,iTime(NULL,PERIOD_H1,0),BUYlev,iTime(NULL,PERIOD_H1,5),BUYlev);
      ObjectSet("LineBUY"+nomln,OBJPROP_TIME1,iTime(NULL,PERIOD_H1,0));
      ObjectSet("LineBUY"+nomln,OBJPROP_TIME2,iTime(NULL,PERIOD_H1,5));
      ObjectSet("LineBUY"+nomln,OBJPROP_PRICE1,BUYlev);
      ObjectSet("LineBUY"+nomln,OBJPROP_PRICE2,BUYlev);
      ObjectSet("LineBUY"+nomln,OBJPROP_COLOR,Blue);
      ObjectSet("LineBUY"+nomln,OBJPROP_WIDTH,2);
      ObjectSet("LineBUY"+nomln,OBJPROP_RAY,0);
      
      ObjectCreate("LineSELL"+nomln,OBJ_TREND,0,iTime(NULL,PERIOD_H1,0),SELLlev,iTime(NULL,PERIOD_H1,5),SELLlev);
      ObjectSet("LineSELL"+nomln,OBJPROP_TIME1,iTime(NULL,PERIOD_H1,0));
      ObjectSet("LineSELL"+nomln,OBJPROP_TIME2,iTime(NULL,PERIOD_H1,5));
      ObjectSet("LineSELL"+nomln,OBJPROP_PRICE1,SELLlev);
      ObjectSet("LineSELL"+nomln,OBJPROP_PRICE2,SELLlev);
      ObjectSet("LineSELL"+nomln,OBJPROP_COLOR,Red);
      ObjectSet("LineSELL"+nomln,OBJPROP_WIDTH,2);
      ObjectSet("LineSELL"+nomln,OBJPROP_RAY,0);
      
      
      total = OrdersTotal();
      for(cnt=0;cnt        

Recommend