Open d4fuQQ opened 1 year ago
coins_bought[coin]['stop_loss'] = 39.7 is define in %. so if enter price is 50, the new stop loss price is: 50 * (1 + 0.397)
coins_bought[coin]['stop_loss'] = 39.7 is define in %.
no, I don't agree.
The only value defined directly in % is actually PriceChange
, i.e. PriceChange = 40
.
so if enter price is 50, the new stop loss price is: 50 * (1 + 0.397)
where can I find this calculation in the code? I don't see it.
attached is an Excel sheet following the script step by step with the example values: Binance-volatility-trading-bot_TSL_calc.xlsx
Hey OP,
coins_bought[coin]['take_profit'] = TP + (TP TRAILING_TAKE_PROFIT) coins_bought[coin]['stop_loss'] = SL + (SL TRAILING_TAKE_PROFIT)
Did this solution work for you? Please Advise
Hi, I'm wondering about the calculation of the readjusted TP and SL values based on the settings coming from the config file.
These are the default values as given in the config:
Then the STOP_LOSS is set to -5 and the TAKE_PROFIT value is stored: https://github.com/CyberPunkMetalHead/Binance-volatility-trading-bot/blob/533daf54c0c47390d2d51daa67fec8127da4a829/Binance%20Detect%20Moonings.py#L437-L438
Now, let's assume a simple scenario: A position was opened at a price of
coins_bought[coin]['bought_at'] = 50
. Based on the following calculations this meansTP = 50.4
andSL = 47.5
. https://github.com/CyberPunkMetalHead/Binance-volatility-trading-bot/blob/533daf54c0c47390d2d51daa67fec8127da4a829/Binance%20Detect%20Moonings.py#L364-L366 This is not a lot of profit, but okay, perhaps TAKE_PROFIT should just be a higher value.But that's not the actual issue here.
The next step is to readjust the TAKE_PROFIT and STOP_LOSS values
if LastPrice > TP and USE_TRAILING_STOP_LOSS:
. So, let's say the last price isLastPrice = 70
. This would be a 40% price increase and is calculated correctly in line 371:PriceChange = float((LastPrice - BuyPrice) / BuyPrice * 100)
, i.e.PriceChange = 40
.https://github.com/CyberPunkMetalHead/Binance-volatility-trading-bot/blob/533daf54c0c47390d2d51daa67fec8127da4a829/Binance%20Detect%20Moonings.py#L376-L378
And now the calculation becomes somewhat obscure to me. Because, looking at the example values, the new TAKE_PROFIT price would then be calculated as
coins_bought[coin]['take_profit'] = 40.1
and the new STOP_LOSScoins_bought[coin]['stop_loss'] = 39.7
, respectively.Both are now below the actual entry price. So what am I missing here?
If you ask me, I'd say the following calculations would make a lot more sense, resulting in
coins_bought[coin]['take_profit'] = 55.44
andcoins_bought[coin]['stop_loss'] = 66.5
, respectively:Of course, then the values in the config should be adjusted accordingly (TRAILING_TAKE_PROFIT > TRAILING_STOP_LOSS), so the new stop loss level is lower than the new take profit level. For
TRAILING_TAKE_PROFIT = 0.4
andTRAILING_STOP_LOSS = 0.1
, the results would becoins_bought[coin]['take_profit'] = 70.56
andcoins_bought[coin]['stop_loss'] = 52.25
, for example.