Navigation:Home > Content >

Mark1.mq4

Time: 2016-06-15 | Download file:Mark1.mq4

extern int    filtr     =100;
extern double gamma     =0.02;
extern double lots    =0.1;
extern int tpf         =45;
extern int sls         =15;

double        demoks1,demoks2,status,lot;
int i,count=0,tp;

int start()
  {
   double
   Min_Lot;
   bool
   ans=true;

// условия открытия

demoks1=iCustom(NULL,0,"DemOK's",filtr,20,gamma,0,0);
demoks2=iCustom(NULL,0,"DemOK's",filtr,20,gamma,0,1);

if (demoks1>demoks2) status=1;
if (demoks1demoks1+2*filtr*Point)
        {
         if (count<3) 
         {
          if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY)==true)
          {
          if(OrderType()==OP_BUY)
         {if(OrderTakeProfit()>0 && OrderTakeProfit()<=OrderClosePrice())  
            {
             if (count==1 || count==2) lot/=2;
             if (count==1) tp=1;
            }     
            if(OrderStopLoss()>0 && OrderStopLoss()>=OrderClosePrice())
            {if (count==2 && tp==1) {lot*=2;tp=0;}}
           }
     
            if(OrderType()==OP_SELL)
            {if(OrderTakeProfit()>0 && OrderTakeProfit()>=OrderClosePrice())  
            {
             if (count==1 || count==2) lot/=2;
             if (count==1) tp=1;
            }     
            if(OrderStopLoss()>0 && OrderStopLoss()<=OrderClosePrice())
            {if (count==2 && tp==1) {lot*=2;tp=0;}}
            }
            }
         }
         RefreshRates();
         OrderSend(Symbol(),OP_BUY,NormalizeDouble(lot,2),Ask,10,Ask-sls*Point,Ask+tpf*Point);
         count++;
         if (count==3) count=0;
        }   

        if (status==-1 && i==0 && Bid0 && OrderTakeProfit()<=OrderClosePrice())  
            {
             if (count==1 || count==2) lot/=2;
             if (count==1) tp=1;
            }     
            if(OrderStopLoss()>0 && OrderStopLoss()>=OrderClosePrice())
            {if (count==2 && tp==1) {lot*=2;tp=0;}}
           }
     
            if(OrderType()==OP_SELL)
            {if(OrderTakeProfit()>0 && OrderTakeProfit()>=OrderClosePrice())  
            {
             if (count==1 || count==2) lot/=2;
             if (count==1) tp=1;
            }     
            if(OrderStopLoss()>0 && OrderStopLoss()<=OrderClosePrice())
            {if (count==2 && tp==1) {lot*=2;tp=0;}}
            }
            }
         }
         RefreshRates();
         OrderSend(Symbol(),OP_SELL,NormalizeDouble(lot,2),Bid,10,Bid+sls*Point,Bid-tpf*Point);
         count++;
         if (count==3) count=0;
        }
     return;
  }


int CountOpenOrders()
{
   int l_count_4 = 0;
   int l_ord_total_12 = OrdersTotal();
   for (int l_pos_8 = 0; l_pos_8 < l_ord_total_12; l_pos_8++) {
      OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
      if ((OrderType() == OP_BUY)||(OrderType() == OP_SELL)) l_count_4++;
   }
   return (l_count_4);
}

int GetTypeLastPos(string sy="", int op=-1, int mn=-1) {
  datetime o;
  int      i, k=OrdersTotal(), r=-1;
 
  if (sy=="0") sy=Symbol();
  for (i=0; i=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          OrderClose(OrderTicket(),OrderLots(),Bid,5,Blue);
        }
      }
    }
  }
}


Recommend