I have a strategy that I am trying to improve with a trailing stop. Everything is working well except that the strategy will not close the trade until the close of the bar. I am wanting the strategy to close the trade on the tick that the low crosses the trailing stop on long trades and on the tick that the high crosses the trailing stop on short trades.
I have tried a million different ways but cannot get it to work. I have tried. strategy.close()
, strategy.exit()
, strategy.close_all()
, immediately=true
, process_orders_on_close=true
, and process_order_on_close=false
. I have also changed the other strategy settings such as calc_on_every_tick=true
, use_bar_magnifier=true
(I am a premium user) etc.
I have searched on multiple sites online but can't find the answer and have submitted a ticked with TV without an answer.
Can anyone help?
The problem is that strategies on historical data will execute one bar after calculation.
To solve that problem you should use limit orders instead,
which will execute on the price given.
But still then it will calc only after
barmerge.isconfirmed
.This behaviour will change when using live data and using
calc_on_every_tick = true
.Here is an example...
There are other ways too.
But to help you with that we need a compile-able code example first.