Visual
20 entries. What each one takes, what it returns, and a working example.
Returns the color's opacity as a number 0-1. If the color has no alpha channel (6-digit #rrggbb) or is invalid, it returns 1 (fully opaque).
It is a color decomposer: it converts a hex color's alpha (opacity) byte to the 0-1 scale (e.g. 0x80 → 0.502). Where red/green/blue give channels, alpha gives opacity.
c = "#2962ff80" plot(alpha(c), "Opaklık")
The opacity of #2962ff80 (0x80 → ~0.502) is plotted as a flat line.
barcolor(color, offset?, display?)
Returns nothing; colors the candle bodies with the given color.
The color can be a series; with iff each candle takes its own color by condition. barcolor colors INSTANTANEOUSLY — each bar's color depends only on that bar's condition. To color a region continuously until the signal changes, use colorBySignal.
barcolor(iff(close > open, "#26a69a", "#ef5350"))
Up candles are colored green, down candles red.
barcolor(iff(close > sma(close,50), "#26a69a", "#787b86"))
Candles are green while price is above SMA50, gray while below.
bgcolor(color, offset?, display?)
Returns nothing; colors the bars' background (the full vertical stripe).
The color can be a series; with iff you give a different color per bar by condition (or na → no shading). bgcolor paints the entire vertical bar stripe — it is independent of price level.
Passing na in the second iff branch shades only the bars that meet the condition — keeping the chart free of needless color.
bgcolor(iff(close > open, "#26a69a22", "#ef535022"))
Up bars get a translucent green background, down bars a translucent red one.
bgcolor(iff(rsi(close,14) > 70, "#ef535033", na))
Only RSI>70 (overbought) bars get a red background; other bars stay unshaded (na).
Returns the color's blue channel as a number 0-255 (invalid color → 0).
It is a color decomposer: it extracts the blue component from a hex color. Together with red/green/alpha it is used to take a color apart and rebuild it with rgb.
base = "#2962ff" kanal = blue(base) plot(kanal, "Mavi Kanal")
The blue channel (255) of #2962ff is plotted as a flat line.
colorByPosition(long?, short?, flat?)
Returns nothing; after the backtest it colors the candles by the strategy position state.
It requires a strategy (a position must be opened with enterLong/enterShort). Colors are applied after the backtest runs, by looking at each bar's position: long>0 → long color, short<0 → short color, otherwise flat. The actual position state, not a condition, decides.
fast = sma(close, 5) slow = sma(close, 20) enterLong(crossover(fast, slow)) enterShort(crossunder(fast, slow)) colorByPosition("#26a69a", "#ef5350", "#787b86")
Candles are green while long, red while short, gray while flat.
colorBySignal(longSignal, shortSignal, longColor?, shortColor?, flatColor?)
Returns nothing; colors candle regions by forward-filling the signal state.
It takes two signals and holds STATE: on longSignal the region turns green and stays so until shortSignal arrives; on shortSignal it turns red. Before the first signal it uses the flat color. Where barcolor(iff(...)) colors each bar instantaneously and looks speckled, this produces continuous green/red blocks.
colorBySignal(crossover(close, sma(close,20)), crossunder(close, sma(close,20)))
The region turns green when price crosses above SMA20 and red when it crosses below; gray until the first signal.
al = crossover(close, sma(close,20)) sat = crossunder(close, sma(close,20)) colorBySignal(al, sat, "#00c853", "#d50000", "#9e9e9e")
The same signals are colored as continuous blocks with custom green/red/gray tones.
Returns nothing; shades the area between the a and b series with color.
Both edges may be series; a constant number is broadcast to every bar. The fill covers the vertical gap between a and b; the area is shaded correctly even where the edges cross. You usually plot both edges as well to make the band visible.
Add alpha to the color (e.g. #2196f322 — the trailing 22 is opacity) so the candles under the fill stay visible.
fast = ema(close, 12) slow = ema(close, 26) plot(fast) plot(slow) fill(fast, slow, "#2196f3")
The area between EMA12 and EMA26 is shaded blue; the band widens as the two averages spread apart.
b = bb(close, 20, 2) plot(b.upper) plot(b.lower) fill(b.upper, b.lower, "#2962ff22")
The body between the Bollinger upper and lower bands fills with translucent blue.
Returns the color's green channel as a number 0-255 (invalid color → 0).
It is a color decomposer: it extracts the green component from a hex color. Together with red/blue/alpha it is used to take a color apart and rebuild it with rgb.
base = "#26a69a" kanal = green(base) plot(kanal, "Yeşil Kanal")
The green channel (166) of #26a69a is plotted as a flat line.
hline(price, title?, color?, style?, width?, display?)
Returns nothing; draws a horizontal constant level on the price panel.
The level is a single constant number — it does not change bar to bar. If you pass an indicator series (e.g. sma(close,50)) only its last-bar value is used to draw a flat line at that height; for a moving line use plot.
For multiple thresholds on the same chart call hline several times (e.g. 70 and 30); each becomes an independent level.
hline(70, "Aşırı Alım", "#ef5350")
Red dashed horizontal line at level 70, labeled 'Aşırı Alım'.
hline(30, "Aşırı Satım", "#26a69a", "dotted", 2)
Green dotted horizontal line at level 30, 2px thick.
location.abovebar / belowbar / top / bottom / absolute / price
Placement names for plotshape/plotchar (dot access). location.abovebar is identical to "abovebar".
mark(condition, style?, location?, color?, text?, size?)
Returns nothing; stamps a mark on bars where the condition is true.
condition is a series; one mark is drawn per true bar. It is a compact helper for quickly flagging signals — location and size are adjustable, but it lacks the finer controls (offset/textcolor) of plotshape.
mark(crossover(close, sma(close,20)), "triangleup", "belowbar", "#26a69a", "AL")
Green up-triangle with 'AL' text below the bar where price crosses above SMA20.
mark(rsi(close,14) > 70, "circle", "abovebar", "#ef5350", "", "small")
Small red circle above the bar on RSI>70 bars.
plot(series, title?, color?, pane?, style?, linewidth?, linestyle?, offset?, display?)
Returns nothing; it draws the series onto the chart.
Colors are hex codes; see the Colors section for ready-made options.
plot(sma(close,20), "SMA20", "#2962ff")
Blue SMA20 line on the price pane.
plot(iff(crossover(close,sma(close,10)), low, na), "AL", "#26a69a")
A green dot at the low level only on cross-above bars; other bars empty (na).
plotarrow(series, title?, colorup?, colordown?, offset?, minheight?, maxheight?, display?)
Returns nothing; it draws arrows according to the signed series.
The arrow height is proportional to |value| (clipped to minheight..maxheight); it visualizes the magnitude.
plotarrow(close - open)
Up arrow on bullish bars, down arrow on bearish bars; length proportional to body size.
plotarrow(macd(close).hist)
Up/down arrows based on the MACD histogram sign.
plotbar(open, high, low, close, title?, color?, editable?, show_last?, display?, format?, precision?, force_overlay?)
Returns nothing; draws one OHLC bar per bar on the price chart.
Unlike plotcandle: there is NO body (filled rectangle) — just a vertical high-low line with a short tick on the left for open and on the right for close. The whole bar is a SINGLE color (no separate body/wick/border colors like plotcandle).
plotbar(open, high, low, close, color=close>=open?"#26a69a":"#ef5350")
Green OHLC bar when close is above open, red when below.
plotcandle(open, high, low, close, title?, color?, wickcolor?, editable?, show_last?, bordercolor?, display?, format?, precision?, force_overlay?)
Returns nothing; it draws a custom candle series from the given OHLC.
For drawing your own OHLC (e.g. Heikin-Ashi, rescaled) or conditionally colored candles. The color can be conditioned on a series.
plotcandle(open, high, low, close)
OHLC candles in the default single-blue color.
plotcandle(open, high, low, close, color=close>=open?"#26a69a":"#ef5350", wickcolor="#787b86")
Green body on rise / red body on fall, gray wick.
plotchar(series, title?, char?, location?, color?, offset?, text?, textcolor?, size?, display?)
Returns nothing; it stamps a character onto the bars where the condition holds.
Like plotshape, but instead of a fixed shape it draws the character/glyph you choose. The collision-avoidance rule in text works the same as plotshape.
plotchar(close > open, char="B", location="belowbar", color="#26a69a")
Green 'B' below green (bullish) bars.
plotchar(crossunder(close, ema(close,20)), char="x", location="abovebar")
'x' above the bar on EMA20 cross-below bars.
plotshape(series, title?, style?, location?, color?, offset?, text?, textcolor?, size?, display?)
Returns nothing; it stamps a shape onto the chart on the bars where the condition holds.
series is a boolean/series; a shape is drawn on every true bar. location positions the shape relative to the bar. Adding in text (at the END of the text for abovebar, at the START for belowbar) pushes the label away from the bar — use this to avoid overlapping another label on the same bar (e.g. the automatic buy/sell marker).
If you need several marks on the same bar, use different location values (abovebar/belowbar) to keep them from overlapping.
plotshape(crossover(close, sma(close,10)), style="triangleup", location="belowbar", color="#26a69a")
Green up-triangle below the bar on SMA10 cross-above bars.
plotshape(rsi(close,14) > 70, style="arrowdown", location="abovebar", color="#ef5350", size="small")
Small red down-arrow above the bar on RSI>70 bars.
Returns the color's red channel as a number 0-255 (invalid color → 0).
It is a color decomposer: it extracts the red component from a hex color. Together with green/blue/alpha it is used to take a color apart and rebuild it with rgb.
base = "#2962ff" fade = rgb(red(base), green(base), blue(base), 0.2) bgcolor(fade)
The channels of #2962ff are read and reassembled at 20% opacity; the background becomes faint blue (#2962ff33).
Returns a hex color string in #rrggbbaa form (opacity is mapped to a 0-255 alpha byte).
It is a color builder: it assembles one hex color from three channels + opacity. opaklik is on a 0-1 scale and is rounded to a 0-255 alpha byte (e.g. 0.15 → 0x26). You can feed the result anywhere a color is expected — plot/barcolor/bgcolor/fill.
bgcolor(rgb(38, 166, 154, 0.15))
A 15%-opacity green (#26a69a26) background applied to all bars.
barcolor(rgb(239, 83, 80))
All candles colored with fully opaque red (#ef5350ff).
shape.arrowup / arrowdown / triangleup / triangledown / circle / square / diamond / cross / xcross / flag / labelup / labeldown
Shape names for plotshape (dot access). shape.circle is identical to "circle"; the dotted form is preferred for readability. (plotchar takes a character, not a shape, so it does not apply there.)