This is a snippet of the script. The strategy is meant for the daily chart and each bar is for the day. The script will look to see if DI+ or DI- is on top. If DI+ is on top, enter a long position at the end of the day and close the position at the open of the next day. If DI- is on top, open a short position and close the position at the open of the next day. I've gotten close, but "process_orders_on_close" closes the position using the close price instead of the open.
I'm stump and not even sure if this is possible. Any help would be greatly appreciated. Thanks!
@version=4
strategy("Sam's Strategy", overlay=true, process_orders_on_close = true,initial_capital=10000)
plot(plus, color = color.green, title="plusDI")
plot(minus, color = color.red, title="minusDI")
overallLong = bool(na)
overallShort = bool(na)
Decision = bool(na)
//ADX enters zone between DMI for the first time
// if green above red, go calls
Decision := if plus > minus
Decision := true
overallShort := na
overallLong := true
// if red above green, go puts
else if minus > plus
Decision := true
overallLong := na
overallShort := true
else
na
strategy.close_all()
//strategy part
if (afterStartDate and overallLong)
strategy.entry("GG-EL", long=true)
if (afterStartDate and overallShort)
strategy.entry("GG-ES", strategy.short)
question from:
https://stackoverflow.com/questions/65866839/strategy-to-open-order-at-end-of-day-and-close-order-at-open-of-the-next-day-on 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…