System
14 entries. What each one takes, what it returns, and a working example.
For drawing in keeping with the theme — so your added layers color consistently with the background.
if barstate.islast { label(close, chartBgColor(), barIndex) } plot(close)
Writes the background color onto the last bar as a label.
For keeping label/text color consistent with the theme.
if barstate.islast { label(close, chartFgColor(), barIndex) } plot(close)
Writes the foreground color onto the last bar as a label.
A gate for logic that branches on bar type; the value is constant because CodeScript produces standard bars.
plot(chartIsStandard() ? 1 : 0, "Standart mı")
Plots a constant 1 on a standard chart.
For anchoring on the left edge of the visible window; as a reference when positioning along the time axis.
plot(chartLeftVisibleBarTime())
Plots the first bar's timestamp as a flat line.
For anchoring on the right edge of the visible window (the most recent bar).
plot(chartRightVisibleBarTime())
Plots the last bar's timestamp as a flat line.
Does not return a value; appends the message to the run log as an error (does NOT stop the script).
Does not halt execution — use runtimeError if you want to stop. For leaving a durable trace of an unexpected condition in the log.
if close <= 0 { logError("gecersiz fiyat") } plot(close)
Had price been zero/negative an error line would be logged; on normal data it is not triggered.
Does not return a value; appends the message to the run log as info.
Does not stop the script. For tracing intermediate values or which branch ran — the output collects in a separate log list.
if barstate.islast { logInfo("tarama tamamlandi") } plot(close)
Adds an info line to the log on the last bar; the plot is unaffected.
Does not return a value; appends the message to the run log as a warning.
Does not stop the script; flags a non-fatal situation that deserves a touch more attention than info.
if rsi(close, 14) > 70 { logWarning("asiri alim bolgesi") } plot(close)
Adds a warning to the log on bars where RSI rises above 70.
Does not return a value; stops the script and reports the given message as an error.
Halts execution the moment it is called. To report a broken assumption (an invalid parameter, an unexpected state) early and clearly — guard it behind a condition so it only fires on the bad case.
if close < 0 { runtimeError("fiyat negatif olamaz") } plot(close)
Had price been negative the script would stop; on normal data the condition is not met and price is plotted.
The CLOSE time (epoch milliseconds) of the current bar.
`time()` gives the bar's OPEN time, `time_close()` gives its close (open + bar duration). The result does not depend on exchange timezone — it's based purely on UTC bar boundaries.
plot(time_close(""))
Plots each bar's close time (epoch ms).
A boolean series: true on the bar that OPENS a new bucket of the given timeframe, false otherwise.
The first bar is always false (there is nothing before it). For an unrecognized timeframe the whole series is false.
plotshape(timeframeChange("1D"), "Yeni gün")
Places a mark on the first bar of each new day.
plot(timeframeChange("1W") ? high : na, "Hafta başı")
Plots the high on the first bar of a new week, empty (na) otherwise.
Converts seconds into a compact timeframe string (e.g. 3600 → "1h", 86400 → "1D"). Zero/negative or non-number → an empty string.
The inverse of timeframeInSeconds; it picks the largest evenly-dividing unit (week > day > hour > minute).
label(close, timeframeFromSeconds(3600))
Labels "1h" (3600 seconds = 1 hour).
label(close, timeframeFromSeconds(86400))
Labels "1D" (86400 seconds = 1 day).
Returns the timeframe's length in seconds (e.g. "1h" → 3600). na for an unrecognized timeframe.
Converts a timeframe string into a numeric length; useful in scaling or comparisons.
plot(timeframeInSeconds("1h"), "Saniye")
Plots a constant 3600 (1 hour = 3600 seconds).
plot(timeframeInSeconds("1D") / 3600, "Günde kaç saat")
Plots a constant 24 (hours in a day).
timestamp(yıl, ay, gün, saat, dakika, saniye)
The epoch timestamp (milliseconds, UTC) built from the calendar parts.
The conversion is plain UTC — exchange timezone/DST is not involved (that only applies to READ variables like `hour`/`minute`/`year`). Arguments may be constants or series (e.g. `year`, `month`); if a series is given, the result is also computed bar-by-bar.
plot(timestamp(2024, 1, 1, 0, 0, 0))
Plots the epoch millisecond value of 2024-01-01 00:00:00 UTC.