ALMA Envelope Reversion

ALMA Envelope Reversion is a strategy that trades USDCAD on 15-minute bars. It holds at most 1 open trade.

pending orders

alma-envelope-reversion.abx
1strategy "ALMA Envelope Reversion"
2market: USDCAD
3bars: 15m
4max_open: 1
5
6input envelope_width = 0.4%
7
8env = envelope(alma(close, 21), 21, percent: envelope_width)
9
10when crosses_below(close, env.lower) and cci(hlc3, 20) < -150:
11buy limit: env.lower, risk: 0.5%, stop: env.lower - 1.5 * atr(14), target: env.middle, expires: 4 bars
12
13when crosses_above(close, env.upper) and cci(hlc3, 20) > 150:
14sell limit: env.upper, risk: 0.5%, stop: env.upper + 1.5 * atr(14), target: env.middle, expires: 4 bars
15
16channel upper: env.upper, lower: env.lower
What this script says

ALMA Envelope Reversion is a strategy that trades USDCAD on 15-minute bars. It holds at most 1 open trade.

You can change one input: envelope_width (default 0.4%).

It calculates env as the moving average envelope (source the 21-bar ALMA of the close, length 21, percent envelope_width).

When the close crosses below env.lower and the 20-bar CCI of the typical price is below -150, it buys with a limit order at env.lower, risking 0.5% of the balance, with a stop at env.lower minus 1.5 × the 14-bar ATR, with a target at env.middle and expiring after 4 bars.

When the close crosses above env.upper and the 20-bar CCI of the typical price is above 150, it sells with a limit order at env.upper, risking 0.5% of the balance, with a stop at env.upper plus 1.5 × the 14-bar ATR, with a target at env.middle and expiring after 4 bars.

On the chart, it draws a channel.

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account