Messaging for TradeStation & MultiCharts
From Triage Documentation
Send your first message
It is easy to try out Triage Messaging for the first time. Simply open up a new analysis technique and type in the following code, verify it and add the analysis technique to a chart.
Vars: ret (0); // Generic return variable // Message Function – message type, message destination, message text, message condition ret = $TriageMsg ("email", "email@example.com", "Hello, World!", "Once");
What you have just typed in will send a single test message to your email address, one time only. Don’t forget to change "firstname.lastname@example.org" to your own email address, and turn off test mode from the tray icon to send a live message.
That was easy wasn’t it? You are now one step closer to harnessing the power of universal messaging for your trading.
Try out universal messaging
The example above was simple, but we know you are looking for a little more excitement. You can try sending messages using all the supported messaging services.
Open up a new analysis technique and type in the following code, verify it and add the analysis technique to a chart. Or you can add the $Samp-UMessaging indicator in your EasyLanguage library to any chart.
Remove the lines in the code that do not apply to you. If you do not have a msn messaging account, then remove the line: ret = $TriageMsg ("msn", "email@example.com", "Hello, World!", "Once")';
Vars: ret (0); ret = $TriageMsg ("email", "firstname.lastname@example.org", "Hello, World!", "Once"); ret = $TriageMsg ("sms", "14155550808", "Hello, World!", "Once"); ret = $TriageMsg ("phone", "14155550606", "Hello, World!", "Once"); ret = $TriageMsg ("fax", "14155550303", "Hello, World!", "Once"); ret = $TriageMsg ("yahoo", "myyahoousername", "Hello, World!", "Once"); ret = $TriageMsg ("msn", "email@example.com", "Hello, World!", "Once"); ret = $TriageMsg ("aim", "myAOLusername", "Hello, World!", "Once"); ret = $TriageMsg ("icq", "570102039432", "Hello, World!", "Once"); ret = $TriageMsg ("gtalk", "firstname.lastname@example.org", "Hello, World!", "Once"); ret = $TriageMsg ("twitter", "twitteralias", "Hello, World!", "Once"); ret = $TriageMsg ("facebook", "facebookalias", "Hello, World!", "Once");
Don’t forget to change the red colored destination numbers and addresses in the sample code above to reflect your own phone numbers and accounts. Also, turn off test mode from the tray icon or the messages will not be sent to the live Triage messaging servers.
In the example we just demonstrated, you should have received the message "Hello, World!" from all your chosen messaging services almost simultaneously, and within seconds. With the Triage Messaging service you'll never miss another critical message again wherever you are in the world.
How to Send a Message
Triage Messaging provides a single comprehensive messaging function to help you send messages from your TradeStation or MultiCharts program.
The $TriageMsg EasyLanguage/PowerLanguage function helps you send messages according to your service, destination, message text, interval and time rules. With four simple parameters shown below, you can send messages to any destination in the world from your trading platform: message service, message destination, message text and message condition.
$TriageMsg (message service, message destination, message text, message condition)
Messaging Function Parameters Message Function Parameter Description Message Service Message service type: phone, sms, fax, email, yahoo, msn, aim, icq, gtalk, twitter, facebook Message Destination Destination address or phone number Message Text Text that you want to send out to your destination Message Condition On what event or condition do you want a message sent? Once only, now in real-time, at a time interval, at a specific time, every x bar(s), every x tick(s).
All parameters may be either literal strings or variable strings.
// Literal Strings Vars: ret (0); ret = $TriageMsg ( "yahoo", "yahoousername", "This is my test message", "once" );
// Variable Strings Vars: someservice ("phone"), somedestination ("14155551111"), ret (0); ret = $TriageMsg ( someservice, somedestination, "This is my test message", "once");
During the execution of your trading code, you can set and change these parameters as many times as you wish. We will explain these message function parameters in the following sections.
Message Service Parameter
The first parameter is your <message service> type. Triage Messaging supports the following messaging services: phone, mobile device, instant messengers, e-mail, fax, Twitter™ and Facebook™ accounts (see below).
Messaging Service Parameters Messaging Service Parameter Value Mobile Phone or Device via Short Message (SMS) sms Text-to-Voice Phone Message to any Telephone or Cell Phone phone Text Fax to any Facsimile Device fax E-mail Relay bypassing tradition SMTP and Mail Clients Yahoo Instant Messenger yahoo AOL ("AIM") Instant Messenger aim Microsoft MSN or Live Instant Messenger msn Google Talk Instant Messenger gtalk ICQ Instant Messenger icq Twitter™ Account Facebook™ Account
Message Destination Parameter
The second parameter is your <messaging destination>. Message destinations are the telephone numbers, internet addresses and instant messaging addresses to reach your target recipient (see below). ' You must be precise in specifying your destination addresses. Only alpha-numeric (including @ + - ) characters are allowed. Plus and minus sign (+ and -) characters are optional. Many common user errors occur when the destination is mistyped or misunderstood.
Messaging Destination Parameters Messaging Service Example Destination Mobile Phone or Device via Short Message (SMS) 14155551111 Text-to-Voice Phone Message to any Telephone or Cell Phone +14155552222 Text Fax to any Facsimile Device +1-415-555-3333 E-mail Relay bypassing tradition SMTP and Mail Clients email@example.com Yahoo Instant Messenger yahoousername AOL ("AIM") Instant Messenger AOLusername Microsoft MSN or Live Instant Messenger firstname.lastname@example.org Google Talk Instant Messenger email@example.com ICQ Instant Messenger 570102039432 Twitter™ Account Twitter Alias Facebook™ Account Facebook Alias
Message Text Parameter
The third parameter is your <messaging text>. This text will be sent to your recipient\’s destination address. For SMS and Twitter™ messages, you are limited to 140 characters per message. Phone text-to-voice messages are limited to 250 characters. Facebook™ messages are limited to 420 characters.
Faxes and e-mails are limited to 1,000 characters. Instant messages are limited to the restrictions of the instant messaging service (please check with your instant messenger service for more details). Triage Messaging servers will truncate your message to fit within the requirements of the messaging service you choose. You may specify multiple destinations, but only one text per message instance.
For email messaging sending, you may also use the || separator (two characters) to specify an e-mail title and body. For example, "My email message title || My email message body text".
ret = $TriageMsg ( "msn", "firstname.lastname@example.org, email@example.com", "This is my test message", "once" );
Message Condition Parameter
The fourth parameter is your <messaging condition>. Traders often send price and status information from their indicators and strategies on some specific interval, such as once an hour or once every 500 ticks. We designed a series of messaging conditions that help you control when messages will be sent without writing the complex code yourself. See Figure 4.4a for the list of messaging condition settings available to you.
Messaging Condition Parameters Message Condition Description "all" Send messages in all cases. There are no restrictions, so you can control when your messages are sent out "once" Send message only once "now", "" Send message now in real-time
(e.g. On the last bar on chart and in real-time.) A "" blank condition parameter also defaults to the "now" condition
"next=x" Send message every x time interval e.g. next=01:00:00
(hh:mm:ss, hh:mm or hh format)
"bar=x" Send message every x bars e.g. bar=10 (every 10 bars) "tick=x" Send message every x ticks e.g. tick=25 (every 25 ticks) "time=timestart-timeend" Send message when system time is between timestart and timeend. (Timestart and timeend are in hh:mm:ss, hh:mm or hh format)
For clients who want to control their own message condition logic, please use the "all" parameter. The "all" parameter will tell the Triage Messaging function to send messages in all cases. You will be required to form your own conditions for restricting when a message is sent out from your trading platform.
The "all" parameter is for advanced users who know exactly how to write code that will send messages only on desired trading events. Otherwise, you may overload both the network and your own messaging device with too many messages.
You may use the Triage Messaging conditions in addition to your own messaging sending criteria.
Shown below is a sample of how the messaging conditions are used in context.
Vars: sys_status (0), ret (0); sys_status = absvalue (MarketPosition); // message sent to a phone destination once ret = $TriageMsg ("phone", "14152228888", "Send this message once", "once"); // message sent via SMS in real-time (last bar on chart) each time code runs ret = $TriageMsg ("sms", "14153338888", "Send this message in real-time", "now"); // message sent to MSN instant message account every 10 bars ret = $TriageMsg ("msn", "firstname.lastname@example.org", "Send this message every 10 price bars", "bar=10"); // message sent to Yahoo instant message account every 20 minutes if my system is in a trade If sys_status = 1 Then // my own condition ret = $TriageMsg ("yahoo", "myyahoouser", "Send this message every 20 minutes", "next=00:20:00"); // message sent to e-mail every 300 ticks ret = $TriageMsg ("email", "email@example.com", "Send this message every 300 ticks", "tick=300"); // message sent to gtalk instant message account during time interval 1AM to 2AM ret = $TriageMsg ("gtalk", "firstname.lastname@example.org", "Send this message from 1AM to 2AM", "time=01:00:00-02:00:00"); // Use my own conditions, so set $TriageMsg to accept sending fax messages // at all times without any conditional restrictions. I will set my own conditions. If value1 = value2 + 1 Then ret = $TriageMsg ("fax", "14156662345", "Send this fax message with my own conditions", "all");
Message Function Return Results
The $TriageMsg function will return error values as shown in Figure 4.5a: Messaging Errors. For error values -101 or lower, please contact Triage support and we will be happy to diagnose and troubleshoot the issue with you.
Most traders will get a value of 1 (success) or -100, which means the message condition has not triggered, yet.
Messaging Errors Error Description Return Value Message sent out successfully 1 Internal Error: Triage Messaging seems not to be running. Check tray icon 0 No message sent out -1 One or more parameters are empty (service, destination or text) -2 The message condition has not triggered for this call (not an error) -100 Internal error, report to Triage Trading Support -101 Internal error, report to Triage Trading Support -102 The message condition parameter is incorrect -103 Failed to load TriageMessaging.dll. May need reinstallation. -200
Sample indicators, strategies, paint bars and studies
Included in your Triage Messaging installation are sample indicators, paint bars, strategies and functions to show you how to send messages from your TradeStation EasyLanguage programs. Look in your EasyLanguage library for the files shown below.
- $Samp Stoc
- $Samp Pct Decrease
- $Samp MovAvg2Line LE
- $Samp GapDnBar
- $Samp Pct Increase
- $Samp MovAvg2Line SE
- $Samp GapUpBar
- $Samp Test All
Read the code to see real-life examples. Change the inputs to your desired messaging service, destination and trigger condition levels. You can copy these code examples as templates for your own custom indicators, strategies, paint bars and studies.