EasyLanguage Object Reference

Using Alerts with Drawing Objects

The Alert property of the TrendLine, HorizontalLine, and VerticalLine drawing objects refers to properties of the AlertConfiguration class and related classes that allow you to set an alert for a drawing object and to create custom notification preferences for the alert if you don't want to use the global notification preferences of the TradeStation platform.

The following code enables alerts for a TrendLine drawing object, myTL, using the global notification settings from the TradeStation platform.

myTL.Alert.Enable = True;
myTL.Alert.GlobalNotification = True;  

By default, alerts will be fired continuously if the alert criteria is true. To fire the alert only once per bar use the following:

myTL.Alert.Frequeny = AlertFrequency.OncePerBar;

The Alert property of Trendline and HorizontalLine drawing objects also references a PriceCondition property that lets you set the type of price breakout for alerts. The VerticalLine refers to a similar property to set a time breakout alerts. The following changes the price condition for myTL.

myTL.Alert.PriceCondition = PriceCondition.breakoutintra_interbar;

You can also set up your own notification criteria for this specific alert instance and enable just those options. In the following, a synthesized voice will announce the alert and the TradeStation alert icon will flash at the lower right of your windows screen. You'll also need to disable global notification to allow your custom alert notification criteria to be sent.

myTL.Alert.Notification.AudibleEnable = True;
myTL.Alert.Notification.AudibleConfiguration.Options = AudibleOptions.Voice;
myTL.Alert.Notification.VisualEnable = True;
myTL.Alert.Notification.VisualConfiguration.Options = VisualOptions.flashicon;
myTL.Alert.GlobalNotification = False;

The next bit of sample code associates a event handler method with the Fired event of the Alert property. Whenever the alert condition is met, the alert event will fire and the method will be called. You can then use your own code to determine how to handle the Alert. If you did nothing else, the method will exit without sending any alert notifications. However, setting the args.Trigger flag to true allows notifications to be sent after exiting the method.

myTL.Alert.Fired += GotAlert;

method void GotAlert(elsystem.object sender, elsystem.drawingobjects.AlertEventArgs args ) 
begin
    	{  put your own code her to handle an alert that has fired }
	args.Trigger = True;	// continue processing using your alert notification settings
end;