freqtrade icon indicating copy to clipboard operation
freqtrade copied to clipboard

Enable future positions to reverse their position

Open xmatthias opened this issue 1 year ago • 1 comments

Summary

This PR enables switching from long to short positions.

The simplest example has "enter_short" and "exit_long" both set to 1 within a candle (while being in a long position) - which will close the long trade, and open a new short trade.

This will also work for all other exit reasons like (trailing) stoploss, roi, or custom-exits.

To prevent a subsequent (despite having a signal in the other direction) - best use the cooldown protection - which (with a setting of 1) can restore previous behavior.

Closes #9183

Quick changelog

  • Enable long/short switch within one candle for backtesting
  • Change auto-lock to be towards the trade-side only (allowing to enter a short trade after closing out a long trade and viceversa).

TODO:

  • [ ] Update docs / enhance docs in this regards

xmatthias avatar Oct 12 '24 18:10 xmatthias

Coverage Status

coverage: 94.418% (+0.01%) from 94.406% when pulling c03f8afca1c33b39822a0e0e9fac8aff0ae8443f on feat/bt_reverse into 52ae7c3615e37408dc52b45459d8421a0a1ae967 on develop.

coveralls avatar Oct 12 '24 18:10 coveralls