Skip to content
Algo Trade Analytics Docs

var - Pine Script Keyword

var is the keyword used for assigning and one-time initializing of the variable.

var variable_name = expression
//@version=6indicator("Var keyword example")var a = closevar b = 0.0var c = 0.0var green_bars_count = 0if close > open    var x = close    b := x    green_bars_count := green_bars_count + 1    if green_bars_count >= 10        var y = close        c := yplot(a)plot(b)plot(c)