Price series
20 entries. What each one takes, what it returns, and a working example.
barstate.islast / isconfirmed / isfirst / ishistory / isrealtime / isnew
A set of bar-state flags accessed with a dot: barstate.islast, isconfirmed, isfirst, ishistory, isrealtime, isnew. Each returns 1 (true) / 0 (false) in a condition.
islast = is this the last bar. isconfirmed = has the bar closed/confirmed (always 1 in backtest; the forming last bar is 0 live). isfirst = is this the first bar. ishistory = is this a closed historical bar (always 1 in backtest). isrealtime = is this a forming real-time bar (always 0 in backtest). isnew = is this a genuine new bar, as opposed to a price-update (tick-recompute) of the same bar (always 1 in backtest; live it's 0 when the same bar recomputes, 1 when a new bar arrives). Each member's camelCase spelling is also valid (isLast, isConfirmed, isFirst, isHistory, isRealtime, isNew).
if barstate.islast { label(close, "Son fiyat: " + str.tostring(close), barIndex) }
Draws a price label only on the last bar (typical for live tracking).
if barstate.isnew { alert("Yeni bar geldi", alert.freq_once_per_bar) }
Only fires the alert when a genuinely new bar arrives; does not repeat on intrabar price updates of the same bar.
The most commonly used price source; the default input of most indicators (sma/ema/rsi...) is close.
plot(sma(close, 20))
The 20-bar moving average of the close as a line on the price panel.
plot(close > open ? 1 : 0)
1 when the bar is green (close above open), otherwise 0.
Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error.
plot(dayofmonth)
Plots each bar's day-of-month value (1-31).
Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error.
plot(dayofweek == dayofweek.monday ? 1 : 0, "Pazartesi mi")
Plots 1 on Monday bars, 0 on other days.
It is the top of the wick; used in resistance, breakout and highest computations.
plot(highest(high, 20))
A line tracking the highest peak of the last 20 bars (upper envelope).
plot(high - low)
The bar range: the distance between the high and the low.
If a bar's high or low is na, that bar's hl2 is na. It is a body-midpoint source, less noisy than close.
plot(sma(hl2, 20))
The 20-bar average of the mid-price; a smoother line than using close.
A balanced price source that also accounts for the close; the classic input for volume-weighted indicators.
plot(sma(hlc3, 20))
The 20-bar average of the typical price.
Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error.
plot(hour == 10 ? 1 : 0, "10:00 mu")
Plots 1 when the bar's hour is exactly 10, 0 otherwise.
It is the bottom of the wick; used in support, downside breaks and lowest computations.
plot(lowest(low, 20))
A line tracking the lowest trough of the last 20 bars (lower envelope).
plotshape(low == lowest(low, 20), style="triangleup", location="belowbar")
An up-triangle below the bar on 20-bar lowest bars.
Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error.
plot(minute)
Plots each bar's minute value (0-59).
Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error. Use `month != month[1]` to catch a month change.
plot(month != month[1] ? 1 : 0, "Ay değişti mi")
Plots 1 on the first bar of a new month, 0 otherwise.
The smoothest source, weighting all four prices equally; it reduces noise but reacts a touch slower.
plot(ema(ohlc4, 20))
The 20-bar exponential average of the average price; one of the smoothest lines.
It is the start of the candle body; compared with close it gives the bar's direction (up/down).
plot(close - open)
Signed body size: positive for an up bar, negative for a down bar.
plot(open - prev(close, 1))
The opening gap: the open relative to the previous close.
Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error. On charts with a minute/hour/day bar duration this is always 0 (bars start on the minute).
plot(second)
Varies 0-59 on a 1-second chart; always 0 on a 1-minute+ chart.
session.ismarket / ispremarket / ispostmarket
Session state variables: session.ismarket, ispremarket, ispostmarket.
Phase 1: regular-session default is constant — ismarket always true, ispremarket/ispostmarket always false. session.regular/extended are SEPARATE constants (for the session() function argument).
syminfo.ticker / mintick / timezone / pointvalue
Symbol information (dot access). Fields backed by real data: syminfo.ticker, syminfo.mintick, syminfo.timezone, syminfo.pointvalue. currency / basecurrency / description / prefix / root / type / session cannot be resolved: an explicit error is raised instead of a silent empty value.
timeframe.period / multiplier / isdaily / isweekly / ismonthly / isintraday / isminutes / isseconds
Chart timeframe metadata variables (dot access): period, multiplier, isdaily, isweekly, ismonthly, isintraday, isminutes, isseconds.
period = TF text. multiplier = numeric (5m→5, hourly→60, daily/weekly/monthly→1). isdaily/isweekly/ismonthly = whether that TF (true/false). isintraday = intraday. isminutes/isseconds = minute/second based. All derived from the bar time-delta.
On some data sources volume can be 0 or missing (na); it is wise to guard volume-based rules with nz.
plot(sma(volume, 20))
The 20-bar average volume; a baseline to compare volume spikes against.
plotshape(volume > sma(volume, 20) * 2, style="circle", location="bottom")
A circle in the bottom band on bars where volume exceeds twice its average.
The week is counted in 7-day blocks starting from the calendar year's January 1st — this is NOT the ISO-8601 week definition (it never jumps year, so it always stays consistent with `year`). Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error.
plot(weekofyear)
Plots each bar's week-of-year (1-53).
Only works for supported symbols/exchange timezones: crypto (UTC), VİOP (Istanbul, no DST), a handful of fixed US/EU/Tokyo zones (including DST rules). For an unsupported symbol/zone, or a year outside the DST rule's range (before 2007 for US, before 1996 for EU), reading the variable raises a clear error.
plot(year)
Plots each bar's year (e.g. 2024).