# Strategy templates

> The built-in WickScript examples – an EMA cross indicator, an EMA cross strategy and a breakout strategy with partial exit and trailing stop – with their full source and how to start from them.

Updated: 2026-10-25T01:50:47.000Z · https://chartrider.com/docs/strategies/templates/

ChartRider comes with three WickScript examples to start from: an indicator and two strategies. They show the typical building blocks – inputs, lines and marks, entries with stop and target, exits, partial exits and a trailing stop – in a few readable lines.

## Where to find them

1. Make a strategy active in the Strategies panel (`F6`).
2. Open the **Scripts** tab of the [Strategy Lab](https://chartrider.com/docs/strategies/strategy-lab/).
3. Under **New script**, open **Choose a template…** and pick one:
   - **EMA cross (example)** – an indicator that marks crosses of two EMAs.
   - **EMA cross strategy (example)** – a strategy that trades those crosses in both directions with a fixed 2 R target.
   - **Breakout with partial exit and trailing (example)** – a long-only breakout strategy that takes half off at 1 R and trails the rest.

The same list also offers **Blank** and the standard indicators (SMA, EMA, RSI, MACD, ATR, VWAP and more, marked **(standard)**) as scripts you can read and change.

The template is added to the active strategy as a new script. Change it in the editor and press **Apply** (or `Ctrl` / `⌘` + `Enter`) to run it on the chart. A strategy template starts trading only once you click **Trade with this script**; then `F5` and [Run strategy](https://chartrider.com/docs/strategies/run-strategy/) use it. The Scripts tab needs WickScript, which you unlock by inviting friends – see [Account](https://chartrider.com/docs/account/).

The inputs of each template (**Fast** and **Slow** for the EMA lengths, **Range** for the breakout) become settings of the script, so you can vary them with Step 1 and Step 2 and compare the results in the heatmap.

The templates are examples of the language, not recommendations to trade. Test any change with the [backtest engine](https://chartrider.com/docs/strategies/backtest-engine/) before you rely on it. The language itself is described in [WickScript](https://chartrider.com/docs/wickscript/) and [Writing strategies in WickScript](https://chartrider.com/docs/wickscript/strategies/).

## EMA cross (indicator)

Two exponential moving averages with adjustable lengths and a mark below the candle where the fast one crosses above the slow one. A good first indicator to change and re-apply.

```wickscript
wickscript 1
indicator "My script" on chart
# two moving averages and a mark where they cross
fast = ema(close, input 9 "Fast")
slow = ema(close, input 21 "Slow")
show fast as line "Fast" color amber
show slow as line "Slow" color blue
when fast crosses above slow
mark "▲" below color green
end
```

## EMA cross strategy

Trades both directions: long when the fast EMA crosses above the slow one, short on the opposite cross. The stop sits two ticks beyond the extreme of the last 10 candles, the target at 2R, and each trade risks 1 % of the account.

```wickscript
wickscript 1
strategy "EMA cross" risk 1%
# long when the fast EMA crosses above the slow one, short the other way
fast = ema(close, input 9 "Fast")
slow = ema(close, input 21 "Slow")
show fast as line "Fast" color amber
show slow as line "Slow" color blue
when fast crosses above slow
tag "cross long"
enter long at market
stop at lowest(low, 10) - 2 * tick
target at 2R
end
when fast crosses below slow
tag "cross short"
enter short at market
stop at highest(high, 10) + 2 * tick
target at 2R
end
```

## Breakout with partial exit and trailing

Buys the break of the recent high with a stop entry (valid for 5 candles) once the close crosses above the 50 EMA. Half of the position is taken off at 1R, the stop moves to entry after 1R and trails at 2 × ATR(14) after 1.5R; the rest targets 4R, and trades still open after 100 candles are closed.

```wickscript
wickscript 1
strategy "Breakout" risk 1%
# buy the break of the recent high, take half at 1R, then let the rest run
len = input 20 "Range"
top = highest(high, len)
bottom = lowest(low, len)
show top as line "Top" color green
show bottom as line "Bottom" color red
when close crosses above ema(close, 50) and not position.open
tag "breakout"
enter long at stop top + 2 * tick valid 5 bars
stop at bottom
exit half at 1R
move stop to entry after 1R
trail stop by 2 * atr(14) after 1.5R
target at 4R
end
exit long when bars since entry >= 100 bars
```
