Bitmex Liquidation Zones for TradingView

This script written for TradingView using Pinescript calculates the forced liquidation price for the volume weighted average price of a certain candle for leverages of 25x,50x and 100x

Code:

//@version=3
//Made by André Couto
study(“Liquidation Range Bands for XBT collateralized”, overlay=true)
src = vwap
//Longs
plot((src*100)/(0.995*100+1), style=circles, title=”L100″,color=yellow, linewidth=4)
plot((src*50)/(0.995*50+1), style=circles, title=”L50″, color=purple, linewidth=4)
plot((src*25)/(0.995*25+1), style=circles, title=”L25″, linewidth=4)
//Shorts
plot((-src*100)/(-1.005*100+1), style=circles, title=”S100″, color=yellow, linewidth=4)
plot((-src*50)/(-1.005*50+1), style=circles, title=”S50″,color=purple, linewidth=4)
plot((-src*25)/(-1.005*25+1), style=circles, title=”S25″, linewidth=4)

Colors, thickness and shape can be changed via the Indicator Style Menu