2 or more pending orders in netting account for same symbol

 
I'm having a problem back testing my EA which opens 2 (or more) pending buy limit orders for the same symbol in a netting account. The deals associated with the 2 orders have different DEAL_TICKET and DEAL_ORDER values, but the same DEAL_POSITION_ID value. As a result, when a Take Profit (or Stop Loss) is hit for 1 deal, BOTH DEALS ARE CLOSED, even though the other deal has not yet reached its TP (or SL).

I tried using 2 different magic numbers as well, but this didn't help. I am using CTrade's BuyLimit for the orders (see below).

//    m_trade.SetExpertMagicNumber(1111);    //  No difference
      m_trade.BuyLimit(1, 4690.50, _Symbol, 4666.50, 4698.50, ORDER_TIME_GTC);

//    m_trade.SetExpertMagicNumber(2222);    //  No difference
      m_trade.BuyLimit(1, 4682.50, _Symbol, 4666.50, 4690.50, ORDER_TIME_GTC); 

So in the above example for the S&P500, price started coming down and the first order was triggered, as was the second order. Price went back up to 4690.50 which triggered the 2nd order's TP, but also prematurely closed the first order. The same phenomenom occurs with Stop Loss.

Surely there must be a way around this? 

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Deal Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You need:

1. Read the reference documentation: Netting SystemHedging System.

2. Work on a hedge trading account.

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
Before you proceed to study the trade functions of the platform, you must have a clear understanding of the basic terms: order, deal and position...
 
Vladimir Karputov #:

You need:

1. Read the reference documentation: Netting SystemHedging System.

2. Work on a hedge trading account.

Thanks for your prompt reply, Vladimir. I will read up on those. In my research, I saw the thread https://www.mql5.com/en/forum/328698  and even downloaded your 'History Deals and Orders' script.

So what you are saying is that I can only do this on a hedging account, and no workaround possible? That's a pity because I trade futures with AMP Futures, and there is no hedging account, only netting. This is a huge limitation and very restricting. I'm both surprised and disappointed.

Deal magic numbers
Deal magic numbers
  • 2019.12.18
  • www.mql5.com
Hello, I'm testing some systems on MT5 and I found a strange thing about History Deals...
 
How could a netting account be so different to a hedging account?

I know the differences, but I cannot think of a concept where this is against you or your money management. In the end, the hedge account is the one giving you a "false" interpretation. If that can be called false.

Think of it, you can virtually turn an underlying netting account into a hedging account, when tracking your activities as they would be handled by the hedging account.

Am I wrong?
 
Dominik Egert #:
How could a netting account be so different to a hedging account?

I know the differences, but I cannot think of a concept where this is against you or your money management. In the end, the hedge account is the one giving you a "false" interpretation. If that can be called false.

Think of it, you can virtually turn an underlying netting account into a hedging account, when tracking your activities as they would be handled by the hedging account.

Am I wrong?

All the above notwithstanding, I still cannot execute my 2 orders successfully on the MT5 platform.

 
TomP3185 #:

All the above notwithstanding, I still cannot execute my 2 orders successfully on the MT5 platform.

 
Vladimir Karputov #:

Yes, I now understand the Stop Loss and Take Profit inheritance rules for netting systems.

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
Before you proceed to study the trade functions of the platform, you must have a clear understanding of the basic terms: order, deal and position...
Reason: