You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
# define in % when to sell a coin that's not making a profit.STOP_LOSS: 5# define in % when to take profit on a profitable coin.TAKE_PROFIT: .8# when hit TAKE_PROFIT, move STOP_LOSS to TRAILING_STOP_LOSS percentage points below TAKE_PROFIT hence locking in profit# when hit TAKE_PROFIT, move TAKE_PROFIT up by TRAILING_TAKE_PROFIT percentage pointsTRAILING_STOP_LOSS: .4TRAILING_TAKE_PROFIT: .1
Then the STOP_LOSS is set to -5 and the TAKE_PROFIT value is stored:
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 means TP = 50.4 and SL = 47.5.
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 is LastPrice = 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.
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_LOSS coins_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 and coins_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 and TRAILING_STOP_LOSS = 0.1, the results would be coins_bought[coin]['take_profit'] = 70.56 and coins_bought[coin]['stop_loss'] = 52.25, for example.
The text was updated successfully, but these errors were encountered:
d4fuQQ
changed the title
the Trailing Stop Loss and Trailing Take Profit calculation do not make sense to me
the Trailing Stop Loss and Trailing Take Profit calculations do not make sense to me
Jan 26, 2023
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:
Binance-volatility-trading-bot/Binance Detect Moonings.py
Lines 437 to 438 in 533daf5
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 means
TP = 50.4
andSL = 47.5
.Binance-volatility-trading-bot/Binance Detect Moonings.py
Lines 364 to 366 in 533daf5
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
.Binance-volatility-trading-bot/Binance Detect Moonings.py
Lines 376 to 378 in 533daf5
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.The text was updated successfully, but these errors were encountered: