Opening several positions at a time on one symbol?

 

Dear all,

From MQL5 documentation about position properties, I can read this: For each financial security(symbol), only one open position is possible.


I have written the following code :

int OnInit()
  {

   CTrade trade;
   MqlTick tickInfo;
   MqlTradeResult result;
   
   SymbolInfoTick(_Symbol, tickInfo);
   
   trade.PositionOpen(_Symbol, ORDER_TYPE_SELL, 1.0, tickInfo.bid, tickInfo.bid + 0.001, tickInfo.bid - 0.1);
   trade.Result(result);
   PositionSelectByTicket(result.order);
   printf("Position ticket = %d",PositionGetInteger(POSITION_TICKET));
   
   trade.PositionOpen(_Symbol, ORDER_TYPE_SELL, 1.0, tickInfo.bid, tickInfo.bid + 0.002, tickInfo.bid - 0.2);
   trade.Result(result);
   PositionSelectByTicket(result.order);
   printf("Position ticket = %d",PositionGetInteger(POSITION_TICKET));

   return(INIT_SUCCEEDED);
  }


and I get the following results :

2019.01.09 00:00:00   instant sell 1 EURUSD at 1.14406 sl: 1.14506 tp: 1.04406 (1.14406 / 1.14410)
2019.01.09 00:00:00   deal #2 sell 1 EURUSD at 1.14406 done (based on order #2)
2019.01.09 00:00:00   deal performed [#2 sell 1 EURUSD at 1.14406]
2019.01.09 00:00:00   order performed sell 1 at 1.14406 [#2 sell 1 EURUSD at 1.14406]
2019.01.09 00:00:00   CTrade::OrderSend: instant sell 1.00 EURUSD at 1.14406 sl: 1.14506 tp: 1.04406 [done at 1.14406]
2019.01.09 00:00:00   Position ticket = 2
2019.01.09 00:00:00   instant sell 1 EURUSD at 1.14406 sl: 1.14606 tp: 0.94406 (1.14406 / 1.14410)
2019.01.09 00:00:00   deal #3 sell 1 EURUSD at 1.14406 done (based on order #3)
2019.01.09 00:00:00   deal performed [#3 sell 1 EURUSD at 1.14406]
2019.01.09 00:00:00   order performed sell 1 at 1.14406 [#3 sell 1 EURUSD at 1.14406]
2019.01.09 00:00:00   CTrade::OrderSend: instant sell 1.00 EURUSD at 1.14406 sl: 1.14606 tp: 0.94406 [done at 1.14406]
2019.01.09 00:00:00   Position ticket = 3


Does this mean that, there can be more than one position opened for one symbol (even though the documentation says the opposite)? Or is there antyhing I don't get?


Thank you very much.

 
zamy007 :


You should know that there are two types of MetaTrader 5 trading accounts: netting and hedge

Act Netting Hedge
BUY 1.0 BUY 1.0 BUY 1.0
SELL 1.0 sell 1.0 position will close buy 1.0 position -> Result: zero positions Result: two positions - buy 1.0 and sell 1.0
 

Many thanks for your answer. This explains that :)


It is sad it not mentioned in the position properties documentation section.


Is there any way to know in advance if an account is a neeting or hedging one? (Like without doing the little test I shared). I tried to look in MT5 options but couldn't find it.

 
zamy007:

Many thanks for your answer. This explains that :)


It is sad it not mentioned in the position properties documentation section.


Is there any way to know in advance if an account is a neeting or hedging one? (Like without doing the little test I shared). I tried to look in MT5 options but couldn't find it.

Basic Principles - Trading Operations

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 
Yes, that's what I read after your first answer. But I don't see how I can know if "Broker A" will give me in a Netting or Hedging System account.
 

It's also important to understand why this is. No matter what, if you ever use one strategy to open offsetting orders then your strategy is fundamentally flawed. I never understood people who did this because it is literally the same thing as opening a position and then instantly closing it. The broker loves it when you do that because you just gave them risk free money and then they get to **** you again if you hold it thru the swap time. It's downright foolish, and the reason the CFTC banned "hedging" for retail accounts was to protect immature traders from themselves. The only argument for having a hedging account is if you're running several different concurrent strategies and you're ok paying more swaps/commissions/spreads for the convenience of doing it from a single account. 

In summation, if the question is ever along the lines of, "how my EA open offsetting orders?" Then the answer is always, NO, STOPIT!

 
The OP is sending 2 orders in the same direction, there is no problem with that, but of course you need a netting account if you want it to result in 1 position. On a hedging account it will be 2 positions.
 
Thank you for these further explanations. So I guess I have to check with the broker itself what account system it proposes.
 
zamy007:

Many thanks for your answer. This explains that :)


It is sad it not mentioned in the position properties documentation section.


Is there any way to know in advance if an account is a neeting or hedging one? (Like without doing the little test I shared). I tried to look in MT5 options but couldn't find it.

I don't know whether you can use MQL5 to find this information programmatically. But you can see it in the MetaTrader window title bar: this often states your account number, broker name, account type and whether it is a hedging/netting account. Otherwise you would need to log in at your broker and check your account information there.
 
WindmillMQL:
I don't know whether you can use MQL5 to find this information programmatically. But you can see it in the MetaTrader window title bar: this often states your account number, broker name, account type and whether it is a hedging/netting account. Otherwise you would need to log in at your broker and check your account information there.
Thank you very much for the tip. Very helpful!
 
Alain Verleyen:
The OP is sending 2 orders in the same direction, there is no problem with that, but of course you need a netting account if you want it to result in 1 position. On a hedging account it will be 2 positions.

Oh... I didn't parse OP's code... Whoops. 


OP, you need to open a 2 lot position then set 2 separate 1 lot Stop orders and 2 separate 1 lot limit orders. It's the exact same strategy with better implantation because you won't risk the extra slippage waiting for the first market order to confirm. The original way only benefits if you need to send in the TP and SL on a pending order.  

Reason: