I am trying to generate a formula that uses the following variables:
- a = account balance
- e = position entry point
- L = leverage used
- p = percentage of loss (in % format, not decimal)
- x = stop loss price
this formula is trying to solve for x
a couple attempts generated this formula: $$x = {ap\over 100}\times {e \over aL} + e$$
but it came to be that acccount balance (a) factored out, and was useless.
The goal is to generate a stoploss price that when hit, would be p% loss of total account size when using leverage(L). If we were to use real numbers, they would look like this
EXAMPLES
My account has 0.105(a) BTC and I want a stoploss of 9%(p). If I enter in a position of 9613(e) with 4.7x(L) leverage, I should have a stoploss price of around 9802(x) in a short (im betting the price is going down, but instead it went up)
My Account has 9.43 ETH and I want a stoploss of 9%. If I enter into a position of 170.90 with 1x leverage, I should have a stoploss price of around 173.9 (math above calculates it as 182.6 giving a percentage of 6.87% instead of 9)
if my account balance(a) is larger, the price, x, should be higher
I found that I only need to use the Account Balance (a) to determine the true Leverage(L) and this much simpler formula got me there
for a buy order: $$x = e-(p/L\times 0.01)\times e).$$
for a sell order $$x = e+(p/L\times 0.01)\times e).$$