Control flow

if, for, match, break and continue.

AlgoBarsX
if regime == Regime.trending:
risk_now = 1%
elif regime == Regime.volatile:
risk_now = 0.5%
else:
risk_now = 0.25%
for level in levels:
if close > level.price:
level.touched += 1
for i in 0..50:
if i > 10:
break
continue
match regime:
Regime.trending: log "trending"
Regime.ranging: log "ranging"
  • if / elif / else choose between blocks.
  • for x in list and for i in 0..50 loop. break and continue work as you expect.
  • match picks a branch by value, which reads well with an enum.

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

Create my free account