Download MetaTrader 5

hedging negative order

To add comments, please log in or register
hadher ramadhan
295
hadher ramadhan  
when iv opened to many orders ,one of theme has a drawdown and i want to hedge it,,,,how to prevent repeating the opposite order more than  once??thanks
for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
     
      result=OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_SELL &&OrderSymbol()==Symbol() &&OrderMagicNumber()==MagicNumber&&Bid-OrderOpenPrice()>=30*MyPoint )  
        {
        
       result=OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,0,0,"",MagicNumber,0,Blue);   
          
        }
     }
whroeder1
15925
whroeder1  
  1. Why did you post in the Root / MT5 General section instead of the MQL4 section (bottom of the Root page?)
  2. Before opening the buy order, see if you already have one open. If you open multiple orders, you'll need to remember the original ticket and the hedged one in an array.
  3. Personally I wouldn't do it. Let the SL close the loosing order.
hadher ramadhan
295
hadher ramadhan  

1-Sorry for this mistake

2-Using tickets is a great idea but i must find a way to make a connection between the 2 tickets thanks

3- It is just an idea it may be succeed 

whroeder1
15925
whroeder1  
hadher ramadhan: 2-Using tickets is a great idea but i must find a way to make a connection between the 2 tickets thanks
You have the connection, when you find the loosing order not in the array, and open the hedge
hadher ramadhan
295
hadher ramadhan  
whroeder1:
You have the connection, when you find the loosing order not in the array, and open the hedge

thank you i found it 
To add comments, please log in or register