Close Message Syntax
📐 Basic Rules
- Use Key=Value to set up instructions. Multiple keys can be separated by commas (,).
- Spacing around keys, values, or between multiple keys is not important.
- Keys are case-insensitive - upper or lower case does not matter.
- The order of Key=Value pairs is not important. You can arrange them in any order.
- Each action requires mandatory keys to be considered valid.
- Optional keys can be included to provide additional settings or data.
- Keys that are not supported by the action will be ignored.
- Maximum message length is 512 characters.
🔑 Supported Keys
| Key | Values | Example | Description |
|---|---|---|---|
| action* | Close | action=Close | Close action |
| size | Volume, % Position | size=1; size=30% | Size to close |
| ticket | number | ticket=4974331881 | Ticket filter |
| type | Long, Short | type=Long; type=Short | Position type filter |
| symbol | text | symbol=GBPUSD | Position symbol filter |
| profit | param numbers | profit=100:500; profit=*:500; profit=100:* | Position profit filter |
Keys that marked with * are mandatory keys. Missing any of mandatory keys will make the message invalid
💡 Explanation
action
Use this key to define the trade action you want to perform. This is mandatory key.
For closing positions, use action=Close
size
Use this key to define the the close size of position.
You can specify the close size in two units:
- Fixed lot size
- Percentage of Position
Detailed as below:
1. Fixed lot size
Use a number without sign suffix to set fixed lot size.
Message:
action=Close, size=0.1
Result:
All open positions will be closed with a volume of 0.1 lots each.
2. Percentage of Position
Use a number with percent sign (%) suffix to use account percentage lot size.
Message:
action=Close, size=50%
Result:
All open positions will be closed at 50% of their position size.
ticket
Use this key to filter positions by ticket.
When ticket is used, don't use other filters as it has no meaning.
Message:
action=Close, ticket=4974331881
Result:
The position with ticket number = 4974331881 will be closed.
type
Use this key to filter positions by type.
Valid type values are as below:
- Long - Long positions
- Short - Short positions
Message:
action=Close, type=Long
Result:
All Long positions wil be closed.
symbol
Use this key to filter positions by symbol.
Our symbol-mapping feature helps you here in some cases. For more details, please read in Buy/Sell syntax
Message:
action=Close, symbol=EURUSD
Result:
All positions for the EURUSD symbol will be closed.
profit
Use this key to filter positions by profit. Specify the range as MinProfit:MaxProfit
Notes:
- Use * as the placeholder for MinProfit if you want no minimum limit. For example:
profit=*:500 - Use * as the placeholder for MaxProfit if you want no maximum limit. For example:
profit=100:*
Message:
action=Close, symbol=EURUSD, profit=10:100
Result:
All positions for the EURUSD symbol that have minimum profit is 10 and maximum profit is 100 will be closed.
🆗 Examples
Example #1
action=close, size=1, ticket=4974331881
Explanation
- Close 1 lot of positions
- Process on position ticket = 4974331881
Example #2
action=close, size=50%, type=long, profit=100:500
Explanation
- Close 50% of positions
- Process on all symbols with type is Long
- Position profit must be between 100 and 500
Example #3
action=close, size=100%, symbol=EURUSD, type=short, profit=30:*
Explanation
- Close 100% of positions
- Process on EURUSD symbol with type is Short
- Position profit must be more than 30