Rules: when something is true, do something

The when rule and its timing modifiers.

A rule is when <condition> [modifiers]: followed by what to do. Name a rule with as to read its counters later, such as long_entry.triggers.

AlgoBarsX
when long_setup.passed as long_entry every 4th:
buy risk: risk, stop: atr(14) * 1.5, target: 3R
when starts(long_setup.passed) skip first 3 max 2 per day cooldown 30m:
triggers += 1
if triggers % 4 == 0:
buy risk: 0.5%, stop: atr(14) * 1.5, target: 3R

Modifiers say when a rule may fire, on the rule itself, so there are no counters to build by hand:

ModifierWhat it does
every <ordinal> | every barAct on every Nth trigger, or count every bar the condition holds.
skip first <n>Ignore the first N triggers, then act on every trigger.
max <n> per <period>Cap actions per day, session, hour or week.
cooldown <duration | n bars>Ignore triggers for a while after acting.
once per barIn tick mode, act at most once per bar.
within sessions <name>, ...Only trigger inside the named sessions.
from <time> to <time> [zone]Only trigger inside a daily time window.

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

Create my free account