Alert for when price crosses above or below 50 MA

petech

Member
VIP
How do I setup an alert in TOS for when the price action (candle) crosses above or below the 50 MA. I called TOS phone support and the person I spoke to couldn't figure it out. I'm not after the moving average crossover, where one moving average crosses another. I'm just want when the candle crosses the 50 MA. Typically I'm on the 1 minute time frame when I'm watching a stock. Thanks in advance.
 

BenTen

Administrative
Staff member
Staff
VIP
Two options:

Use the code below:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2017-2020
#

input price = close;
input length = 50;
input displace = 0;
input showBreakoutSignals = no;

plot SMA = Average(price[-displace], length);
def UpSignal = price crosses above SMA;
def DownSignal = price crosses below SMA;

# Alerts
Alert(UpSignal, " ", Alert.Bar, Sound.Chimes);
Alert(DownSignal, " ", Alert.Bar, Sound.Bell);

or...setup a scanner > save as a watchlist > get alerted for new changes.

5pD4XGA.png
 

petech

Member
VIP
Thank you.

Right now I only want that alert for $SPY. So I went to MARKET WATCH > ALERTS > STUDY ALERT > ThinkScript Editor. Then I just copied and pasted your code. Then I pressed Create Alert.

I hope I did the right steps. I'm still pretty new to trading. Since it is Saturday right now, I won't know how this alert works until Monday. If I should have gone to scan like you suggested instead of market watch, please let me know. Thanks.
 

BenTen

Administrative
Staff member
Staff
VIP
@petech If you're going to use the Market Watch alerts tab, I suggest setting up the alerts like this:

n0GaPWg.png


Be sure to adjust the length to 50 and also the timeframe as well.
 

Joseph Patrick 18

Active member
Hi Ben,

Just had a quick question. If I just want to set up a scan to show when a stock just crosses above or below say the 10EMA? And also a scan that shows when a stock crosses above or below say the 8,13,21 EMA? Thanks

AyG8cMk.png
 
Last edited by a moderator:

Joseph Patrick 18

Active member

Hi Ben sorry to bother you...I have tried to accomplish this on my own but could use a quick hand..I am looking for script that shows stocks that have wide swings throughout the day...for example ZM had huge swings with highs and lows for the day.

I am just testing simple theories like today FB crossed above or below the 10 day EMA (HAPPENED 7 X'S TODAY ON THE 5 MIN CHRT SEE ATTACHED PIC).

You helped me yesterday with a scan that shows exactly that when a stock is about to cross the 10D EMA...so now in addition to that STUDY FILTER I would like to add an additional STOCK OR STUDY FILTER to show wide volatile swings (like the examples below (A)***

(A)*** I have been trying to find all the stocks that have wide ranging volatile whipsaws throughout the day...for example ZM today went from $465 to $483 and AMZN and TSLA usually have wide swings also...whether they are a $3 dollar stocks or $3000 stocks I just want to find the ones that are forming a pattern of going up and down or have a wide price ranges for the day...

I have tried adjusting the BETA (volatility) and have also tried to adjust the % CHANGE in the STOCK FILTER scan settings but not really seeing a consistency...so maybe there is a script for something like that if that makes sense?

Also a while back I tried to get help from TOS and a person helped me with this script and said to just adjust the last line "4" and just increase the "4" higher or lower. It works some times but again inconsistent..

def hi = high;
def lo = low;
def ratio = (1 - (lo / hi)) * 100;
plot scan = ratio > 4;

.I'm still not getting the right combination to accomplish wide volatile swings.

Is this okay to ask this on this thread or should I start a new one? Sorry if I posted in the wrong spot..thanks in advance for any help its greatly appreciated!

BsQC3v4.png


Another stupid question..is there a scan for when the Heikin Ashi pattern is changing directions (when a Heiken Ashi Doji forms)...from downward to upward and visa versa
 
Last edited:

Similar threads

Top