CODESCRIPT

Visual

20 entries. What each one takes, what it returns, and a working example.

alpha(renk)

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).

renk
color
The hex color whose opacity is read. An #rrggbbaa form carrying an alpha channel is expected.
NOTE

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.

CODESCRIPT
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.

color
color
A single hex color (all candles) or a bar-by-bar color series (usually via iff). A bar given na/non-color stays unpainted.
NOTE

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.

CODESCRIPT
barcolor(iff(close > open, "#26a69a", "#ef5350"))

Up candles are colored green, down candles red.

CODESCRIPT
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).

color
color
A single hex color (all bars) or a bar-by-bar color series (usually produced with iff). Passing na/non-color for a bar leaves that bar unshaded.
NOTE

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.

TIP

Passing na in the second iff branch shades only the bars that meet the condition — keeping the chart free of needless color.

CODESCRIPT
bgcolor(iff(close > open, "#26a69a22", "#ef535022"))

Up bars get a translucent green background, down bars a translucent red one.

CODESCRIPT
bgcolor(iff(rsi(close,14) > 70, "#ef535033", na))

Only RSI>70 (overbought) bars get a red background; other bars stay unshaded (na).

blue(renk)

Returns the color's blue channel as a number 0-255 (invalid color → 0).

renk
color
The hex color (#rgb / #rrggbb / #rrggbbaa) whose blue channel is read.
NOTE

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.

CODESCRIPT
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.

long
color
Optional. Candle color while in a long position (default #26a69a).
short
color
Optional. Candle color while in a short position (default #ef5350).
flat
color
Optional. Candle color while flat (no position) (default #787b86).
NOTE

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.

CODESCRIPT
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.

longSignal
bool
The signal that starts the green (long) region; the color turns green from the bar where it is true.
shortSignal
bool
The signal that starts the red (short) region; the color turns red from the bar where it is true.
longColor
color
Optional. Long region color (default #26a69a).
shortColor
color
Optional. Short region color (default #ef5350).
flatColor
color
Optional. Neutral region color before the first signal (default #787b86).
NOTE

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.

CODESCRIPT
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.

CODESCRIPT
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.

fill(a, b, color)

Returns nothing; shades the area between the a and b series with color.

a
series
The series (or a constant number) forming one edge of the band.
b
series
The series (or a constant number) forming the other edge of the band.
color
color
Optional. Fill color (default #2196f3). Use a hex with an alpha channel for translucency (e.g. #2196f322).
NOTE

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.

TIP

Add alpha to the color (e.g. #2196f322 — the trailing 22 is opacity) so the candles under the fill stay visible.

CODESCRIPT
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.

CODESCRIPT
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.

green(renk)

Returns the color's green channel as a number 0-255 (invalid color → 0).

renk
color
The hex color (#rgb / #rrggbb / #rrggbbaa) whose green channel is read.
NOTE

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.

CODESCRIPT
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.

price
number
The fixed price level to draw the line at. If a series is given, its value on the last bar is taken and pinned there (the line does not move bar to bar).
title
string
Optional. Label for the level.
color
color
Optional. Line color (hex).
style
string
Optional. Line style: solid/dashed/dotted (default dashed).
width
number
Optional. Line thickness in pixels (default 1).
NOTE

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.

TIP

For multiple thresholds on the same chart call hline several times (e.g. 70 and 30); each becomes an independent level.

CODESCRIPT
hline(70, "Aşırı Alım", "#ef5350")

Red dashed horizontal line at level 70, labeled 'Aşırı Alım'.

CODESCRIPT
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
bool
A mark is stamped on bars where this is true (≠0/na).
style
string
Optional. Mark shape (e.g. circle/triangleup/triangledown/arrowup/arrowdown/square/diamond; default circle).
location
string
Optional. Location: abovebar/belowbar/top/bottom (default abovebar).
color
color
Optional. Mark color (default #2962ff).
text
string
Optional. Short text next to the mark (e.g. AL/SAT).
size
string
Optional. tiny/small/normal/large/huge or a number (pixels, 7-40). Default normal.
NOTE

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.

CODESCRIPT
mark(crossover(close, sma(close,20)), "triangleup", "belowbar", "#26a69a", "AL")

Green up-triangle with 'AL' text below the bar where price crosses above SMA20.

CODESCRIPT
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.

series
series
The series to draw on the chart.
title
string
Optional. Label for the line.
color
color
Optional. Hex color (e.g. "#26a69a").
pane
string
Optional. The target pane. If omitted, it is chosen automatically based on the value range (the price pane if close to price, otherwise the shared lower pane). Pass a fixed string (e.g. "rsi") to group all plot() calls that use the same string into the same sub-pane.
style
string
Optional. Draw style: line/stepline/histogram/columns/area/circles/cross (default line).
linewidth
number
Optional. Line thickness (1-4).
linestyle
string
Optional. Line dash pattern: solid/dashed/dotted.
NOTE

Colors are hex codes; see the Colors section for ready-made options.

CODESCRIPT
plot(sma(close,20), "SMA20", "#2962ff")

Blue SMA20 line on the price pane.

CODESCRIPT
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.

series
series
Value: >0 draws an up arrow, <0 draws a down arrow, 0/na draws nothing.
title
string
Optional. Label.
colorup
color
Optional. Up arrow color (default green).
colordown
color
Optional. Down arrow color (default red).
offset
number
Optional. Bar shift.
minheight
number
Optional. Shortest arrow in pixels (default 5).
maxheight
number
Optional. Longest arrow in pixels (default 100).
NOTE

The arrow height is proportional to |value| (clipped to minheight..maxheight); it visualizes the magnitude.

CODESCRIPT
plotarrow(close - open)

Up arrow on bullish bars, down arrow on bearish bars; length proportional to body size.

CODESCRIPT
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.

open
series
Open price.
high
series
High price.
low
series
Low price.
close
series
Close price.
title
string
Optional. Label for the series.
color
color
Optional. Hex color (e.g. "#26a69a"). Defaults to a single blue if omitted.
editable
bool
Optional, not yet implemented.
show_last
number
Optional. Draws only the last N bars.
display
string
Optional. Pass "none" to hide.
format
string
Optional, not yet implemented.
precision
number
Optional, not yet implemented.
force_overlay
bool
Optional, not yet implemented.
NOTE

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).

CODESCRIPT
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.

open
series
Candle open series.
high
series
Candle high series.
low
series
Candle low series.
close
series
Candle close series.
title
string
Optional. Label.
color
color
Optional. Body color (can be conditional).
wickcolor
color
Optional. Wick color.
bordercolor
color
Optional. Border color.
editable
bool
Optional. Currently has no effect — accepted but not applied (passing a non-default value prints a one-time warning).
show_last
number
Optional. Draws only the last N candles; earlier ones are hidden.
display
string
Optional. "none" draws no candles at all; "all" (default) draws them. Any other value still draws but prints a warning.
format
string
Optional. Currently has no effect — accepted but not applied (passing a non-default value prints a one-time warning).
precision
number
Optional. Currently has no effect — accepted but not applied (passing a value prints a one-time warning).
force_overlay
bool
Optional. Currently has no effect — accepted but not applied (passing true prints a one-time warning).
NOTE

For drawing your own OHLC (e.g. Heikin-Ashi, rescaled) or conditionally colored candles. The color can be conditioned on a series.

CODESCRIPT
plotcandle(open, high, low, close)

OHLC candles in the default single-blue color.

CODESCRIPT
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.

series
bool
A character is drawn on bars where this is true.
title
string
Optional. Label.
char
string
Single character/glyph to display (default ★).
location
string
abovebar/belowbar/top/bottom/absolute.
color
color
Optional. Color.
offset
number
Optional. Bar shift.
text
string
Optional. Additional text.
textcolor
color
Optional. Text color.
size
string
Optional. tiny/small/normal/large.
NOTE

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.

CODESCRIPT
plotchar(close > open, char="B", location="belowbar", color="#26a69a")

Green 'B' below green (bullish) bars.

CODESCRIPT
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
bool
A shape is drawn on bars where this is true (≠0/na).
title
string
Optional. Label for the shape.
style
string
Shape: arrowup/arrowdown/triangleup/triangledown/circle/square/diamond/cross/xcross/flag/labelup/labeldown (default circle).
location
string
Location: abovebar/belowbar/top/bottom/absolute (default abovebar).
color
color
Optional. Shape color (hex).
offset
number
Optional. Bar shift.
text
string
Optional. Text next to the shape.
textcolor
color
Optional. Text color.
size
string
Optional. tiny/small/normal/large.
NOTE

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).

TIP

If you need several marks on the same bar, use different location values (abovebar/belowbar) to keep them from overlapping.

CODESCRIPT
plotshape(crossover(close, sma(close,10)), style="triangleup", location="belowbar", color="#26a69a")

Green up-triangle below the bar on SMA10 cross-above bars.

CODESCRIPT
plotshape(rsi(close,14) > 70, style="arrowdown", location="abovebar", color="#ef5350", size="small")

Small red down-arrow above the bar on RSI>70 bars.

red(renk)

Returns the color's red channel as a number 0-255 (invalid color → 0).

renk
color
The hex color (#rgb / #rrggbb / #rrggbbaa) whose red channel is read.
NOTE

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.

CODESCRIPT
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).

rgb(r, g, b, opaklik?)

Returns a hex color string in #rrggbbaa form (opacity is mapped to a 0-255 alpha byte).

r
number
Red channel 0-255 (out-of-range values are clamped and rounded to integer).
g
number
Green channel 0-255.
b
number
Blue channel 0-255.
opaklik
number
Optional. Opacity 0-1 (0=fully transparent, 1=fully opaque; default 1).
NOTE

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.

CODESCRIPT
bgcolor(rgb(38, 166, 154, 0.15))

A 15%-opacity green (#26a69a26) background applied to all bars.

CODESCRIPT
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.)