Preloader

Slippage

This article was written by @bunie

  1. Let’s talk about Slippage: Here you will see 2 equity curves. Both of these are from the exact same strategy, with the exact same settings, with only 1 difference… One of these equity curves (the prettier one) has no slippage applied. The other (the not so nice one with over 100% drawdown) does have some slippage applied… ouch! So… what is slippage and why do we need to add it when backtesting? The markets are volatile, when Tradingview triggers a trade during a moving market, three things come into play —
    1. It takes time for Tradingview to contact the exchange, and for the exchange to execute that order. In that time the price can move up or down, especially in times of high volatility.
    2. When you execute a market order you have to pay the spread between the buyers and sellers for immediate execution (For more info: https://www.ledger.com/academy/glossary/bid-ask-spread). This means you’re paying a little more than the price on tradingview, depending on the spread.
    3. Finally, liquidity (Info here: https://cointelegraph.com/explained/crypto-exchange-liquidity-and-why-it-matters-explained). The less liquidity there is in the market the faster it will move. And, the larger your order is, the more it will impact that movement. Some exchanges have lower liquidity than others.
    So what..? Well… all of this leads to your trade not executing at the price tradingview tells you. Your equity curve will look great on paper, but your account balance might not look so great when the bot goes live.ImageImageImageImage
  2. So…. uh… how do I calculate Slippage? It’s hard…. it’s ####ing hard!…
    1. As a starting point…. try the Slippage Calculator indicator by zuklesny set to 1 minute and try to find a roughly average slippage amount. This is just to start, and it’s impossible for this to be accurate, but at least you’ve accounted for some slippage and you’re not fooling yourself with those sexy curves.
    2. Start manually recording your trades by coin & exchange — what price did tradingview execute at? What price did the exchange execute at? What’s the difference?
    3. Record a lot of these… until you can build a picture of average slippage for a coin/exhange over time.
    Why are some of my examples green on that spreadsheet? Well… there’s positive slippage where you actually execute at a better price, and negative, where you execute at a less favourable price. Unless you have recorded a lot of trades to average over, stick to averaging the negatives (i.e. the worst case)
  3. Final note: If you can get a strategy working well with slippage, you are likely onto a winner. Provided you haven’t over-fitted, you’ve remembererd to also add comission and you’ve incubated it before putting it live to see how it performs.
Trusted Site