I have a TradingView strategy, which opens orders at a stop price.
This is the code I use to open positions:
strategy.entry("Long", strategy.long, stop=LongEntryPrice, alert_message = alert_string_open)
On backtest everything works correctly, trades are opened exactly at the stop levels, so they are opened intrabar (not at the bar open or close of next candle).
However, during the live data, the strategy is behaving differently, and trades are opened with significant delay/slippage. It seems that trades are open at the close of the next bar. However, if I refresh the page all the entry points become correct (intrabar and at the correct levels).
I am looking for a way to execute trades intrabar exactly at the stop price, during live data feed. I understand there could be some slippage in real-live trading, but I want to make TradingView trigger alerts without delays when the price reaches a certain level.
Any ideas what could be the possible reason for this?
What I have already tried to do:
- calc_on_every_tick=true
- I Tried removing all drawings, as I had a hypothesis that it is too heavy and recalculation takes a lot of time. The script now updates faster. But this didn’t solve the issue.
- Originally the strategy worked on range charts, I tried backtesting on traditional candlesticks, and the same issue.
- Checked slippage in settings, it was zero
Dmitry Karavaev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.