08. Usage examples
Rejecting orders
Case 1
Rejecting a certain type of orders for a group on a day of the week.
Rule:
- NameBTCFridayReject
- Actions
- Action typeReject
- Filter
- Request typesMarket, Limit activation, Stop activation, Pending open
- DirectionsBuy
- Filter group 1
- NameGroup1BTC
- Conditions
- Accounts
=Group1 - Symbols
=BTC* - Days
=Friday
With this rule, placing a BTC* BUY order on Fridays will be impossible for the Group1 MetaTrader group.
Case 2
Rejecting placing pending orders at the specific hours of day.
Rule:
- NameMiddayReject
- Actions
- Action typeReject
- Filter
- Request typesPending open
- Filter group 1
- NameMidday
- Conditions
- Accounts
=* - Times
≥12:00 - Times
≤13:00
Placing pending orders will be prohibited from 12:00 to 13:00.
Case 3
Rejecting trading activity around the server’s End Of Day timestamp.
Rule:
- NameEODReject
- Actions
- Action typeReject
- Filter
- Request typesMarket, Instant, Pending activation
- Entry type
*
- Filter group 1
- NameEODIn
- Conditions
- Accounts
=* - Times
≥23:30
- Filter group 2
- NameEODOut
- Conditions
- Accounts
=* - Times
≤00:30
Trading will be disabled between 23:30 and 00:30.
Case 4
Preventing scalping trading
Rule:
- NameAnti-scalping
- Actions
- Action typeReject
- Filter
- Request typesMarket
- Entry typeOut
- Filter group 1
- NameScalpers
- Conditions
- Accounts
=Scalpers-* - Duration
<60 - Profit
<2
This rule prevents closing trades almost right after the opening which at the same time have low profit. Executing scalping strategies with a bit-by-bit profiting becomes impossible.
Case 5
Preventing opening too many positions on a particular symbol
Rule:
- NameNotMoreThanTen
- Actions
- Action typeReject
- Filter
- Request typesMarket
- Entry typeIn
- Filter group 1
- Name10pos
- Conditions
- Accounts
=* - Symbols
=EURUSD - Positions limit
≥10
This rule prevents opening more than 10 positions on the EURUSD symbol.
Applying a custom slippage
Case 1
Partial slippage compensation
Rule:
- NameSlippageVIPCompensation
- Actions
- Action typeCurrent price
- Slippages
- Negative action1
- Filter group 1
- NameVIP
- Conditions
- Accounts
=VIP-*
Negative slippage will be compensated by 1 point for the VIP traders MetaTrader group.
Case 2
Adding a custom slippage
Rule:
- NameAddSlippageToZero
- Actions
- Action typeCurrent price
- Slippages
- Zero action
= -5 -2 50%
A random custom negative slippage (from 2 to 5) will be added in 50% of cases for all the orders having a 0 natural slippage.
Delaying requests
Case 1
Delaying requests by 0.5-2 seconds during a high volatility period of EURUSD and opening trades at a worst price for traders:
Rule:
- NameEURUSDDelay
- Actions
- Action typeWorst Price
- Delay500-2000
- Filter
- TimeFrom: 2020.02.03 00:00:00; To: 2020.02.07 00:00:00
- Request typesMarket
- Filter group 1
- NameEURUSDall
- Conditions
- Accounts
=* - Symbols
=EURUSD
Such a rule can be useful during high volatility periods of an instrument. According to the rule, all the EURUSD trades will be delayed by 2 seconds, and the worst price among the ticks that came in these 2 seconds will be picked. The rule is applied only for opening and closing a Market order.
Checking exposure before confirmation
Case 1
Preventing opening too much exposure on a particular security on a particular account.
Rule:
- NameNotMoreThanTenThousand
- Actions
- Action typeReject
- Filter
- Request typesMarket
- Entry typeIn
- Filter group 1
- Name10kusdcrypto
- Conditions
- Accounts
=* - Symbols
=Crypto\* - Exposure limit
≥Crypto\*; 10000; USD; Total; Include
This rule prevents opening crypto securities (on any account), if current exposure on them (including that of the requested order) is more than $10000 worth. Can be modified into:
Exposure limit
≥ *USD*; 10000; USD; Total; Includeto reject all crypto requests, if only USD-based crypto symbols exceed the allowed exposure (not taking into account, e.g., *EUR* crypto symbols). Or into:
Exposure limit
≥ *; 10000; USD; Total; Include; PerSymbolto reject a crypto request, if the exposure on the requested symbol alone will exceed $10000, given the request is approved.
Case 1a
Using filter groups
The above mentioned subcases (slightly modified) can be placed into three separate filter groups in terms of one Reject rule to precisely control the allowed exposure on cryptos:
- Filter group 1
- Name5kusd_1crypto
- Conditions
- Accounts
=* - Symbols
=Crypto\* - Exposure limit
≥*; 5000; USD; Hedged; Include; PerSymbol
- Filter group 2
- Name7kusd_allusdcrypto
- Conditions
- Accounts
=* - Symbols
=Crypto\* - Exposure limit
≥*USD*; 7000; USD; Total; Include
- Filter group 3
- Name10kusd_allusdcrypto
- Conditions
- Accounts
=* - Symbols
=Crypto\* - Exposure limit
≥Crypto\*; 10000; USD; Total; Include
So, if the request is:
- Not increasing its crypto symbol exposure beyond $5000 level, and at the same time,
- Not increasing USD-based crypto exposure beyond $7000 level, and at the same time,
- Not increasing total crypto exposure by $10000 level,
it will not pass the rule’s filter tiers, and, according to our settings, it will get confirmed by the Default rule.
In these examples, exposure is checked per account issuing a request. Let’s see how Dealing Desk can check the total exposure on multiple accounts altogether.
Case 2
Preventing opening too much exposure on a particular symbol in a particular account scope.
Rule:
- NameEURUSD Server limit
- Actions
- Action typeReject
- Filter
- Request typesMarket
- Entry typeIn
- Filter group 1
- Name10musdbtc
- Conditions
- Accounts
=USA* - Symbols
=BTCUSD - Exposure limit
≥*; 1000000; USD; Total; Include; PerSymbol; AccountMask; USA*
This rule prevents opening a BTCUSD order, if it will make the BTCUSD exposure of all USA-groups altogether go beyond the $1,000,000 mark.
Case 2a
With a coverage account
The example above calculates total exposure of all groups in the scope per BTCUSD request. Imagine that the account scope is not just a bunch of groups, but the entire server:
Symbols = BTCUSD; Accounts = *; Exposure limit >= *; 1000000; USD; Total; Include; PerSymbol; AccountMask; *Although Dealing Desk will calculate the exposure quite quickly, it will still do that per request, which has a risk of overloading the MT server, when requests are being sent frequently.
In this case, to drastically lower the possible load, it would be great to have a coverage account, which already has all BTCUSD trades of other accounts copied on it:
- Account #101: Buy 1 BTCUSD, Buy 3 EURUSD
- Account #102: Sell 2 BTCUSD, Buy 1 EURUSD
- Account #103: Sell 1 EURGBP, Sell 3 BTCUSD
- Coverage account: Account #100: Sell 4 BTCUSD (total BTCUSD of #101, #102, #103)
And the modified filters of the rule:
- Conditions
- Symbols
=BTCUSD - Accounts
=!100,* - Exposure limit
≥*; 1000000; USD; Total; Include; PerSymbol; AccountMask; 100
Now, while ending up with the same calculation results, Dealing Desk does this way faster, because it checks exposure of just one account #100 instead of checking the other three. This scheme can be scaled up to the entire server, saving lots of processing time for the plugin.
So, if you are planning to use Exposure limit for a similar case, you might want to pair it with a coverage account.
Limiting SL/TP levels of positions and pending orders
Case 1
- NameNoHighSLTP
- Actions
- Action typeReject
- Filter
- Request types
* - Entry type
*
- Filter group 1
- NameSLTP
- Conditions
- Accounts
=* - Stop deviation
≥sl:30%;tp:40%
Given the current price is 1.500, it will be possible to to set SL not higher than at the
1.500 + (-) 1.500*0.3 = 1950 (1050) levels, and TP - at the 2100 (900) levels.