Navigation:Home > Content >

Болван-TraderArrow.mq4

Time: 2014-08-08 | Download file:Болван-TraderArrow.mq4

//+------------------------------------------------------------------+
//|                                               Болван_scalper.mq4 |
//|                                                    Ksardas Tower |
//|                                                                  |
//+------------------------------------------------------------------+
//#property copyright "Copyright 2014, MetaQuotes Software Corp."    |
//#property link      "Свободы.net"                                  |
//--------------------------------------------------------------------
extern string  time                 ="Время работы";
extern int     Start                = 4,
               Stop                 = 14;    
extern string  Indicator            = "Setting";     
extern int     bar                  = 1;
extern int     Stoploss             = 200,           //стоплосс
               Takeprofit           = 700,           //тейкпрофит
               TrailingStop         = 100,           //трейлингстоп, если 0, то нет трейлинга
               NoLoss               = 100;           //перевод в безубыток, если 0, то нет перевода в безубыток

extern bool    CloseRevers          = true;
extern bool    CloseTime            = true;
extern int     Timeclose            = 350;
extern double  pip                  = 5,           
               Lot                  = 0.1,         //если Lot=0, то лот расчитывается от свободных средств
               risk                 = 10;          //процент свободных средств для расчета плавающего ордера
extern bool    Comente              =true ;  
extern int     Magic                = 22072014;

//--------------------------------------------------------------------
int TimeBar,STOPLEVEL;
int triger=2,
    check=2,
     day =8;

int start()
{
   
//-----------------------------------------------

if(CloseTime==true ){
     int total=OrdersTotal(); //количество ордеров
     for ( int a=0;aTimeclose*60)&&
                  OrderMagicNumber()==Magic)
                   {  
          if((OrderType()==OP_SELL )&&((OrderOpenPrice()-iClose(NULL,PERIOD_M5,0))/(10*Point))>=pip)
              {
               if(OrderClose(OrderTicket(),OrderLots(),Ask,10,Blue)) Print ("Завис Sell");
              }
          if((OrderType()==OP_BUY )&&((iClose(NULL,PERIOD_M5,0)-OrderOpenPrice())/(10*Point))>=pip)
                {
                if(OrderClose(OrderTicket(),OrderLots(),Ask,10,Blue))Print ("Завис Buy");
                }
         }   
     }
   }
//-----------------------------------------------
     
   int Ticket,b,s,tip;STOPLEVEL=MarketInfo(Symbol(),MODE_STOPLEVEL);
   double OSL,OTP,OOP,StLo,SL,TP;
   for (int i=0; i=STOPLEVEL && Stoploss!=0)
                  {
                     SL = NormalizeDouble(Bid - Stoploss   * Point,Digits);
                  } 
                  else SL=OSL;
                  if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)
                  {
                     TP = NormalizeDouble(Ask + Takeprofit * Point,Digits);
                  } 
                  else TP=OTP;
                  if (NoLoss>=STOPLEVEL && OSL=STOPLEVEL && TrailingStop!=0)
                  {
                     StLo = NormalizeDouble(Bid-TrailingStop*Point,Digits);
                     if (StLo >= OOP && StLo <= NormalizeDouble(Bid-STOPLEVEL*Point,Digits) && StLo > OSL) SL = StLo;
                  }
                  if (SL > OSL || TP != OTP)
                  {  
                     if (!OrderModify(Ticket,OOP,SL,TP,0,White)) Print("Error order ",Ticket);
                  }
               }                                         
               if (tip==OP_SELL)        
               {
                  s++;
                  if (OSL==0 && Stoploss>=STOPLEVEL && Stoploss!=0)
                  {
                     SL = NormalizeDouble(Ask + Stoploss   * Point,Digits);
                  }
                  else SL=OSL;
                  if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)
                  {
                     TP = NormalizeDouble(Bid - Takeprofit * Point,Digits);
                  }
                  else TP=OTP;
                  if (NoLoss>=STOPLEVEL && (OSL>OOP || OSL==0) && NoLoss!=0)
                  {
                     if (OOP >= NormalizeDouble(Ask+NoLoss*Point,Digits)) SL = OOP-15*Point;
                  }
                  if (TrailingStop>=STOPLEVEL && TrailingStop!=0)
                  {
                     StLo = NormalizeDouble(Ask+TrailingStop*Point,Digits);
                     if (StLo <= OOP && StLo >= NormalizeDouble(Ask+STOPLEVEL*Point,Digits) && (StLo < OSL || OSL==0)) SL = StLo;
                  }
                  if ((SL < OSL || OSL==0) || TP != OTP)
                  {  
                     if (!OrderModify(Ticket,OOP,SL,TP,0,White)) Print("Error order ",Ticket);
                  }
               } 
               
            }
         }
      }
   }
 if (IsDemo()) string ts = "Демо"; else ts = "Реал";
   if(Comente==true)
      {Comment(
      "\n"," Тип счета: "+ts+" - №: "+ AccountNumber(),
      "\n"," Счет в компании   ", AccountCompany(),
      "\n"," Плечо = 1 : ",AccountLeverage(),"\n",
      "--------------------------------------------------------",
      "\n"," Тейк Профит в валюте депо = ",Profit(),
      "\n"," Балланс = ",NormalizeDouble(AccountBalance(),2),
      "\n"," Эквити  = ",NormalizeDouble(AccountEquity(),2),"\n",
      "--------------------------------------------------------",
      "\n"
        );  }
    
   if(Hour()=Stop) return(0);
   if (TimeBar==Time[0]) return(0);
   for (int sift = bar; sift < 3; sift++) {
            if (Time[sift] > 0) {
               if (ObjectGet("tdi ssa arrows:" + Time[sift], OBJPROP_COLOR) == LimeGreen) {
                  check = 1;
                  
                  break;
               }
               if (ObjectGet("tdi ssa arrows:" + Time[sift], OBJPROP_COLOR) == Red) {
                  check = 0;
                 
                  break;
               }
            }
         }
   if (day!=DayOfWeek())triger=2;
     
   if(triger!=1&&check == 0)//&&rsi=b)       
         {
       int ticket=OrderSend(Symbol(),OP_SELL,LOT(),NormalizeDouble(Bid,Digits),2,0,0,"болван sell",Magic,Red);
       TimeBar=Time[0];
       day=DayOfWeek();
       triger=1;
       if (ticket<0) Print ("Не смогли продать из-за ошибки! ",GetLastError());
         }
      }
   if(triger!=0&&check == 1)//&&ema=s)       
         {
       ticket=OrderSend(Symbol(),OP_BUY, LOT(),NormalizeDouble(Ask,Digits),2,0,0,"болван buy",Magic,Blue);
       TimeBar=Time[0];
       day=DayOfWeek();
       triger=0; 
       if (ticket<0) Print ("Не смогли купить из-за ошибки! ",GetLastError());
         }
       }  
           
return(0);
}
//--------------------------------------------------------------------
 double Profit() {
   double grin = 0;
   int order_total = OrdersTotal();
   for (int y = 0; y < order_total; y++)
      if (OrderSelect(y, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) grin = grin + OrderProfit() + OrderSwap() + OrderCommission();
   return (NormalizeDouble(grin, 2));
}
   
//--------------------------------------------------------------------
int order(int or)
{
   int a = 0;
   for (int r = OrdersTotal() - 1; r >= 0; r--) {
      if (OrderSelect(r, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
            if (or == OP_BUY       && OrderType() == or) a++;
            if (or == OP_SELL      && OrderType() == or) a++;
            if (or == OP_BUYSTOP   && OrderType() == or) a++;
            if (or == OP_SELLSTOP  && OrderType() == or) a++;
            if (or == -2)                                        a++;
         }
      }
   }
   return (a);
}
//--------------------------------------------------------------------
double LOT()
{
   if (Lot!=0) return(Lot);
   double MINLOT = MarketInfo(Symbol(),MODE_MINLOT);
   double LOT = AccountFreeMargin()*risk/100/MarketInfo(Symbol(),MODE_MARGINREQUIRED);
   if (LOT>MarketInfo(Symbol(),MODE_MAXLOT)) LOT = MarketInfo(Symbol(),MODE_MAXLOT);
   if (LOT= 0; i--)
     {
       string label = ObjectName(i);
       if(StringSubstr(label, 0, 5) != "_rdb_BuySell_Signal_with_LotMM_v1")
           continue;
       ObjectDelete(label);   
     }   */
//------------

Recommend