diff --git a/config.json.example b/config.json.example index 5b98a505a..63530d936 100644 --- a/config.json.example +++ b/config.json.example @@ -4,7 +4,9 @@ "stake_amount": 0.05, "fiat_display_currency": "USD", "dry_run": false, - "trailing_stop": false, + "trailing_stop": { + "positive" : 0.01 + }, "unfilledtimeout": 600, "bid_strategy": { "ask_last_balance": 0.0 diff --git a/freqtrade/analyze.py b/freqtrade/analyze.py index c1bae8303..4a073c3bd 100644 --- a/freqtrade/analyze.py +++ b/freqtrade/analyze.py @@ -203,7 +203,6 @@ class Analyze(object): # evaluate if the stoploss was hit if self.strategy.stoploss is not None and trade.stop_loss >= current_rate: - # just for debugging if 'trailing_stop' in self.config and self.config['trailing_stop']: logger.warning( "HIT STOP: current price at {:.6f}, stop loss is {:.6f}, " @@ -216,7 +215,19 @@ class Analyze(object): # update the stop loss afterwards, after all by definition it's supposed to be hanging if 'trailing_stop' in self.config and self.config['trailing_stop']: - trade.adjust_stop_loss(current_rate, self.strategy.stoploss) + + # check if we have a special stop loss for positive condition + # and if profit is positive + stop_loss_value = self.strategy.stoploss + if isinstance(self.config['trailing_stop'], dict) and \ + 'positive' in self.config['trailing_stop'] and \ + current_profit > 0: + + print("using positive stop loss mode: {} since we have profit {}".format( + self.config['trailing_stop']['positive'], current_profit)) + stop_loss_value = self.config['trailing_stop']['positive'] + + trade.adjust_stop_loss(current_rate, stop_loss_value) # Check if time matches and current rate is above threshold time_diff = (current_time.timestamp() - trade.open_date.timestamp()) / 60 diff --git a/freqtrade/persistence.py b/freqtrade/persistence.py index 52aa17038..a34b1b6c9 100644 --- a/freqtrade/persistence.py +++ b/freqtrade/persistence.py @@ -141,7 +141,7 @@ class Trade(_DECL_BASE): else: logger.debug("keeping current stop loss") - print( + logger.debug( "{} - current price {:.8f}, bought at {:.8f} and calculated " "stop loss is at: {:.8f} initial stop at {:.8f}. trailing stop loss saved us: {:.8f} " "and max observed rate was {:.8f}".format(