Reputation: 1062
I am trying to get values of previous bar in a Heikin Ashi chart on 15m time frame. As the script will execute after every 15m. I want to check if previous bar was closed high than its open. If it was I am opening a new entry in strategy. It is working but the long position are not opening as it is supposed to be.
I want the strategy to open trade on candles where its yellow color. I am using the following code
long = close[1] > open[1]
short = close[1] < open[1]
strategy.entry("Long", strategy.long, when = long)
strategy.close("Long", when = short)
Upvotes: 0
Views: 295
Reputation: 21219
By default, it will open positions on the open of the next candle. If you want to enter a position when a candle is closed, you should use process_orders_on_close=true
in your strategy()
call.
Upvotes: 1