Skip to content
ChartRiderDocs
Docs/WickScript/Writing indicators in WickScript
WickScript WickScript

Writing indicators in WickScript

How WickScript indicators draw in the price chart or their own panel, how outputs become Trade Setup lines, how inputs become settings and Step 1 / Step 2 parameters, and how to reuse built-in indicators.

Updated ·Markdown

An indicator script calculates values for every candle and draws them. This page covers what is specific to indicators; the syntax itself is in the Language guide.

Price chart or own panel

The head line decides where the whole script draws:

indicator "Name" on chart     # in the price chart, on the price scale (also the default without on chart)
indicator "Name" in pane      # in its own panel below the chart, with a Height setting

A script draws either entirely in the price chart or entirely in its own panel. Values that are not prices – RSI, volume, delta, a count – belong in a panel: if you show one in an on chart script, the checker warns and offers to change the head line to in pane. show … in pane on a single output of a chart script is a warning for the same reason. Levels always draw in the price chart.

WickScript
wickscript 1
indicator "RSI with levels" in pane
period = input 14 "Period" from 2 to 50
r = rsi(close, period)
show r as line "RSI" color violet
show 70 as line "Overbought" color red
show 30 as line "Oversold" color green
show r crosses below 30 as event "Into oversold"

How outputs are drawn:

OutputPrice chartOwn panel
show … as lineline on the price scaleline on the panel's scale
show … as histogrambarsbars around a zero line
show … as eventdot where the condition is truedot where the condition is true
marktext above the high or below the low–
levelhorizontal line until killed, expired or ended–

Outputs

Every show creates a named output:

  • The legend shows all outputs of the script with their values at the crosshair (events as yes/no).
  • In the Trade Setup, each output is a line you can use for entry gates, filters, exits, stop-loss and take-profit. It is listed with the script's tech name, for example WS1 · Fast for the output "Fast" of the first WickScript indicator.
  • A strategy script can read the outputs with use WS1 as ws and ws.Fast or ws["Fast"] (see Strategies).

Output names must be unique within a script. A candle on which the value is na shows nothing, which you can use to draw a line only on some candles:

WickScript
wickscript 1
indicator "Inside bars" on chart
inside = high < high[1] and low > low[1]
motherHigh = na
motherLow = na
if inside then
    motherHigh = high[1]
    motherLow = low[1]
end
show motherHigh as line "Mother high" color green
show motherLow as line "Mother low" color red
when inside
    mark "IB" above color gray
end

Inputs become settings

Every input becomes a field in the indicator's settings, in the section "Inputs". Changing a value there recalculates the script without touching the code.

InputSettings field
input 14 "Period"number field (whole numbers only when the default and the step are whole)
input 0.3% "Buffer", input 2R "Target", input 5 bars "Wait"number field, the value keeps its unit
input "day" "Anchor"text field
input choice "Mode" of ["wick", "close"]drop-down list
input true "Show bands"checkbox
input color amber "Color"color picker
input timeframe 4h "Higher timeframe"drop-down list with 1m, 5m, 15m, 1h, 4h, 1d, 1w

The field ID is the variable name (period for period = input 14 "Period"); an input written inside an expression gets its ID from the label. When you edit and apply the script, inputs that keep their name and kind keep their values.

Step 1 / Step 2. Number inputs can be chosen as Step 1 or Step 2 parameters in the strategy panel: the backtest runs once for each combination of values and shows the results as a heatmap (Step 1 in the columns, Step 2 in the rows). When an input has from … to … step and that gives between 2 and 25 values, the range is suggested for the stepper.

WickScript
wickscript 1
indicator "Keltner channel" on chart
length = input 20 "Length" from 10 to 50 step 10
mult = input 2 "ATR multiple" from 1 to 3 step 0.5
tone = input color teal "Color"
basis = ema(close, length)
show basis as line "Basis" color tone
show basis + mult * atr(length) as line "Upper" color tone
show basis - mult * atr(length) as line "Lower" color tone

Marks, levels, HUD lines and alerts

Indicators can also write marks at candles, draw levels with a lifecycle, add lines to the HUD and raise alerts. The full syntax of mark, level, hud, alert and log is in the Language guide.

WickScript
wickscript 1
indicator "Volume spikes" on chart
avg = sma(volume, input 20 "Average length")
spike = volume > 3 * avg
when spike
    mark "VOL" above color amber
    level close "Spike close" color amber until killed or 50 bars
    alert "Volume spike"
end
hud "Volume {volume / avg} × average · last spike {bars since spike} bars ago"

Reusing ChartRider indicators: use indicator

use indicator "Name" [with setting value, setting value …] as alias

use indicator creates any indicator from the indicator list (F3), calculates it on the script's candles and gives you its outputs:

  • Name: the indicator's name, short name or class name, ignoring upper/lower case and special characters ("RSI", "MACD", "VWAP", "Relative Strength").
  • Settings: by setting ID or label, separated by commas; values are fixed values or inputs. Settings you don't mention keep their defaults. The settings of each built-in indicator are listed on its page under Indicators.
  • Outputs: alias.value is the main line; other outputs by name, e.g. alias.signal or alias["histogram"]. Names ignore case and special characters.
  • Values are aligned to the candles the same way as indicators in a strategy: the value at each candle's close.
  • It works in the chart, in strategies and in the Strategy Lab. An unknown name or setting shows a message with suggestions in the Scripts tab, and the outputs stay na.
  • Outputs of other indicators have no unit, so the checker can't check how you combine them.
WickScript
wickscript 1
indicator "MACD from the list" in pane
fast = input 8 "Fast"
use indicator "MACD" with fastPeriod fast, slowPeriod 21 as m
use indicator "RSI" with period 21 as r
show m.histogram as histogram "MACD histogram"
show m.histogram crosses above 0 and r.value > 50 as event "Momentum up"

In strategy scripts, use <TechName> as x reads an indicator that is already part of the strategy instead (for example use RSI1 as r); see Strategies.

The standard indicators as WickScript

ChartRider's standard indicators are also available as WickScripts. In Scripts → New script they appear as templates named like "RSI (standard)": a good starting point for your own variant. They calculate the same values as the built-in indicators, and their inputs have the same IDs and defaults.

TemplateHead lineInputs
SMAindicator "Simple Moving Average" on chartperiod 21
EMAindicator "Exponential Moving Average" on chartperiod 21
DEMAindicator "Double Exponential Moving Average" on chartperiod 9
VWAPindicator "VWAP" on chartvwapUnit (choice), vwapUnitAmount 1
VOLindicator "Volume" in pane–
RSIindicator "Relative Strength Index" in paneperiod 14
MACDindicator "MACD" in panefastPeriod 12, slowPeriod 26, signalPeriod 9
ATRindicator "Average True Range" in paneperiod 14
Stochindicator "Stochastic" in paneperiod 9, periodSmooth 1, periodD 3
StochDindicator "Stochastic %D" in paneperiod 9, periodSmooth 1, periodD 3
SMIindicator "Stochastic Momentum Index" in paneperiod 10
MFIindicator "Money Flow Index" in paneperiod 14
OBVindicator "On-Balance Volume" in pane–
CHOPindicator "Choppiness Index" in paneperiod 14

Some of them in full:

WickScript
wickscript 1
indicator "Relative Strength Index" in pane
period = input 14 "Period" from 2 to 500
show rsi(close, period) as line "RSI" color violet
WickScript
wickscript 1
indicator "MACD" in pane
fastPeriod = input 12 "Fast period" from 1 to 500
slowPeriod = input 26 "Slow period" from 1 to 1000
signalPeriod = input 9 "Signal period" from 1 to 500
m = macd(close, fastPeriod, slowPeriod, signalPeriod)
show m.line as line "MACD" color blue
show m.signal as line "Signal" color amber
show m.histogram as histogram "Histogram"
WickScript
wickscript 1
indicator "Stochastic" in pane
period = input 9 "%K period" from 1 to 500
periodSmooth = input 1 "%K smoothing" from 1 to 100
periodD = input 3 "%D period" from 1 to 100
s = stoch(period, periodSmooth, periodD)
show s.k as line "%K" color blue
show s.d as line "%D" color amber
WickScript
wickscript 1
indicator "Stochastic Momentum Index" in pane
period = input 10 "Period" from 2 to 500
# high and low of the previous candles (without the current one), distance to the middle relative to the whole range
hh = highest(high, period)[1]
ll = lowest(low, period)[1]
show 100 * ((close - (hh + ll) / 2) / (hh - ll)) as line "SMI" color violet
WickScript
wickscript 1
indicator "VWAP" on chart
vwapUnit = input choice "Anchor" of ["day", "week", "month", "hour", "minute", "session"]
vwapUnitAmount = input 1 "Anchor amount" from 1 to 100
show vwap(vwapUnit, vwapUnitAmount) as line "VWAP" color violet

More examples

Bollinger Bands from a moving average and the standard deviation:

WickScript
wickscript 1
indicator "Bollinger Bands" on chart
length = input 20 "Length" from 5 to 100 step 5
mult = input 2 "Deviations" from 1 to 3 step 0.5
basis = sma(close, length)
dev = mult * stdev(close, length)
show basis as line "Basis" color amber
show basis + dev as line "Upper" color blue
show basis - dev as line "Lower" color blue
show close crosses above basis + dev as event "Break up"

Previous day's high and low from the daily timeframe (on 1d always uses the last closed daily candle):

WickScript
wickscript 1
indicator "Previous day high and low" on chart
pdh = high on 1d
pdl = low on 1d
show pdh as line "PDH" color green
show pdl as line "PDL" color red
when high > pdh
    mark "PDH swept" above color orange
end

A cumulative delta panel from the tick data (see Data):

WickScript
wickscript 1
indicator "Delta and CVD" in pane
show delta as histogram "Delta"
show cvd - ema(cvd, 50) as line "CVD vs. its EMA" color cyan

Generated from the ChartRider source code on every release – settings, outputs and the WickScript reference always match the app.

Imprint·Privacy·Contact·Changelog·llms-full.txt

Paper trading uses play money only. Nothing in these docs is investment advice.