Having a Buy and a Sell position simultaniously on the same Symbol (Hedging)

 

Hello, im kind of new at this, im developing a simple strategy of hedging, i encountered a problem when i tried to buy when i have a open position of a sell, the system closes my sell position, i starting to read about it and find out that the problem is MT5, is it true?, i mean, how is it posible that it works in MT4 and doesnt work in MT5, i'll be forced to go backwards and run my code in MT4, its very sad.

 

Glad to hear your comments.

 Regards. 

 
Be ware of FIFO... I think you can still hedge but you would have to use pending orders...
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

Why would you want to hold Buy and Sell position simultaneously for the same pair? To lose on swaps?
 
ssn:
Be ware of FIFO... I think you can still hedge but you would have to use pending orders...

you might consider the real definition of what is a position, what is an order; that means hedging (MT4 spirit) is over. Some solutions can be tried with virtual orders
 
enivid:

Why would you want to hold Buy and Sell position simultaneously for the same pair? To lose on swaps?
is just a strategy i use, sometimes my algoritm puts a buy and a sell, the wrong one hits the stop loss and the other one keep the profits running, i only uses it when there is high volatility and some other conditions.
 
aleloa:
is just a strategy i use, sometimes my algoritm puts a buy and a sell, the wrong one hits the stop loss and the other one keep the profits running, i only uses it when there is high volatility and some other conditions.
Just code it so that when both buy and sell are generated, one of them closes other. Instead of a stop-loss, you set up a pending order that would reopen the desired position. The trading result will be the same (except for the elimination of the possible loss in swaps).
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 
enivid:
Just code it so that when both buy and sell are generated, one of them closes other. Instead of a stop-loss, you set up a pending order that would reopen the desired position. The trading result will be the same (except for the elimination of the possible loss in swaps).

its true, much more coding, but theres no room for laziness in this bussiness. thanks enivid.

 

 

Reason: