Migrating MT4 EA to MT5 - Multiple Magic Numbers on one EA - page 2

 
Marco vd Heijden:

Well it depends on the account type but in your case you would fire an opposing order of the matching or equal volume, to cancel out the position.

So you are either long or short but not at the same time, if you want that you have to use a Hedging account.

I think that's what's causing me the confusion.  Is it an absolute that you can only ever have one position per symbol (as it suggests in the documentation), or is this dependant on the account type with my broker?  I'm not interested in hedging functionality, it's more knowing whether I could have more than one position open on a symbol.

 

Yes that is called a Hedging type account.

ENUM_ACCOUNT_MARGIN_MODE

Identifier

Description

ACCOUNT_MARGIN_MODE_RETAIL_NETTING

Used for the OTC markets to interpret positions in the "netting" mode (only one position can exist for one symbol). The margin is calculated based on the symbol type (SYMBOL_TRADE_CALC_MODE).

ACCOUNT_MARGIN_MODE_EXCHANGE

Used for the exchange markets. Margin is calculated based on the discounts specified in symbol settings. Discounts are set by the broker, but not less than the values set by the exchange.

ACCOUNT_MARGIN_MODE_RETAIL_HEDGING

Used for the exchange markets where individual positions are possible (hedging, multiple positions can exist for one symbol). The margin is calculated based on the symbol type (SYMBOL_TRADE_CALC_MODE) taking into account the hedged margin (SYMBOL_MARGIN_HEDGED).


https://www.mql5.com/en/docs/constants/environment_state/accountinformation

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
There are several types of accounts that can be opened on a trade server. The type of account on which an MQL5 program is running can be found out using the ENUM_ACCOUNT_TRADE_MODE enumeration. In case equity is not enough for maintaining open positions, the Stop Out situation, i.e. forced closing occurs. The minimum margin level at which Stop...
 

Thanks for clarifying, I'm still getting my head around all the info for MQL5 and the documentation on positions didn't give any suggestion of this.

Position Properties

Execution of trade operations results in the opening of a position, changing of its volume and/or direction, or its disappearance. Trade operations are conducted based on orders, sent by the OrderSend() function in the form of trade requests. For each financial security (symbol) only one open position is possible. A position has a set of properties available for reading by the PositionGet...() functions.

 

@SteMcG1984 I appreciate you asked this 18 months back, but I was working on something similar this week so I thought I would make a suggestion.

"- Is it possible for an MT5 position to have multiple magic numbers?  Then do partial close for all parts with a specific MN."

I found that by multiplying the ulong magic no, you can free up digits on the RHS which can be used to store additional info, for example a unique ID.

So you could have something like this:

<magicID> x 100 yields:  <magicID><2 digit groupID> which allows 100 unique groups with a common magic No-  <magicID><00>,  <magicID><01>, ... <magicID><99>

The ulong field can support 19 digits so you can easily made the right hand section longer if needed.

Hope that helps

Reason: