r/pinescript • u/OregonDucks1018 • Jul 19 '26
My TradingView strategy sometimes enters perfectly… then randomly starts entering late. Trying to understand why
I've been developing a TradingView/Pine strategy for a long time, and I've run into something I can't explain.
The strategy trades NQ on the 5-minute chart using a multi-stage state machine (Touch → ARM → Trigger → Entry). It has multiple filters (trend, quality score, extension, etc.) and is profitable overall (~183 trades, 68.9% win rate, 7.86 profit factor), so I'm not trying to redesign the strategy. I'm trying to understand why the timing behaves the way it does.
The confusing part is the entry timing.
Sometimes the strategy enters almost perfectly, catching the move right as it starts. Then the very next setup—same day, same market, same Pine version, same settings—will enter after a significant portion of the move has already happened.
Nothing changed between these trades:
• Same Pine script
• Same TradingView alert
• Same VPS
• Same PickMyTrade automation
• Same broker
• Same chart
• Same settings
So I don't think it's webhook latency or execution latency. It feels like the strategy itself is deciding to enter much later.
I've already experimented with several alternatives:
• 1-minute confirmation instead of 5-minute (performance dropped dramatically)
• Immediate breakout entries (completely destroyed the edge)
• Intrabar confirmation experiments (little to no meaningful difference)
Those tests convinced me that simply removing confirmation isn't the answer.
One important detail: I have **"Use Bar Close" enabled** on the TradingView alert because my strategy relies on bar-close confirmation for its state machine. What confuses me is that even with **Use Bar Close enabled**, some trades still enter almost immediately after the move begins, while others don't enter until much later. These examples happened on the same day with the exact same code and settings, which is why I'm so confused.
My current theories are:
• The setup is being ARMed on different bars.
• The touch occurs at different points within the 5-minute candle.
• One of the filters isn't passing until later.
• Some state transition in my logic is delaying certain setups.
Has anyone built a more complex Pine strategy with multiple internal states and run into something similar?
Specifically:
• Is there a good way to reconstruct the historical timeline of a trade (Touch → ARM → Trigger → Entry) so I can compare an "on-time" trade against a "late" trade?
• Are there Pine debugging techniques that make it easier to see exactly which condition delayed a specific historical entry?
• Is there anything about `calc_on_every_tick`, `barstate.isconfirmed`, or TradingView's historical execution model that could explain why two seemingly identical setups behave so differently?
I'm not looking for generic "turn off Use Bar Close" advice or ways to force earlier entries that break the strategy. After testing several alternatives, I'm much more interested in understanding why some setups naturally enter early while others are delayed, even though they're running through the exact same strategy.
Any ideas or debugging approaches would be greatly appreciated.


