Repository navigation
Fixed Profit Target and Stop Loss #765
Replies: 2 comments
|
I also need this feature |
|
# entry_price, high, low, range are all aligned to your entries
tp_pct = (high + your_range - entry_price) / entry_price
sl_pct = (entry_price - (low - your_range)) / entry_price
pf = vbt.Portfolio.from_signals(
close,
entries=entries,
exits=exits,
sl_stop=sl_pct,
tp_stop=tp_pct,
)Since both are set once from arrays that already encode your entry-time high/low/range, they're genuinely fixed at entry — nothing needs to be recomputed mid-trade, which is exactly why |
Uh oh!
There was an error while loading. Please reload this page.
I am working on backtesting a strategy using VectorBT, and I was wondering if there is a way to have a fixed profit target and stop loss from the entry price. Specifically, I want to have a profit target of the high + range and a stop loss as the low - range. I tried using the adjust_tp_func_nb argument in the from_signals method, but I am not sure if this is the proper way to do this. Could someone please provide a suggestion for how I can implement this specific type of feature.
All reactions