PineHookPineHook

Account Types & Magic Numbers

Understand hedging vs netting accounts, single vs multi-strategy magic number modes, and how to run multiple independent strategies on the same symbol with one license.

MT5 accounts run in one of three margin modes: hedging, netting, or exchange. Exchange (futures/stock-exchange) accounts behave like netting for our purposes (one net position per symbol) and are also locked to Single mode. Which one you have changes how positions work and directly affects how you set up multiple strategies.


Hedging vs Netting Accounts#

Hedging accounts let you hold multiple positions on the same symbol at the same time. You can have a buy and a sell open on EURUSD simultaneously, or two separate buy positions from two different strategies. Each position is tracked independently with its own entry price, stop loss, and magic number.

Netting accounts aggregate all orders on a symbol into a single net position. If you buy 0.1 lots and then buy another 0.1 lots, you end up with one position of 0.2 lots, not two separate ones. Sending a close signal on a netting account closes the net position proportionally.

Most retail forex brokers default to hedging accounts. Most futures and stock brokers use netting. The account type is set at the broker level and cannot be changed after account creation. Check your broker's account settings or documentation to confirm which type you have.


Magic Numbers: What They Are and Why They Matter#

Magic numbers are unique numeric identifiers stamped on every trade the EA opens. MetaTrader uses them to identify which EA or strategy opened which position. The EA only manages positions that carry its assigned magic number, leaving everything else untouched.

Without magic numbers, a close signal from one strategy could close positions opened by another. Magic numbers are what prevent that.


Single vs Multi-Strategy Mode#

PineHook supports two magic number modes. Magic Number Mode defaults to Single on every account. On a hedging account you can switch it to Multi-Strategy via the Magic Number Mode input in the EA settings dialog. On netting (and exchange) accounts the input is forced to Single at startup and cannot be changed to Multi-Strategy.

ModeWhen it appliesBehavior
Single (default)Netting accounts (locked) and hedging accounts unless you change it.Magic numbers are not taken into consideration. All commands apply to the open position on the targeted symbol.
Multi-StrategyHedging accounts only, when manually selected.Every open signal must include magic=N. Close and modify commands filter positions by the magic in the signal.

Netting and exchange accounts are locked to Single mode

If your account is a Netting or Exchange account, the EA detects this at startup and locks it to Single mode. You cannot switch to Multi-Strategy mode on a netting or exchange account.

Hedging accounts default to Single mode

Even on a hedging account, Single mode is the default. To use Multi-Strategy mode, open the EA inputs dialog in MetaTrader and set Magic Number Mode to Multi-Strategy. This cannot be changed from the dashboard.

Single Mode#

Magic numbers are not taken into consideration. All commands apply to the open position on the targeted symbol. closelong,EURUSD closes the EA's EURUSD longs regardless of what magic number they carry. Including magic=N in a signal has no effect in this mode.

Best for: A single strategy per license, or any netting account.

Multi-Strategy Mode#

Each open signal must include a magic number. A buy signal without magic=N is rejected before any trade is attempted. Close and modify commands filter positions by the magic in the signal. To target all positions on a symbol regardless of magic, pass magic=ALL (the wildcard). magic=0 targets only magic-0 manual trades, and negative values are rejected.

Bulk commands do not require a magic number and accept an optional symbol. When sent without a symbol, they act account-wide, regardless of magic number, symbol, or mode, including positions opened by other software (each still keeps its own scope: closeall closes every position, cancelall cancels every pending order, clearqueue clears every queued delayed signal):

closeall, closecancelall, closealleaoff, closecancelalleaoff, closeallprofit, closeallloss, cancelall, clearqueue

  • With a symbol (e.g. closeallprofit,EURUSD): applies to all positions on that symbol across all magic number strategies.
  • Without a symbol (e.g. closeallprofit): applies to every position on the account regardless of symbol or magic number, including positions opened by other software. Only use this when you intend to affect your entire account.

Best for: Running multiple independent strategies on a hedging account using the same license.

SymbolMagicMode
anyAcceptAccept
SingleAcceptAccept
MultiReject — magic requiredReject (magic required; kill switches exempt)
anyReject — symbol requiredAccept (Multi: that magic across all symbols; Single: default magic; ALL = every magic)
SingleReject — symbol requiredAccept (full kill switch)
MultiReject — symbol requiredAccept (full kill switch)

Hover the column headers to see which commands belong to each category and example signals for each case.


Running Multiple Strategies on the Same Symbol#

To run Strategy A and Strategy B both trading EURUSD on a hedging account, you do not need multiple licenses. One license handles it all.

The key is magic numbers. There is no place in PineHook to register "Strategy A uses magic 1001." You pick a number for each strategy, keep track of it yourself, and include it in every TradingView alert for that strategy.

Here's the full setup:

  1. Confirm your account is a hedging account at the broker level.
  2. Open the EA inputs dialog in MetaTrader and set Magic Number Mode to Multi-Strategy.
  3. Pick a unique magic number for each strategy. Any number works, just make sure they don't overlap. For example: Strategy A = 1001, Strategy B = 1002.
  4. In each TradingView alert, include the matching magic number:
Open Strategy A
LICENSE,buy,EURUSD,size_lots=0.1,magic=1001
Open Strategy B
LICENSE,buy,EURUSD,size_lots=0.1,magic=1002
  1. Close commands must also carry the matching magic number to target only that strategy's positions:
Close only Strategy A's EURUSD longs
LICENSE,closelong,EURUSD,magic=1001
Close only Strategy B's EURUSD longs
LICENSE,closelong,EURUSD,magic=1002

One license is enough

You do not need a separate license for each strategy. Multi-Strategy mode is built for this use case: multiple independent strategies on the same account, same symbol, same license.


Limitations on Netting and Exchange Accounts#

On a netting or exchange account, the EA is automatically locked to Single mode. Running multiple strategies on the same symbol is not supported because the broker merges all positions into one net position. There are no separate positions to distinguish by magic number.

If your broker only offers netting or exchange accounts and you want to run multiple independent strategies, the options are:

  • Assign each strategy to a different symbol (e.g., Strategy A on EURUSD, Strategy B on GBPUSD).
  • Use separate MT5 accounts, each with its own PineHook license.