Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Anybody know how to make a custom alert, or maybe it would have to be a study, for a close below 9-EMA? I went to the MarketWatch tab as it says in ToS help, but that doesn't put anything on the chart.
def alert = close is less than MovAvgExponential()."AvgExp";
Alert(alert, "Close above 9 EMA", Alert.BAR);
def alert = close crosses below MovAvgExponential()."AvgExp";
Alert(alert, "Close above 9 EMA", Alert.BAR);
input price = close;
input length = 9;
input displace = 0;
def AvgExp = ExpAverage(price[-displace], length);
def alert = close crosses below AvgExp;
Alert(alert, "Close below 9 EMA", Alert.BAR);
input price = close;
input fastLength = 10;
input slowLength = 20;
input averageType = AverageType.EXPONENTIAL;
plot FastMA = MovingAverage(averageType, price, fastLength);
plot SlowMA = MovingAverage(averageType, price, slowLength);
def bullish = FastMA crosses above SlowMA;
def bearish = FastMA crosses below SlowMA;
AssignPriceColor(if bullish then color.blue else color.red);
AssignPriceColor(if FastMA > SlowMA then color.blue else color.red);
declare lower;
def above = SimpleMovingAvg("length" = 20)."SMA" crosses above SimpleMovingAvg("length" = 200)."SMA";
def below = SimpleMovingAvg("length" = 20)."SMA" crosses below SimpleMovingAvg("length" = 200)."SMA";
plot arrowaabove = if above then above else Double.NaN;
plot arrowbelow = if below then below else Double.NaN;
arrowaabove.SetDefaultColor(Color.GREEN);
arrowaabove.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
arrowbelow.SetDefaultColor(Color.RED);
arrowbelow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
declare upper;
input fast = 20;
input slow = 200;
input price = CLOSE;
def null = double.NaN;
plot S = SimpleMovingAvg(price, slow);
plot F = SimpleMovingAvg(price, fast);
plot CX_UP = if F crosses above S then F else null;
CX_UP.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
plot CX_DN = if F crosses below S then F else null;
CX_DN.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
if F > S and F[1] < S[1]
Hello Ben. I'm looking for similar scanner, but slightly different. I need 50MA(Blue) crosses 200MA(Red), and can this scanner work on premarket crossovers? Please see picture for reference. Thank youThis is just a simple indicator for moving average crossover but added scanner, cloud, and alerts for additional visual effect and enhancement.
For example, if 5/10 EMA crossover is your strategy, then this indicator plot an up arrow on the golden cross and down arrow on the death cross. You can also use the scanner to scan for stocks with EMA crossover and the built-in alerts to let you know as it happens.
thinkScript Code
Rich (BB code):# Moving Average Crossover With Arrows, Alerts, Crossing Count and Bubble at Cross # Mobius # Chat Room Request 01.25.2017 # Modified a bit by BenTen input price = close; input fastLength = 8; input slowLength = 21; input averageType = AverageType.EXPONENTIAL; plot FastMA = MovingAverage(averageType, price, fastLength); plot SlowMA = MovingAverage(averageType, price, slowLength); FastMA.SetDefaultColor(GetColor(1)); SlowMA.SetDefaultColor(GetColor(2)); plot ArrowUp = if FastMA crosses above SlowMA then low else double.nan; ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP); ArrowUP.SetLineWeight(3); ArrowUP.SetDefaultColor(Color.Green); plot ArrowDN = if FastMA crosses below SlowMA then high else double.nan; ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN); ArrowDN.SetLineWeight(3); ArrowDN.SetDefaultColor(Color.Red); Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes); Alert(ArrowDN, " ", Alert.Bar, Sound.Bell); AddCloud(FastMA, SlowMA, Color.GREEN, Color.RED); # End Code
Shareable Link
https://tos.mx/2ZED6i
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
L | A Volume Pressure Moving Average For ThinkOrSwim | Indicators | 15 | |
T | Mega Moving Average For ThinkOrSwim | Indicators | 26 | |
S | Moving Average Golden Cross - Death Cross For ThinkOrSwim | Indicators | 14 | |
D | Repaints MTF Moving Average Slope Histogram For ThinkOrSwim | Indicators | 20 | |
All The Moving Average Ribbons for ThinkorSwim | Indicators | 16 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.