Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

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)