Fixing Trailing Stop Loss to correctly update the stop_loss value #193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are you addressing in this PR
How have you tested this PR
Corrected behaviour has been verified, see below
In your own words, please share how this makes the codebase better.
when USE_TRAILING_STOP_LOSS is enabled and the take_profit value for a coin is reached the new stop_loss value should be set to just below the existing take_profit (ie
take_profit - TRAILING_STOP_LOSS
).Due to the order of the operations this was being incorrectly set to
take_profit + TRAILING_TAKE_PROFT - TRAILING_STOP_LOSS
This PR simply switches the order of the operations to update take_profit and stop_loss to prevent the bug.
Test output
For comparison, existing incorrect behaviour with same params: