EA problem

 

summary of EA:


1) always start with BUY order (with SL and TS)

2) if first order close with TP is ok becouse I won, else start with SELL order (with SL and TP)

3) if second order close with TP is ok becouse I won, else start with thirth BUY order (with SL and TP).


Following there is a draft of EA, but i don't know how continue.

I hope for someone more experienced, thanks



int start()
  {
//----
   int total = OrdersTotal();

   double SL1 = 0.0100;
   double TS1 = 0.0030;
   int ticket;
   int ticket2; 




   if (total < 1 && OrderProfit()>=0)
      {
        ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-SL1,0,"UNO",1111,0,Blue); 
        return (0);
      }

  
  

// check for trailing stop  
   int i;
   for(i=0;i<total;i++)
     {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_BUY && OrdersTotal()==1)   
       {
        if(TS1>0)  
         {                 
          if(Bid-OrderOpenPrice()>TS1)
           {
            if(OrderStopLoss()<Bid-TS1)
             {
              OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TS1,OrderTakeProfit(),0,Blue);
              return(0);
             }
           }
         }
       }
     }




   // check second order
      if (OrderProfit()<0  && total<1)
        {
         ticket2=OrderSend(Symbol(),OP_SELL,0.02,Bid,3,Ask+SL1,Ask-TS1,"DUE",2222,0,Red);  
        return(0);
        }
  


//----
   return(0);
  }



//----
return(0);
}

 
ro66er:

summary of EA:


1) always start with BUY order (with SL and TS)

2) if first order close with TP is ok becouse I won, else start with SELL order (with SL and TP)

3) if second order close with TP is ok becouse I won, else start with thirth BUY order (with SL and TP).


   int total = OrdersTotal();
   if (total < 1 && OrderProfit()>=0)
      {
        ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-SL1,0,"UNO",1111,0,Blue); 
        return (0);
      }

if total is less than one then OrderProfit() is meaningless. It also meaningless since you never do a OrderSelect()

Also your loop must select the last closed order or the last 2 orders, and there can be no open orders.

 
thanks for the help but I have no idea to continue
 
I have done alone, hippyyyy
 

Hi

I was wondering if you could possibely change this EA to trade more than one pair since when you attach to another pair it can not to trade.

Kaveh

Files:
hilobar_2.mq4  3 kb
Reason: