There's an options to add tp_stop
or sl_stop
on vbt.Portfolio.from_signals
which is percent based.
sl_stop : array_like of float Stop loss. Will broadcast.
A percentage below/above the acquisition price for long/short position. Note that 0.01 = 1%.
I would like to exit based on a move of n
price ticks or n
dollars per contract. For example if price moves 50 ticks in against me then exit.
I can at least point you in the right direction, though I can't answer fully.
You need to check out vectorbt's "adjust_tp_func_nb" and "adjust_sl_func_nb".
When asked about how to create a take profit rule that is more elaborate than just a static percentage, vectorbt's author has said "To add a further condition ... you need to use adjust_tp_func_nb."
Similarly, you can create custom stop loss logic with "adjust_sl_func_nb".
See vectorbt's docs
And the author's answer I mentioned
Edit: I found an example that is close to your scenario, at the first link, here. Look for "We can implement our own stop loss or take profit, or adjust the existing one at each time step. Let's implement stepped stop-loss:"
You will see an example like: