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.
1
algobarsx 12
strategy "Cheat Sheet" # or: indicator, alert, library3
market: EURUSD # several: markets: EURUSD, GBPUSD4
bars: 15m # 1m 5m 1h 4h 1d, or renko(5), xray(20)5
max_open: 16
max_daily_loss: 3%7
8
input length = 20, min: 5, max: 200 # a setting in the panel9
const BUFFER = 2 pips # fixed value10
state wins = 0 # survives between bars11
12
fast = ema(close, length) # worked out again on every bar13
prev_close = close[1] # history: one bar back14
h4 = bars(bars: 4h) # another bar size, closed candles only15
uptrend = h4.close > ema(h4.close, 50)16
17
confirmations setup: # named conditions18
trend: uptrend19
momentum: rsi(close, 14) between 50 and 7020
require: all21
22
when setup.passed and crosses_above(close, fast) max 2 per day cooldown 30m:23
buy risk: 1%, stop: low - BUFFER, target: 2R:24
breakeven at: 1R25
partial 50% at: 1.5R26
trail by: atr(14) * 2, after: 1.5R27
28
when crosses_below(close, fast):29
close_all30
31
on exit(trade):32
if trade.r > 0:33
wins += 134
log "{trade.tag} closed at {trade.r:0.00}R, {wins} wins so far"35
36
plot fast, color: if uptrend then green else redFor the long version, see the Language Tour example, which uses nearly every construct in the language.