×

Sign up and get MultiCharts free

Use its powerful simulation mode with data included out of the box. Just fill out the form and start honing your trading skills with a few clicks.

Changes - MultiCharts
Open main menu

Changes

Once per bar alert

892 bytes added, 12:27, 10 February 2012
no edit summary
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]]