Strategy function evaluates the next bar #32
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Thank you for the report! I've investigated this and it's not a bug - it's the correct Pine What's happening When you call strategy.entry() at bar 3, the order is created but fills on the next bar (bar Why the output looks confusing The execution order at each bar is:
So your debug output actually shows: The strategy print happens at the beginning of bar 4 before your script runs, which is why it This is standard Pine Script behavior - orders always execute on the bar after they're I'm converted this to a discussion because this is actually correct behavior that can be |
Beta Was this translation helpful? Give feedback.

Thank you for the report! I've investigated this and it's not a bug - it's the correct Pine
Script behavior.
What's happening
When you call strategy.entry() at bar 3, the order is created but fills on the next bar (bar
4) using bar 4's prices. This matches TradingView exactly.
Why the output looks confusing
The execution order at each bar is:
So your debug output actually shows:
bar_index= 3 open= 1.0762 # User script at bar 3 (creates order)
pynecore/lib/strategy/init.py:534 # START of bar 4: processes bar 3's order
price= 1.07712 h= 1.0768 l= 1.077 # Using bar 4's values - CORR…