The cheat sheet

Most of the language on one screen. It compiles.

One script that touches the header, inputs, constants, state, history, another bar size, confirmations, a rule with timing, a managed order, an event and a plot. Copy it into the Terminal and start deleting what you do not need.

AlgoBarsX
1algobarsx 1
2strategy "Cheat Sheet" # or: indicator, alert, library
3market: EURUSD # several: markets: EURUSD, GBPUSD
4bars: 15m # 1m 5m 1h 4h 1d, or renko(5), xray(20)
5max_open: 1
6max_daily_loss: 3%
7
8input length = 20, min: 5, max: 200 # a setting in the panel
9const BUFFER = 2 pips # fixed value
10state wins = 0 # survives between bars
11
12fast = ema(close, length) # worked out again on every bar
13prev_close = close[1] # history: one bar back
14h4 = bars(bars: 4h) # another bar size, closed candles only
15uptrend = h4.close > ema(h4.close, 50)
16
17confirmations setup: # named conditions
18trend: uptrend
19momentum: rsi(close, 14) between 50 and 70
20require: all
21
22when setup.passed and crosses_above(close, fast) max 2 per day cooldown 30m:
23buy risk: 1%, stop: low - BUFFER, target: 2R:
24breakeven at: 1R
25partial 50% at: 1.5R
26trail by: atr(14) * 2, after: 1.5R
27
28when crosses_below(close, fast):
29close_all
30
31on exit(trade):
32if trade.r > 0:
33wins += 1
34log "{trade.tag} closed at {trade.r:0.00}R, {wins} wins so far"
35
36plot fast, color: if uptrend then green else red

For the long version, see the Language Tour example, which uses nearly every construct in the language.

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

Create my free account