How to code for SMA crossover alert?
Author: gchudublin
Creation Date: 11/21/2016 2:03 AM
profile picture

gchudublin

#1
Hi, I am using Active trader and I can draw chart to show SMA 10 day, 20 day, ...etc.

This should be easy to do in Wealth lab, would you please show me some code to send me an alert when AAPL cross over 10 day SMA and cross below 10 day SMA? I would like to trigger buy when it cross over, and trigger sell when cross below.

Thanks

Greg
profile picture

Eugene

#2
There's no need in showing such code as anybody can easily do it including you. According to the Wiki FAQ (FAQ > How do I get started learning Wealth-Lab?), namely the last paragraph:

QUOTE:
Also, we recommend to experiment with the Rule Wizard (Strategy from Rules). This is the easiest way to get a basic trading system working w/o any programming, in a drag & drop manner. Then, convert them into code-based Strategies to see how things fit together.


The idea here is that you could drag and drop any condition (i.e. the crossover/crossunder) and click "Open Code in new Strategy Window" to see how it looks under the hood.

Here's a couple of tutorial videos from the Wiki to illustrate the tool's usage:

Use the Wizard to create a Rule-based Strategy
Designing Rule-based Strategies, Combining different Indicators

As for alert by email, you might want to check out the User Guide > Preferences > Email Settings.
profile picture

gchudublin

#3
I added strategies, and it did send alert to my email, but when I started the strategies it asked me a range of days, or ... If I just want to use today data, do I just use date range 1 day?

Also how can I have this continue to run even if I turn off Wealth lab application? I meant make Wealth lab a .NET service?

Also if I want to place buy and sell real time, I heard I need to have 500 trades in my account to qualify, what is the approval process?

Also any way to text messaging me the alerts in stead of sending an email?

Thanks

Greg
profile picture

Eugene

#4
QUOTE:
I added strategies, and it did send alert to my email, but when I started the strategies it asked me a range of days, or ... If I just want to use today data, do I just use date range 1 day?

You have to load enough bars for the system to build indicators and trading decisions (seed period). It's always individual.

QUOTE:
Also if I want to place buy and sell real time, I heard I need to have 500 trades in my account to qualify, what is the approval process?

This sort of question is something that your Fidelity rep knows much better.

QUOTE:
Also how can I have this continue to run even if I turn off Wealth lab application? I meant make Wealth lab a .NET service?

It's not possible.

QUOTE:
Also any way to text messaging me the alerts in stead of sending an email?

Search for email to SMS gateways.
profile picture

gchudublin

#5
I attached an image to show last run and next run, how do I make it continue to run? Or can I configure how often it runs? I had 1 minute chart, so it runs every minute?

Thanks

Greg
profile picture

Eugene

#6
It runs every minute and you cannot configure this except that by changing bar scale. Please read the Wealth-Lab User Guide to review the basics, thank you.
profile picture

gchudublin

#7
I will spend time to study during Thanksgiving weekend, but please help with one more question, I set up alert when stock prices go over 10 day SMS, and found that it would not work, it sends me alert every minute. I just need it sent alert when it cross over or below, can it be done with rules? May be just send x times, and make x configurable.

Thanks
Greg
profile picture

Eugene

#8
With 1 minute scale selected there's no "10 day SMA" in Rules - it's not supported. The code works on 1 minute scale and triggers a lot of alerts through the day. You should choose the Daily scale, not intraday.

Additionally, this can happen when the condition applied does not contain "crossed above/below" (for example, "is above/below" would not do what you want).
profile picture

gchudublin

#9
I can use programming to accomplish what I want right? Fidelity mobile app to send alert for exponential moving average for 20, 50, 200 day. I would be very surprised if wealth lab cannot do it.

I think I can live with a 3 or 5 minute chart

Thanks
Greg
profile picture

Eugene

#10
To support only one (native) bar scale is a limitation of Rule-based Strategies but in code you can do what you want of course. Question is what do you want. It's not clear. There's an impression that you're after 200-day crossover in 1-minute time frame. Why complicate things?