# Rules based email alerts



## skeezwiz (4 March 2013)

Is there any products/brokers that offer custom rules to send email alerts of the following nature:

Say stock/etf “ABC” at any time of market trading day when: (MACD divergence is 0.005 and RSI is > 55) OR SMA(100) >= 10.68 then send email?

It would be good if we can add a large number of AND/OR conditions even have them feed into one another. E.g. the above can be Rule1 then Rule2=Rule1 AND (EMA(100) < 10.02 and EMA(200)<10.98) OR (Rule3 AND Rule4) etc…

It should be able to send the email frequency count per day once, twice or whatever, so if a repeat event occurs then I receive alerts up to the frequency that I choose. Also have the rules expiring at certain dates and/or events and if dependent rule expires then master rule expires or sets to false. Also once these rules are setup have them applied to certain sectors like metals, pharmacy, retail stocks at the traders disposal?

Would a similar rules based engine be available for options?


----------



## CanOz (4 March 2013)

skeezwiz said:


> Is there any products/brokers that offer custom rules to send email alerts of the following nature:
> 
> Say stock/etf “ABC” at any time of market trading day when: (MACD divergence is 0.005 and RSI is > 55) OR SMA(100) >= 10.68 then send email?
> 
> ...




I am quite confident that Amibroker would do this easily...

CanOz


----------



## pixel (4 March 2013)

skeezwiz said:


> Is there any products/brokers that offer custom rules to send email alerts of the following nature:
> 
> Say stock/etf “ABC” at any time of market trading day when: (MACD divergence is 0.005 and RSI is > 55) OR SMA(100) >= 10.68 then send email?
> 
> ...




It sounds like one of the many features of Paritech's Marketscan program. I no longer subscribe to it because it doubles up on alerts I get from my own scripts, and I'm anyway trading from my office or not at all.
But Paul Klink at http://www.paritech.com.au/ or phone 1300 652 511 would probably be the man to contact with your specific questions.


----------



## skeezwiz (4 March 2013)

pixel, what scripts have u written in excel or c#?
You would need a live data feed for that right? which would cost $?


----------



## pixel (4 March 2013)

skeezwiz said:


> pixel, what scripts have u written in excel or c#?
> You would need a live data feed for that right? which would cost $?




For live trading I need live data, true.
But there is more than Excel and C++ although I am able to use Excel quite extensively.
fwiw, for my scanning and charting, I use MDS Financial's Market Analyser 7. It has its own scripting language, but won't meet your email alert requirements.


----------



## waimate01 (5 March 2013)

skeezwiz said:


> Is there any products/brokers that offer custom rules to send email alerts of the following nature:




For maximum flexibility, set up a Google Docs spreadsheet. Then, use the rather-cool serverside scripting to write your own code that implements whatever rules you want, in whatever complexity you want. The scripts run asynchronously even when you are not logged on. They can send you emails, or through a service such as 160.com, send you SMS messages. For bonus points you can even integrate the google scripts with bits of PHP you might have somewhere else so you can have automated logon to password-protected private sites, and additional data fetched or actions performed autonomously. 

Google scripts are very powerful. The underlying language is Javascript, and they integrate pretty seemlessly to everything Google offers, including finance.


----------



## Gringotts Bank (5 March 2013)

I'd use Amibroker as well.  of course you'd have to have AB running and scanning continuously, which it can do unattended.



Using formula-based alerts
Introduction

AmiBroker allows you to define formula-based alerts. When alert is triggered a text can be displayed, user-defined sound played back, e-mail notification can be sent and any external application can be launched. This is all handled by single AlertIF function.

By default all alerts generate text that is displayed in the Alert Output window.

To show this window you have to select View->Alert Output menu.

There is also Easy Alerts window that allows you to define simple alerts that do not require any coding (but do not offer full flexibility of AlertIf function).

Settings

Alert - related settings are present in the "Alerts" tab of Tools->Preferences window. 

It allows to define e-mail account settings, test sound output and define which parts of AmiBroker can generate alerts via AlertIF function. 

*E-mail* setting page now allows to choose among most popular authorization schemes like: AUTH LOGIN (most popular), POP3-before-SMPT (popular), CRAM-MD5, LOGIN PLAIN.

"Enable alerts from" checkboxes allow you to selectively enable/disable alerts generated by Automatic analysis, Commentary/Interpretation and custom indicators. 

Alert output window now has an additional column that shows the source of alert - if this is Automatic Analysis, Commentary or one of your custom indicators. This makes it easier to find out which part of AmiBroker generates alerts.

New in AmiBroker 5.30 - support for SSL (secure connection) used by GMail for example.

In order to enable SSL support you need to follow these steps:

1. Download and run SSL add-on from http://www.amibroker.com/bin/SSLAddOn.exe
2. Configure (Tools->Preferences->Alerts) with SSL enabled as shown below



AlertIF function

AlertIF function is similar to WriteIF. But instead of just writing the text to the output window (commentary/interpretation) it allows to:

direct the customized text to "alert output" window, 
make a sound (just by computer beeper or from .WAV file) 
send an e-mail 
launch any external application 
The syntax is as follows:

AlertIf( BOOLEAN_EXPRESSION, command, text, type = 0, flags = 1+2+4+8, lookback = 1 );

1. BOOLEAN_EXPRESSION is the expression that if evaluates to True (non zero value) triggers the alert. If it evaluates to False (zero value) no alert is triggered. Please note that only lookback most recent bars are considered.

2. The command string defines the action taken when alert is triggered. If it is empty the alert text is simply displayed in the Alert output window (View->Alert Output). Other supported values of command string are:

SOUND the-path-to-the-WAV-file
EMAIL
EXEC the-path-to-the-file-or-URL <optional args>

SOUND command plays the WAV file once. 

EMAIL command sends the e-mail to the account defined in the settings (Tools->Preferences->E-mail). The format of the e-mail is as follows:

Subject: Alert type_name (type) Ticker on Date/Time
Body: text

EXEC command launches external application or file or URL specified after EXEC command. <optional args> are attached after file name and text is attached at the end

3. Text defines the text that will be printed in the output window or sent via e-mail or added as argument to the application specified by EXEC command

4. Type defines type of the alert. Pre-defined types are 0 - default, 1 - buy, 2 - sell, 3 - short, 4- cover. YOu may specify higher values and they will get name "other"

5. Flags control behaviour of AlertIF function. This field is a combination (sum) of the following values:
( 1 - display text in the output window, 2 - make a beep (via computer speaker), 4 - don't display repeated alerts having the same type, 8 - don't display repeated alerts having the same date/time) By default all these options are turned ON.

6. lookback parameter controls how many recent bars are checked

Examples:

Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Sell;
Cover = Buy;

AlertIF( Buy, "EMAIL", "A sample alert on "+FullName(), 1 );

AlertIF( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );

AlertIF( Short, "EXEC Calc.exe", "Launching external application", 3 );

AlertIF( Cover, "", "Simple text alert", 4 );

Note EXEC command uses ShellExecute function and allows not only EXE files but URLs too.

Notes

1. Please note that by default AlertIf function does not generate repetitive signals when the same scan is run multiple times. During experimentation you may prefer to get repeated signals in subsequent scans. To do so you should change default flags to 1 + 2:

AlertIF( condition, "", "Text", 1, 1+2 );

2. If you want to generate the alert only on COMPLETED bar you may need to add this code:

barcomplete = BarIndex() < LastValue(BarIndex());

AlertIF( barcomplete AND condition, "", "Text", 1 );


----------



## CanOz (5 March 2013)

Of course then one needs to ask the question that many are wondering...whats the point? 

Why not just automate it?

CanOz


----------



## Gringotts Bank (5 March 2013)

CanOz said:


> Of course then one needs to ask the question that many are wondering...whats the point?
> 
> Why not just automate it?
> 
> CanOz




Because "(MACD divergence is 0.005 and RSI is > 55) OR SMA(100) >= 10.68" won't return a profit unless you have the discretionary ability to pick the winners from the bunch of triggered alerts, I guess.


----------



## skeezwiz (5 March 2013)

great info thx. I would like to explore the google docs coding option, but wouldn't there be a some web services somewhere that would give me =MACD(stock/etf), SMA_20(stock/etf), RSI(stock/etf) etc. then I can run this on a scheduler every hour or so that will alert me of these specific events.  I would also like to build chart pattern alerts e.g. say last 6 months stock/etf is showing wedge up/down, triangle up/down, formation of a trendline etc. Who is offering these web services?

The tools that I found so far: Multicharts, Ninjatrader, Recognia, Amibroker, but want to get a cheaper option then probably hit these advanced tools at a later time.


----------



## skeezwiz (13 March 2013)

I have found a free delayed service from yahoo (http://ichart.yahoo.com/table.csv?s="Symbol"), which may do the trick for now. I wanted to know if anybody has any excel vba code to perform the *macd(26,12,9)* and  *Average Directional Index (ADX) (with (-DI) and (+DI) lines)*. I need these functions to return per symbol for each trading day and I correlate these with RSI, volume, sma(20,50,100), volatility and other indicators in excel in order to setup my entry/exit trades.

Would anybody else know the general rules to apply per sector e.g. healthcare, tech, retail etc. Example if im looking at a tech stock and it has P/E=20, P/S=40 plus other factors. I'm looking for rules that say for this tech stock say "ABC", historically(last 6 months) RSI(14) has been over 45 when the stock was trading with MACD(26,12,9) on average over this period at 0.0067 and ADX showing positive momentum. How are other traders applying entry/exit trades points?


----------

