Close Syntax
Create an alert message with instructions to close positions.
๐ 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 |
Notes:
- 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.
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.
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.
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
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
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:*
๐ 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