if
strategy.risk.allow_entry_in(strategy.direction.all)
strategy.exit() and strategy.close_all() doesnt work
but if
strategy.risk.allow_entry_in(strategy.direction.long)
or
strategy.risk.allow_entry_in(strategy.direction.short)
it works
strategy.risk.allow_entry_in(strategy.direction.all)
strategy.exit() and strategy.close_all() doesnt work
but if
strategy.risk.allow_entry_in(strategy.direction.long)
or
strategy.risk.allow_entry_in(strategy.direction.short)
it works
//@version=2 strategy(title='test', shorttitle='T', overlay=true, initial_capital=100000, currency=currency.USD) strategy.risk.allow_entry_in(strategy.direction.all) trade_size = input(10000.0) take_profit_in_ticks = input(500) stop_loss_in_ticks = input(50) // ||-----------------------------------------------------------------------------------------------------------------------------------------------------------|| trade_session = input(title='Trade Session:', type=string, defval='0400-1500', confirm=false) istradingsession = not na(time('1', trade_session)) bgcolor(istradingsession?gray:na) // ||-----------------------------------------------------------------------------------------------------------------------------------------------------------|| strategy.entry('buy', long=true, qty=trade_size, when=change(istradingsession) > 0) strategy.entry('sel', long=false, qty=trade_size, when=change(istradingsession) > 0) strategy.exit('exit buy', from_entry='buy', profit=take_profit_in_ticks, loss=stop_loss_in_ticks) strategy.exit('exit sel', from_entry='sel', profit=take_profit_in_ticks, loss=stop_loss_in_ticks) strategy.close_all(when=change(istradingsession) < 0)