Simpel_Bart

Liq level to Entry Calculator

Simpel_Bart Updated   
This script calculates long and short entry levels with leverage and liquidation levels of your choosing. Suppose you are trading XBTUSD and believe the bottom is in. You're looking for a long entry using 10x leverage that will only get liquidated if we hit new lows. You choose "5698.9" USD.


By changing the leverage to "10" and the long liquidation price to "5698.9", the script will calculate the price point for your long entry.


I hope this helps inform your trades.

-Sim
Release Notes:
//@version=3
study("Liq level to Entry Calculator")
//
plot(close, color = black, linewidth = 2, title = "Close")
leverage = input(10, title = "Leverage")
CalculateLongEntry = input(false, title = "Calculate Long Entry?")
CalculateShortEntry = input(false, title = "Calculate Short Entry?")
//Long Calculator
longliqlevel = input(0, title = "Long Liquidation Level")
denominator = leverage*((1/leverage) - (1/pow(leverage, 2)))
LongEntry = longliqlevel/denominator
plot(CalculateLongEntry?LongEntry:na, color = #247BA0, title = "Long Entry")
plotchar(barstate.islast and CalculateLongEntry?LongEntry:na, color = #247BA0, size=size.auto, location=location.absolute)
plot(CalculateLongEntry?longliqlevel:na, color = #D72946, title = "Long Liquidation Level at X Leverage")
//Short Calculator
shortliqlevel = input(0, title = "Short Liquidation Level")
denominator2 = leverage*((1/leverage) + (1/pow(leverage, 2)))
ShortEntry = shortliqlevel/denominator2
plotchar(barstate.islast and CalculateShortEntry?ShortEntry:na, color = #FC5B03, size=size.auto, location=location.absolute)
plot(CalculateShortEntry?ShortEntry:na, color = #FC5B03, title = "Short Entry")
plot(CalculateShortEntry?shortliqlevel:na, color = #07135B, title = "Short Liquidation Level at X Leverage")

plotshape(leverage==100 and barstate.islast and CalculateLongEntry?longliqlevel:na, style=shape.flag, color = red, location=location.absolute, text="100x")
plotshape(leverage==50 and barstate.islast and CalculateLongEntry?longliqlevel:na, style=shape.diamond, color = red, location=location.absolute, text="50x")
plotshape(leverage==25 and barstate.islast and CalculateLongEntry?longliqlevel:na, style=shape.circle, color = red, location=location.absolute, text="25x")
plotshape(leverage==10 and barstate.islast and CalculateLongEntry?longliqlevel:na, style=shape.xcross, color = red, location=location.absolute, text="10x")
plotshape(leverage==5 and barstate.islast and CalculateLongEntry?longliqlevel:na, style=shape.triangleup, color = red, location=location.absolute, text="5x")


plotshape(leverage==100 and barstate.islast and CalculateShortEntry?shortliqlevel:na, style=shape.flag, color = #07135B, location=location.absolute, text="100x")
plotshape(leverage==50 and barstate.islast and CalculateShortEntry?shortliqlevel:na, style=shape.diamond, color = #07135B, location=location.absolute, text="50x")
plotshape(leverage==25 and barstate.islast and CalculateShortEntry?shortliqlevel:na, style=shape.circle, color = #07135B, location=location.absolute, text="25x")
plotshape(leverage==10 and barstate.islast and CalculateShortEntry?shortliqlevel:na, style=shape.xcross, color = #07135B, location=location.absolute, text="10x")
plotshape(leverage==5 and barstate.islast and CalculateShortEntry?shortliqlevel:na, style=shape.triangleup, color = #07135B, location=location.absolute, text="5x")
Release Notes:
Added a feature; the option to choose separate long and short leverages.
Protected script
This script is published closed-source but you may use it freely. You can favorite it to use it on a chart. You cannot view or modify its source code.
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?