how to package trade?

 

hi i have an strategy that when it gets a signal it should open 5 buys with different sls and tps but it should wait until all of them being closed by hiting sl and tp and then open another 5 buy .


as i said i should wait until  trade package close then open another 5 trade package 

what should i do 

here is a sample of my code

void OnTick()

  {

  

   if(Volume[0]<=1   &&  OrdersTotal()==0 )

   {

   

      if(CandleStatus()=="Buy")

      int tiketbuy=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(stoploss1*Point),Ask+(takeprofit*Point),"Rise Group",1111,0,clrGreen);

      int tiketbuy1=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(stoploss2*Point),Ask+(takeprofit2*Point),"Rise Group",2222,0,clrGreen);

    //  int tiketbuy2=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(stoploss3*Point),Ask+(takeprofit3*Point),"Rise Group",3333,0,clrGreen);

    //  int tiketbuy3=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(stoploss4*Point),Ask+(takeprofit4*Point),"Rise Group",4444,0,clrGreen);

    //  int tiketbuy4=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(stoploss*Point),Ask+(takeprofit5*Point),"Rise Group",5555,0,clrGreen);
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


 
Mohammad Velayati: it should wait … what should i do
  1. Use the code button.
  2. Code it to do what you want. Show us your attempt (using the CODE button) and state the nature of your problem. There are no mind readers here and our crystal balls are cracked.

  3.    if(Volume[0]<=1   &&  OrdersTotal()==0 )
    
    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 and MetaTrader 4 - MQL4 programming forum.) Always use time.
    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              New candle - MQL4 and MetaTrader 4 - MQL4 programming forum

  4. Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

  5.       if(CandleStatus()=="Buy")
    
          int tiketbuy=OrderSend(…);
    
          int tiketbuy1=OrderSend(…);
    
    Your if statement only applies to the first OrderSend, The other's are always done. Is that what you intended?