Usage
Alert(conditional statement, text alert, alert type, sound);
Examples
#
# TD Ameritrade IP Company, Inc. (c) 2017-2020
#
input fastLength = 50;
input slowLength = 200;
input averageType = AverageType.SIMPLE;
plot FastMA = MovingAverage(averageType, close, fastLength);
plot SlowMA = MovingAverage(averageType, close, slowLength);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));
def goldencross = FastMA crosses above SlowMA;
# Alert
Alert(goldencross, "50/200 Crossover", Alert.Bar, Sound.Chimes);
The alert script above will notify you every time there's a golden cross (the 50 SMA crossing above the 200 SMA).
Here is another one where we utilize two different alert sounds. You'll hear a chime when there is an up arrow and a bell sound when there is a down arrow.
#
# TD Ameritrade IP Company, Inc. (c) 2017-2020
#
input price = close;
input length = 9;
input displace = 0;
plot AvgExp = ExpAverage(price[-displace], length);
plot UpSignal = price crosses above AvgExp;
plot DownSignal = price crosses below AvgExp;
AvgExp.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
# Alerts
Alert(UpSignal, "Price crossing above 9 EMA", Alert.Bar, Sound.Chimes);
Alert(DownSignal, "Price crossing below 9 EMA", Alert.Bar, Sound.Bell);
Additional scripts related to Alert
- https://usethinkscript.com/threads/rsi-crossover-alert-for-thinkorswim.243/
- https://usethinkscript.com/threads/crossing-vwap-sound-alert.844/
- https://usethinkscript.com/threads/sending-alerts-from-script.2542/
- https://usethinkscript.com/threads/custom-sounds-on-alerts-for-studies.1158/
Useful Notes from the thinkScript Lounge
thinkScript Alert() function. Platform and chart have to be open. [source]Alert for an entire watchlist [source]
TOS platform tip/trick - How to set an earnings warning Alert [source]