Real-Life Messaging Solutions

From Triage Documentation

Jump to: navigation, search

Contents

Multiple Messaging Services and Destinations

You can list multiple services and destinations in your <message service> and <message destination> parameters.

For example, if you wanted to list your yahoo instant messenger, your phone number and your mobile phone as destinations, all you have to do is separate the service by the use of commas— "yahoo,phone,sms". And to do more than one destination you can separate your destinations by the use of commas—"14152228989, 14158882332, 18003492912" or "yahoouser1,yahoouser2,yahoouser3".

For multiple destinations with more than one service, you can write your destination parameter as a multiple service string such as: "email=abc@email.com,xzy@abc.com; yahoo=yahoouser1,yahoouser2;phone=14158881234"

Vars:      ret (0),
           services ("yahoo,phone,email"),
           dest ("email=nbc@abc.com,xzy@abc.com;yahoo=yahoouser1,yahoouser2;phone=14158881234");
           ret = $TriageMsg (services, dest, "Send message for a small inside day", "once");

You will be able to send a single message to as many services and destinations as you want using a message function call.

Condition and event triggers

It is important that you carefully consider what conditions and events will trigger your messages. Custom EasyLanguage programs that you write for TradeStation will loop in real-time and run your code hundreds of times a minute if you do not specify conditions and events to limit when messages are sent. The following are some code snippets that demonstrate ways to control your message sending.

Vars:   ret (0);

If High < High [1] and Low > Low [1] and Range < 0.7 * Average (Range, 3) then
   ret = $TriageMsg ("phone", "14155557777", "Send message for a small inside day", "now");

If RSI (Close,5) Crosses Over RSI (Close, 14) and RSI (Close, 5) < 50 then
   ret = $TriageMsg ("phone", "14155557777", "Send message when RSI crosses over", "now");

If barstatus(1) = 2 then
   ret = $TriageMsg ("phone", "14155557777", "Send message at end of bar", "now");

If LastBarOnChart then
   ret = $TriageMsg ("phone", "14155557777", "Send message on last bar on chart", "now");

If GetAppInfo (aiRealTimeCalc) = 1 then
   ret = $TriageMsg ("phone", "14155557777", "Send message only with real-time data", "now");

If Date=CurrentDate and Time > 1500 then
   ret = $TriageMsg ("phone", "14155557777", "Send message after 3PM today on chart", "now");

You may also create one-time or one-time-until-reset triggers to control how many times a message is sent per event. The following is a code snippet that will send a message once per day when triggered. On the next day, the trigger flag is reset and the condition can once again trigger a message send.

Vars:       Triggered (FALSE), MyCondition (FALSE), ret (0);

MyCondition = High > HighD (1);                      // Current high is greater than yesterday’s high

If Triggered = FALSE and MyCondition then
   Begin
        ret = $TriageMsg ("phone", "14155557777", "Breakout of previous day’s high", "now");
        Triggered = TRUE;
   End;

If Date <> Date [1] then Triggered = FALSE;    // Reset trigger on next trading data

Like most traders, you will likely use a combination of conditions to ensure you get only the messages you need, and not fill up your messaging services with unnecessary messages. A realistic example of such code is shown below.

Vars:   InsideDayPattern (FALSE), RSIBottom (FALSE), Triggered (FALSE), ret (0);

InsideDayPattern = High < High [1] and Low > Low [1] and Range < 0.7 * Average (Range, 3);

// My special inside day pattern
RSIBottom = RSI (Close, 5) Crosses Over RSI (Close, 14) and RSI (Close, 5) < 50;

// My special RSI bottom pattern

If Triggered = FALSE and barstatus(1) = 2 and LastBarOnChart and GetAppInfo (aiRealTimeCalc) = 1 and Date=CurrentDate and Time > 1030 and Time < 1550 then
   Begin
        ret = $TriageMsg ("phone", "14155557777", "My pattern triggered after 10:30", "now");
        Triggered  = TRUE;
   End;

If RSI (Close, 5) > 80 or RSI (Close, 5) < 10 Then
   Triggered = FALSE;		// Reset send message trigger if RSI is overbought or oversold

Historical bars, last bar on chart and real-time

In TradeStation, EasyLanguage code is applied to all time series of a chart, and for the entire look back period of a radarscreen\’s additional bars loaded. Most of the time, traders issue messages only for real-time trading events, and not during historical time-series execution of their EasyLanguage code.

Using LastBarOnChart and GetAppInfo (aiRealTimeCalc) = 1 will prevent the execution of your messaging code on historical bars.

However, if you desire to send messages regarding your historical bars, you can use $TriageMsg with the "all" message condition parameter to send messages across ALL historical bars without any time or date restrictions.

Please use the historical bar messaging sparingly. Not only will sending so many messages slow down your TradeStation program, but it can slow or lock up your operating system if you have limited memory and CPU resources.

We recommend that you send historical bar messages to a text file rather than to the Triage Messaging live service. If you want to send historical bar messages and need further assistance or support code, then please contact us.

Intra-bar versus end-of-bar messages

Depending on how you set the bar or tick resolution of your indicators and strategies, your EasyLanguage may evaluate your code each tick, or before a time-series bar ends. Often, this is not desired by traders who don’t need a message every tick, but need their code to evaluate each tick.

Using the barstatus function ensures you only send messages at the beginning or end of a bar.

If barstatus(1) = 0 then		// Send on the first tick of the bar
   $TriageMsg ("phone", "14155557777", "Send message at beginning of the bar", "now");

If barstatus(1) = 2 then		// Send on the last tick of the bar
   $TriageMsg ("phone", "14155557777", "Send message at end of the bar", "now");

If barstatus(1) = 1 then		// Send on any tick within bar – warning: could be many messages
   $TriageMsg ("phone", "14155557777", "Send message at middle of the bar", "now");

How to control the sending of messages for a long list of events?

If you want to test a long list of trading events, then you can evaluate conditions in an array. Loop through the array, storing each event in a message string until you are ready to send your message out.

// Send a message showing if a list of events have triggered

Inputs: Service ("phone"), Destination ("1415555777");
Vars: Count (0), Message (""), ret (0);
Array: Events [5] (""), EventTrigger [5] (FALSE); 

Once (CurrentBar = 1)                         // Set list of event names
	Begin
		Events [1] = "Inside Bar";
		Events [2] = "Outside Bar";
		Events [3] = "Higher High Bar";
		Events [4] = "Lower Low Bar";
		Events [5] = "Higher Open of Bar";
	End; 

// Evaluate list of events
EventTrigger [1] = High < High [1] and Low > Low [1];
EventTrigger [2] = High > High [1] and Low < Low [1];
EventTrigger [3] = High > High [1];
EventTrigger [4] = Low < Low [1];
EventTrigger [5] = Open > Open [1];
Message = "";

For Count = 1 to 5 
	Begin
		If EventTrigger[Count] Then                    // If event is true, add it to message string
			Message = Message + Events [1] + " - ";
	End;

If Message <> "" then                                     // send event message every 15 minutes
   Begin                
	ret = $TriageMsg (Service, Destination, "Events Triggered: "+Message, "next=00:15:00");   
	if ret = 1 then	Message = "";       // reset the message if the send was successful
   End;

How to send prices every hour if my strategy has a market position?

Sending strategy status to yourself every hour is easy to do with the $TriageMsg function. Just add the function to a strategy. Specify inputs for service, destination, message, price and interval.

// Send a price quote for symbol each hour through multiple messaging services

Inputs: Services ("yahoo, phone, email"), 
        Destinations ("yahoo=yahoousername;phone=14155558888;email=me@email.com;"),
        Message ("My strategy position is: "), 
        PriceOutput (Close), 
        TimeInterval ("01:00:00"); 	// Change this interval to any that you like in hh:mm:ss format

If MarketPosition <> 0 THEN                     // if system is not flat
   ret = $TriageMsg ( Services, Destinations, NumToStr (Time,0) + ":" + Message + MarketPosition + " " + GetSymbolName + NumToStr (EntryPrice,4), "next="+TimeInterval );

Personal tools
Navigation