Enter Multiple trades and Trailing stop to start at profit

 
I have a few queries, I have different trades of each day and time of the week and I use breakeven. The problem arises when there's lets say a buy trade that is still running and I need to get into another buy trade. My question is can I be able to enter into another buy trade while this one is still running. Below is my Buy trade function. I also want to know can the trailing stop start trailing from profit and not begin below the order open price or make the breakeven trail the price? Below are both my functions. Thank you all in advance.
//+------------------------------------------------------------------+
//|                   BUY ORDERS                                     |
//+------------------------------------------------------------------+
void BuyTrades( string symbol, double volume, int MagicNumber){
   int BuyCount= 0;
   int Count= OrdersTotal();
   for(int i=Count -1; i>=0;i--){
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
       if(OrderSymbol()==symbol && OrderMagicNumber()==MagicNumber){
         if(OrderType()==OP_BUY) BuyCount++;
         }
       }
     }
    if(BuyCount==0){
       if(OrderSend(symbol,OP_BUY,volume,Ask,0,0,0,NULL,MagicNumber)) {}
       }
}

//+------------------------------------------------------------------+
//|                       TRAILING STOP                              |
//+------------------------------------------------------------------+
void AdjustTrail(){
//buy order section   
   for(int b=OrdersTotal()-1;b>=0;b--)
     {
     if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==Symbol())
       if(OrderType()==OP_BUY)
        {
        if(OrderStopLoss()<Ask-(340*Point))
         OrderModify(OrderTicket(),OrderOpenPrice(),Ask-111*Point,OrderTakeProfit(),0);
        }
     }
//sell order section
   for(int s=OrdersTotal()-1;s>=0;s--)
     {
     if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==Symbol())
       if(OrderType()==OP_SELL)
       {
       if(OrderStopLoss()==0 || OrderStopLoss()>Bid+(340*Point))
         OrderModify(OrderTicket(),OrderOpenPrice(),Bid+111*Point,OrderTakeProfit(),0);
       }
     }
  }

//+------------------------------------------------------------------+
//|                          BREAK-EVEN                              |
//+------------------------------------------------------------------+
void BreakEven(){
//buy order section   
   for(int b=OrdersTotal()-1;b>=0;b--)
     {
     if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==Symbol())
       if(OrderType()==OP_BUY)
        {
        if(OrderStopLoss()<OrderOpenPrice())
        if(Ask>OrderOpenPrice()+(200*Point))
         OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+100*Point,OrderTakeProfit(),0);
        }
     }
//sell order section
   for(int s=OrdersTotal()-1;s>=0;s--)
     {
     if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==Symbol())
       if(OrderType()==OP_SELL)
       {
       if(OrderStopLoss()==0 || OrderStopLoss()>OrderOpenPrice() || Bid< OrderOpenPrice()-(200*Point))
         OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-100*Point,OrderTakeProfit(),0);
       }
     }
  }
 
Jones John: can I be able to enter into another buy trade while this one is still running.
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Yes, except that you prevent it.

        if(BuyCount==0){
  3. Jones John I also want to know can the trailing stop start trailing from profit and not begin below the order open price or make the breakeven trail the price?
    Of course, it can; code it to do what you want. Define"profit" each individual or all open orders combined: Lots Weighted Average Price = ∑  op(i) × lot(i) ÷ ∑ lot(i). This is the break even price of all orders combined.


              OrderOpenPrice question . - MQL4 programming forum
              looking for sample code on how to calculate the price BE for a few Buy and Sell orders simultaneously - Pips - MQL4 programming forum

 

William Roeder #:

  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Yes, except that you prevent it.

  3. Of course, it can; code it to do what you want. Define"profit" each individual or all open orders combined: Lots Weighted Average Price = ∑  op(i) × lot(i) ÷ ∑ lot(i). This is the break even price of all orders combined.


              OrderOpenPrice question . - MQL4 programming forum
              looking for sample code on how to calculate the price BE for a few Buy and Sell orders simultaneously - Pips - MQL4 programming forum


Hello William Thank you for your reply. 
1. Noted will make sure not to make the same mistake
2. On the Buycount==0 when I increase the number to let's say 1 the EA executes 2 buy trades at the same time.

Reason: