Variables and state
Values recalculated each bar, and values that survive between bars.
A plain assignment such as trend_up = close > ema(close, 50) is worked out again on every bar. A state value is set once and keeps whatever you last put in it, which is how you count things or remember a price.
state triggers = 0state last_entry: price = nawhen close > open:triggers += 1last_entry = closeon day change:triggers = 0You can annotate a type when the default does not say enough: state last_entry: price = na.