end;
</syntaxhighlight>
== Triggering an alert once per bar - simplified ==
To simplify the triggering of an alert once per bar, and not clutter your code with the code logic from the example above, consider making a function called '''AlertOncePerBar''' (Return type: Numeric, Function Storage: Simple), in which you'll place the following code:
<syntaxhighlight>
{
AlertOncePerBar function; will generate an alert once per bar.
}
Inputs:
AlertText(StringSimple);
Variables:
IntraBarPersist barNumOfAlert(0);
if (CurrentBar <> barNumOfAlert) then begin
Alert(AlertText);
barNumOfAlert = CurrentBar;
end;
AlertOncePerBar = 0; // dummy
</syntaxhighlight>
Now, if you want to call an alert once per bar (for example, with an EMA crossover), you can call that with:
<syntaxhighlight>
if (XAverage(Close, 5) crosses above XAverage(Close, 20)) then
AlertOncePerBar("EMA cross alert");
</syntaxhighlight>
[[Category:About_EasyLanguage]]