Multi-Strategy
comment=
in v3
If you are on v3, comments no longer need to be enclosed in quotation marks.Example:
- v2 Syntax:
LicenseID,buy,EURUSD,risk=1,comment="strategy 1"
- v3 Syntax:
LicenseID,buy,EURUSD,risk=1,comment=strategy 1
Starting from PineConnector MT4 EA v2.143 and MT5 EA v2.095, you can now trade multiple strategies on a single license using the enhanced "close" and "cancel" commands that closes positions with the same comment.
Available Commands:
- closelong (closes buy positions)
- closeshort (closes sell positions)
- cancellong (closes buystop and buylimit orders)
- cancelshort (closes sellstop and selllimit orders)
Please note that support for other close commands such as “closelongpct” and “closelongvol” will be added in the future.
Now you can trade two or more timeframes/strategies simultaneously for the same instrument using just one license.
Implementation
To execute multiple strategies, you need to include a comment in your signals.
Entries
To enter the market, you may use either of the 6 entry commands:
- buy
- sell
- buylimit
- selllimit
- buystop
- sellstop
Let's assume you want to run 2 strategies. For Strategy 1 signals, include the comment "strategy 1", and for Strategy 2 signals, include the comment "strategy 2".
LicenseID,buy,EURUSD,risk=1,comment=strategy 1
LicenseID,buy,EURUSD,risk=1,comment=strategy 2
For example, you can indicate the strategy name or timeframe you are trading such as "SuperTrend Strategy" or "15 minutes".
Closing
To close positions for a specific strategy, the close command must be accompanied by the same comment.
List of closing commands presently supported:
- closelong (closes buy positions)
- closeshort (closes sell positions)
- cancellong (cancels buystop and buylimit orders)
- cancelshort (cancels selllstop and selllimit orders)
Using our example, to close positions for Strategy 1:
LicenseID,closelong,EURUSD,comment=strategy 1
With the above command:
- All buy trades for EURUSD with the comment "strategy 1" will be closed.
- Sell trades for EURUSD with the same comment will not be closed.
- Buy positions for EURUSD without any comment or with different comments will not be closed.
Similarly, to close positions on Strategy 2:
LicenseID,closelong,EURUSD,comment=strategy 2
Close on Reverse
Instead of closing positions of a strategy using the “closelong” or “closeshort” commands, you may close your positions with the Close On Reverse EA feature. For example, there are 2 buy EURUSD positions with the following syntax:
LicenseID,buy,EURUSD,risk=1,comment=strategy 1
LicenseID,buy,EURUSD,risk=1,comment=strategy 2
Once both positions are open, you may close one of them with:
LicenseID,sell,EURUSD,risk=1,comment="strategy 1"
The buy position with “strategy 1” comment will close and a sell position will open. The other buy position with “strategy 2” comment will left untouched.
Important Note
Blanket Behavior — Entries Without Comments
Sending a "closelong" command without a comment will close positions with or without comments.
For example, you have the following open:
- buy EURUSD without a comment
- buy EURUSD with “strategy 1” commented
- buy EURUSD with “strategy 2” commented
Sending an EURUSD “closelong” will close all 3 positions above.
Innovation Exchange: Ideas, Feedback, and Beyond
If there are ways we can improve the implementation of the multi-strategy feature (or any other feature or aspect), please let us know!