vectorbt
vectorbt copied to clipboard
Using close of bars as entry in OHLCSTEX
Hi Oleg,
I'm using OHLCSTEX in my data science workflow and I've noticed a few things I'd like to have control over. Currently, you get the opening price of a bar when entries is true at a given minute bar. I've read through the documentation and I've noticed that ohlc_stop_choice_nb has an is_open_safe argument. I know that OHLCSTEX uses ohlc_stop_choice_nb for its tp/sl/ts simulation. Is there any way we can set the is open safe argument to false for OHLCSTEX run? When I enter I want to get the close of the bar and start simulating the orders from that point on. I don't want to assume I can get the open of the bar. Thank you!
Hi @trevor-richardson, you can pass is_open_safe
directly to OHLCSTEX.run
, but note that it has no effect if wait
is set to 1 (default), so you can pass any open
and it's already safe. The logic is the following: is_open_safe
tells vectorbt that at the entry bar open
(your entry price) comes before low and high, such that vectorbt can use low and high at this bar to check the stop criteria. But since you're waiting one time step (= skipping the entry bar, such that entry and exit can't happen at the same time), vectorbt doesn't need high and low of the entry bar anymore and your open
becomes automatically safe.