Alert ( String sound);
Shows an alert message with the
text and plays the
sound when the
true. Note that you can create studies containing only alert function call without defining any plots.
|condition||-||Defines condition upon which the alert is displayed.|
|text||-||Defines text of the alert message.|
|alert type||Alert.ONCE||Defines periodicity with which the alert is shown. This parameter accepts Alert constants as value.|
|sound||Sound.NoSound||Defines the alert sound. This parameter accepts Sound constants as value.|
Alert(Crosses(close, Average(close, 15), CrossingDirection.ABOVE), "Closing price crosses over SMA!");
This alert is triggered on the first cross of the Close price over the SMA with the length equal to 15. It can be triggered only once and does not play any sound, because it uses default values
Sound.NoSound for the alert type and sound.
def condition = Crosses(Average(close, 15), Average(close, 30), CrossingDirection.ABOVE);
Alert(condition, "Bullish!", Alert.BAR);
This alert is triggered when the fast average crosses the slow average and shows the corresponding text message. It can be triggered once per bar and does not play any sound, because it uses
Alert.BAR value for the alert type and default
Sound.NoSound value for the sound.
Alert(close >= 100 and close < 200, "100 <= Tick < 200!", Alert.TICK, Sound.Ding);
Alert(close >= 200, "Tick > 200!", Alert.TICK, Sound.Chimes);
First alert is triggered for each tick greater than 100, but less than 200 and the second alert - for each tick greater than 200. Both alerts also display a text and play sound other than default.