Slippage
Slippage, as a parameter in the order
Slippage is a conditional order parameter that determines the deviation from the price of the condition, for the worse for you.
Slippage only works for conditional orders! For other order types, slippage is not used. However, the program has a mode for "by market" orders, which is enabled by the "Convert by market to limit orders" setting (agent's settings), when placing such an order, slippage from the agent's Trading settings can be used.
Setting the slippage parameter
In trading settings, slippage is set for the entire agent. In percentages and in steps, both parameters are summed up before order formation and represent a single slippage parameter for a conditional order.
![](https://doc.tslab.pro/~gitbook/image?url=https%3A%2F%2F45805883-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MaCiHiFV0s-5gqtvIid-1703796690%252Fuploads%252Fym7QWQc1m39RrFVqCjkp%252Ftsl_agentSlippage.png%3Falt%3Dmedia%26token%3Dff1057ae-3600-4607-8b18-b2124c26b253&width=768&dpr=4&quality=100&sign=febccc2c&sv=1)
Slippage in trading settings has a lower priority than slippage, which is located directly in the block for entering and/or exiting a position (set in absolute values):
![](https://doc.tslab.pro/~gitbook/image?url=https%3A%2F%2F45805883-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MaCiHiFV0s-5gqtvIid-1703796690%252Fuploads%252F8HNoK1Ywxf286ZAoXJWD%252Ftsl_blockSlippage.png%3Falt%3Dmedia%26token%3Dfe6e8109-2715-4c0b-bee9-fd30409badb1&width=768&dpr=4&quality=100&sign=c328825&sv=1)
If there are 5 points in a certain entry block, and a slippage of 1% is set in the trading settings, then 5 points will be taken for orders of this signal, and 1% for the rest of the script
Slippage in the program tables
Currently, not implemented in the program, the columns themselves are present, but not filled.
Execution slippage
Under slippage, the user can understand not only the Parameter in a conditional order, but simply, the execution at prices different from the price of the order. You place an order to buy "By market" at the opening of the bar, at the current price of 100 (the price of the last transaction on the market, it is also the Opening of the bar), and the execution price from the exchange comes 105. This difference can be understood as slippage, not a parameter in the order, and slippage performance.
As part of the execution slippage, the execution price can be either worse than the order price or better.
If during the period between the triggering of the condition and placing the limit order, the price went sharply in our direction, the broker (or program) will execute the order at the best price, below is an example with a picture for a conditional order "Sell if lower". Positive "execution slippage" often occurs when the slippage parameter is set to 0 in a conditional order. The slippage set in the order works only in the direction of the order and in no way limits the execution price from above (for selling), from below (for buying).
Conditional order "Sell if below price 114510, with 0 slippage". That is, sell at a price of 115510 or higher as soon as the transaction price for the instrument (the current quote) touches the condition price.
Slippage in optimization
All previous settings, both in blocks for entering a position, and in blocks for exiting a position, and in trading settings, are not taken into account in any way when optimizing the script and work only when trading. When developing a script, testing and optimizing, use the "Commission" blocks in order to take into account possible "execution slippage", all commissions, all slippage parameters,
Example of working with slippage
Current price: 90
We place an order: "Buy 5 lots, if above 100, slippage 10"
When the current price reaches the level of 100, a limit order is placed (by the broker or by us, depending on whether the broker supports conditional orders): Buy at a price of 110
Thus:
if there is a total volume of 5 for sale between prices 0 and 110, there will be transactions in the order queue (in the order book). The average trade price is the order execution price.
if there are no 5 lots between prices 0 and 110 in the queue of orders for sale, then transactions will be completed at the existing volume and a limit order at the price of 110 will be placed on the balance, that is, the current price has become higher than 110
if there is no Wait for execution parameter in the trading settings, the order will be canceled for recalculation and will be partially executed.
if at the same time Auto open / Auto close is enabled in the trading settings, then the order on the market will go to the rest. The market order will be an integral part of the total portfolio order for this signal.
Last updated