Closed 010011x closed 3 years ago
@Potato334343 How you want your stop loss to change with the trade duration?
Anyways, from_order_func
is the way (there is an example for tracking a stop price under from_order_func
documentation). You can also implement your own generate_ohlc_stop_exits
and then use from_signals
. But you need to do it on your own, there is nothing comparable in any backtesting framework, to my knowledge. In the next release, I'll add stop loss/take profit to from_signals
.
@polakowo
Understood, thank you.
I was thinking about something like this https://www.freqtrade.io/en/latest/strategy-advanced/#time-based-trailing-stop
@Potato334343 maybe I can incorporate this into from_signals
. I already implemented stop loss, trailing stop loss, and take profit. I could give you an option to pass a function that returns stop value as freqtrade does it, but with slightly different arguments. Something like this:
def adjust_stop_nb(init_i: int, init_price: float, last_close: float, i: int, stop: float) -> float:
return stop
You can then get the trade duration by doing i - init_i
and profit using last_close - init_price
. This function will be run before processing the current timestamp i
. But you wouldn't be able to switch between standard and trailing stop loss because they are treated as different types.
@polakowo
that would be great, thank you!
Implemented in 0.19.0.
Hi!
I'm using
generate_ohlc_stop_exits
to test stop loss values. I want to adjust my stop loss based on the duration of the trade. Is there an easy way to do that ? Or should I usefrom_order_func
to do that? Is there an example maybe?Thanks a lot!