Discussion of article "MetaTrader 5 features hedging position accounting system" - page 7

 
rosomah:

I wanted to open a new demo account on MQL5 terminal. (I already have a netting demo account) When opening an account, the button "Use hedging in trading" is not activated.

Question: Can I have both hedge and netting forex accounts on the same terminal? Or should I reinstall the terminal?

There is a dependence on which trading server you log in to. Connect to MetaQuotes-Demo
 
Vladimir Karputov:
There is a dependence on which trade server you log in to. Connect to MetaQuotes-Demo.
It worked on MetaQuotes-Demo. Thank you.
 
Help who knows, can't find the information on my own. The broker has hedging accounts. My robot is written for non-hedging accounts. How can I close a position on a hedging account using MQL5? There is no OrderClose() function in MQL5. The opposite position, as in a netting account, does not close the open position.
 
Sergiy Riehl:
Help who knows, can't find the information on my own. The broker has hedging accounts. My robot is written for non-hedging accounts. How can I close a position on a hedging account using MQL5? There is no OrderClose() function in MQL5. The opposite position, as in a netting account, does not close the open position.

Maybe TRADE_ACTION_CLOSE_BY should be set in the trade request on a hedging account ?

or is there a more correct solution?

 
Sergiy Riehl:
Help who knows, can't find the information on my own. The broker has hedging accounts. My robot is written for non-hedging accounts. How can I close a position on a hedging account using MQL5? There is no OrderClose() function in MQL5. The opposite position, as in a netting account, does not close the open position.

Use the universal code for position traversal - it works on both netting and hedge accounts. Example in the GalacticExplosion code - CloseAllPositions function

//+------------------------------------------------------------------+
//| Close all positions|
//+------------------------------------------------------------------+
void CloseAllPositions()
  {
   for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of current positions
      if(m_position.SelectByIndex(i))     // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
            m_trade.PositionClose(m_position.Ticket()); // close a position by the specified symbol
  }
 
Carl Schreiber:

What about the commission?

If I have two open positions, one buy, one sell, and close the 'sell' by the 'buy' I have paid twice the commission. But I would have paid only once the commission if I just close the buy, isn't it?

But what if a broker isn't asking for a commission but has increased the spread? Don't I pay the spread twice as well?

What about Carl's concern about paying the commission twice? Any answers from MetaQuotes, any experiences, please?