Messaging for Sierra Chart

From Triage Documentation

Jump to: navigation, search


Send your first message

It is easy to try out Triage Messaging for the first time. Simply open up a custom study, and insert the following code into your study.

/* Declare Triage Messaging Function  */

SCSFExport scsf_TriageMessagingStudySample (SCStudyGraphRef sc)
   typedef int (__stdcall \* proc_Triage_Msg) (SCStudyGraphRef, LPCSTR, LPCSTR, LPCSTR, LPCSTR, CHAR \*);

   static HMODULE hDll_TriageMessaging = NULL;
   static proc_Triage_Msg func_Triage_Msg = NULL;

   /* Load TriageMessaging.DLL */

   if (NULL == hDll_TriageMessaging)
      hDll_TriageMessaging = LoadLibrary("SierraChart_Msg.dll");
      if (NULL != hDll_TriageMessaging)
         func_Triage_Msg = (proc_Triage_Msg)
         GetProcAddress(hDll_TriageMessaging, "Triage_Msg");

   /* Send Message */

   if (func_Triage_Msg != NULL)
      int res = (func_Triage_Msg) (sc, "i16", "email", "","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 "" 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 we just showed you 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 Sierra Chart C++ 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: int res = (func_Triage_Msg) (sc, "i16", "msn", "", "Hello, World!", "Once");

/* Send Message */

if (func_Triage_Msg != NULL)
      int res = (func_Triage_Msg) (sc, "i16", "email", "","Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "phone", "14155550606", "Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "sms",  "14155550808", "Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "fax", "14155550303", "Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "yahoo", "myyahoousername","Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "msn", "","Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "aim", "myAOLusername","Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "icq", "570102039432","Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "gtalk", "","Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "twitter", "twitteralias", "Hello, World!", "Once");
      int res = (func_Triage_Msg) (sc, "i16", "facebook", "facebookalias", "Hello, World!", "Once");

Don't forget to change the 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 Sierra Chart program.

The func_Triage_Msg Sierra Chart C++ function helps you send messages according to your service, destination, message text, interval and time rules. With five simple parameters shown below, you can send messages to any destination in the world from your trading platform: SCStudyGraphRef, SC persistent variable, message service, message destination, message text and message condition.

(func_Triage_Msg) (SCStudyGraphRef, persistent variable, message service, message destination, message text, message condition)
Messaging Parameters
Message Function Parameter Description
SCStudyGraphRef Which Sierra Chart study graph reference does the message belong?
Persistent Variable Choose a Sierra Chart persistent variable i1 to i16 to store the message instance.
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
int res = (func_Triage_Msg) (sc, "i16", "icq", "570102039432", "Hello!", "Once");
// Variable Strings
char *xservice = "phone";
char *xdestination = "14155551111";
int res = (func_Triage_Msg) (sc, "i16", xservice, xdestination, "Hello!", "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 detail in the following sections.

SCStudyGraphRef Parameter

Always use your SCStudyGraphRef for the first parameter of func_Triage_Msg. This is to allow func_Triage_Msg to know which Sierra Chart study graph will be sending the message to Triage Messaging.

SCSFExport scsf_TriageMessagingStudySample (SCStudyGraphRef sc)

  int res = (func_Triage_Msg) (sc, "i16", "msn", "", "Hello!", "Once");


Persistent Variable Parameter

Triage Messaging requires the use of Sierra Chart persistent variables to store messaging information for each instance of your messages and conditions. You must select a persistent integer variable from the 16 integers that Sierra Chart provides per study graph. These Sierra Chart persistent variables are named i1, i2, i3 … i16.

As a default, use i16 as shown below. Make sure that you are not already using i16 in the rest of your Sierra Chart code.

int res = (func_Triage_Msg) (sc, i16, "msn", "", "Hello!", "Once");

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.

Messaging Services
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 email
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 twitter
Facebook™ Account facebook

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.

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 Formats
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
Yahoo Instant Messenger yahoousername
AOL ("AIM") Instant Messenger AOLusername
Microsoft MSN or Live Instant Messenger
Google Talk Instant Messenger
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".

int res = (func_Triage_Msg) (sc, "i16", "msn", "", "Hello!", "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. We designed a series of messaging conditions that help you control when messages will be sent without writing the complex code yourself.

Messaging Condition Settings
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)
"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.

// message sent to a phone destination once
int res = (func_Triage_Msg) (sc, "i16", "phone", "14152228888", "Send this message once", "once");

// message sent via SMS in real-time (last bar on chart) each time code runs
int res = (func_Triage_Msg) (sc, "i16", "sms", "14153338888", "Send this message in real-time", "now");

// message sent to MSN instant message account every 10 bars
int res = (func_Triage_Msg) (sc, "i16", "msn", "", "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      // my own condition
   int res = (func_Triage_Msg) (sc, "i16", "yahoo", "myyahoouser", "Send this message every 20 minutes", "next=00:20:00");

// message sent to gtalk instant message account during time interval 1AM to 2AM
int res = (func_Triage_Msg) (sc, "i16", "gtalk", "", "Send this message from 1AM to 2AM", "time=01:00:00-02:00:00");

Message Function Return Results

The _triage_msg.send_msg 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
Personal tools