RicardoSantos

BUG - strategy.direction.all

bug
240 0 6
bug
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
Remove from Favorite Scripts Add to Favorite Scripts
//@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)
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out