Replies: 1 comment
-
Okay, got it to work with the basic strategy described in the tutorials: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi. Basically, I want to do a grid search of different take profit (TP) and stop loss (SL) values.
BUT, on top of the TP/SL exits, I also want to add an exit strategy based on indicators.
How can I can I combine the exits generated from a grid of tp/sl with the exits_indicators generated by indicators?
See the following example:
`
exits_indicators = bb.upper_below(df['Close']) & rsi.rsi_above(80)
stops = np.arange(0.01, 0.6, 0.01) / 100
stops_grid = np.array(np.meshgrid(stops, stops)).T.reshape(-1,2)
ohlcstx = vbt.OHLCSTX.run(
entries,
entry_price = df["Close"],
open = df["Open"],
high = df["High"],
low = df["Low"],
close = df["Close"],
sl_stop = list(stops_grid[:,0]),
tp_stop = list(stops_grid[:,1]),
)
exits = ohlcstx.exits.copy()
price = ohlcstx.close.copy()
price[exits] = ohlcstx.stop_price
del ohlcstx
pf_kwargs = dict(size=1, fees=0.000001, freq='1m', init_cash=100000, leverage = 16.6, leverage_mode = "Eager")
pf = vbt.Portfolio.from_signals(
df['Close'],
entries,
exits,
price = price,
**pf_kwargs)
`
Desired output example:
`
exits_indicators = [True, True, False, False, False]
exits = ([False, False, True, False, False],
[False, True, False, False, True])
exits = exits_indicators or exits
exits = ([True, True, True, False, False],
[True, True, False, False, True])
`
In the documentation of vectorbt pro, I found a method called "OHLCSTX.exits_or". Could this be helpful? If so, how do I use it?
Or should I use a completely different approach and set the tp and sl as lists or params in the portfolio?
Thank you very much for your help.
Beta Was this translation helpful? Give feedback.
All reactions