Studies – test an assumption before you build a strategy
WickScript studies count how often something happens after a condition – with a control at other times, 95 % intervals, buckets, steps and runs over all markets – without a trade setup. Strategy Lab → Stats.
A study answers one question: how often does something happen after a condition? “Does London take the Asian range?”, “Does a raid of the previous day high close back below it?”, “Is the RSI back above 50 within 20 candles after it dropped below 30?” You write the condition and the expectation in WickScript; ChartRider counts every sample on the chart and over all markets of your watchlist – no entries, stops or targets needed. It is the step between looking at an indicator by hand and a strategy you can backtest.
wickscript 1
study "London takes the Asian range"
use indicator "Session Times" as st
when in killzone London
expect "Takes the Asian high or low" high > st.ash or low < st.asl until not in killzone London
expect "Asian high goes first" high > st.ash before low < st.asl until nyHour >= 12
bucket nyWeekday
bucket "Asian range" = pct(st.ash[1], st.asl[1]) step 0.5%
endHow a study counts
study "Name"instead ofindicatororstrategyin the second line.- A sample starts each time its
when … endblock runs – here at the first candle of the London killzone, once per day. expect "Name" <condition>looks at the candles after the sample, in a window:within 20 barsorwithin 4h– a fixed number of candles or a time span,until <condition>– up to (not including) the candle where the condition becomes true,- both – whichever ends first.
- What counts as a hit:
expect "…" <condition>– the condition is true in at least one candle of the window,expect "…" never <condition>– in none of them,expect "…" <a> before <b>–ahappens beforeb(both in the same candle = tie, neither = neither; both are shown but not counted),expect "…" <condition> at end– the condition is true in the last candle of the window.
- Only finished windows count. A window that is still open at the end of the data is shown as open and left out, so the newest days don't bend the rate.
Looking ahead is the point of a study – but only inside expect. Studies have no outputs for gates, they can't trade, and indicator and strategy scripts can't use expect.
When does the window start?
If everything the sample depends on is known when its candle opens – the time (in killzone London, nyHour == 8), inputs, or values of earlier candles (close[1], atr(14)[1]) – the window includes that candle. Otherwise (the condition reads this candle's close, high, an indicator value …) the window starts with the next candle, because the sample is only known at the close.
For samples that start with their own candle, a bucket can't read that candle yet: write atr(14)[1] instead of atr(14). The checker tells you.
The control: is it the condition, or just the market?
A rate alone says little: London takes the Asian range in about three of four days – but so does almost any three-hour window. Each sample therefore also runs the same test, with the same window length, shifted by 3, 6, 9 … 21 hours (seven control windows per sample). The control rate is how often the test holds anyway.
- Δ is the rate minus the control rate, in percentage points.
- ● means the 95 % interval of the rate excludes the control rate (from 30 samples on).
study "Name" control 1hshifts by 1, 2 … 23 hours,control 1duses the same time the next day,control noneswitches it off.
Buckets
bucket groups the samples of its when block by a value at the sample:
bucket nyWeekday,bucket session,bucket killzone– text, one row per value,bucket close > ema(close, 50)– yes / no,bucket rsi(close, 14) step 10– numbers in steps (stepin the unit of the value:step 0.5%,step price(10)),bucket rsi(close, 14) at 30, 70– numbers split at edges (< 30,30 – 70,≥ 70),bucket "Name" = <value> …gives the bucket a name.
Thin tails of numeric buckets are folded into “< x” and “≥ y” rows.
Steps: one probability per setting
Every input of a study is a step parameter, like in a strategy. Choose it as Step 1 (and Step 2) in the Strategies panel and press Run in the Stats tab: each value becomes one cell in the Steps grid. That gives you a whole curve instead of one number – for example how often London reaches the CBDR ± 0.5, 1, 1.5 … 4 range heights:
wickscript 1
study "CBDR projections"
use indicator "Session Times" as st
mult = input 2 "Range multiple" from 0.5 to 4 step 0.5
size = st.cbh - st.cbl
when in killzone London
expect "Reaches CBDR ± multiple" high >= st.cbh + mult * size or low <= st.cbl - mult * size until nyHour >= 12
endClick a cell to show cards, buckets, markets, months and samples for that value.
Strategy Lab → Stats
Open Strategies (F6) → Strategy Lab → Stats.
- New study from template adds a study to the active strategy: London and the Asian range, Judas swing, New York continues London, previous day high / low raids, CBDR projections, lunch raid, the 08:30 first move and an RSI example. Edit script opens it in Scripts.
- This chart shows the study on the candles of the chart, right away.
- Run on N markets runs it on every market of the watchlist with the range, date windows and steps of the panel – in your browser. + 50 live perps fills the watchlist with the 50 perpetual futures of the market overview. All markets then shows the run: one card per expectation, the buckets, every market, the steps grid, every month and every date window, and the newest samples.
- Samples: click one to jump to its candle on the chart. On the chart, the study marks every sample with ✓ (hit) or ✗ (miss) and shows the rates in the HUD.
Many buckets and markets mean many comparisons – among dozens of rows a single ● can be luck. Look for effects that hold across markets, months and date windows (blind test with a turning point, see Strategy Lab), then turn them into a strategy.
Values that belong to the sample
Conditions in expect are evaluated candle by candle. To compare with a value from the sample, keep it: keep ref = na at the top, ref = close inside the when block – or use close[20] with a fixed window. A plain variable set only inside the block is na on the other candles of the window (the checker warns). If samples overlap, a newer sample overwrites ref while an older window is still open – the study tells you how often that happened.
Time values in New York
ICT times are New York times. Next to hour, minute, weekday and date (UTC) there are nyHour, nyMinute, nyWeekday and nyDate with US daylight saving time; killzone and the Session Times indicator use New York time as well.