RSI Crossover Alert for ThinkorSwim

Azzy19

New member
Hi, I'm struggling to find and create an alert for RSI crossing 30 (Oversold), and 70(Overbought). Is their a way to set an alert for a security when it's RSI behaves like this?

Thanks!
 
Last edited:

theelderwand

Active member
2019 Donor
VIP
Navigate to Marketwatch -> Alerts

Type the security you are interested in and click on Study Alert.

Go to thinkscript editor and enter the following

Code:
RSI() crosses above 30 or RSI() crosses below 70

You can edit it as you need it. There should be an RSI Crossover as well.
Below screenshot.

5qTVWv5.png
 
Last edited by a moderator:
Do you know how to make the script for sound? I want to make one for RSI under 30 and one for Awesome Oscillator crossing under the zero line. I made one for the MACD but can't figure these two out.

Code:
#wizard input: crossingType
#wizard text: Inputs: fast length:
#wizard input: fastLength
#wizard text: slow length:
#wizard input: slowLength
#wizard text: macd length:
#wizard input: MACDLength
#wizard text: average type:
#wizard input: AverageType

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input crossingType = {default "Positive to Negative", "Negative to Positive"};

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;

plot signal = Crosses(Diff, 0, crossingType == crossingType."Negative to Positive");

signal.DefineColor("Negative to Positive", GetColor(2));
signal.DefineColor("Positive to Negative", GetColor(3));
signal.AssignValueColor(if crossingType == crossingType."Negative to Positive" then signal.Color("Negative to Positive") else signal.Color("Positive to Negative"));

signal.SetPaintingStrategy(if crossingType == crossingType."Negative to Positive"
    then PaintingStrategy.BOOLEAN_ARROW_UP
    else PaintingStrategy.BOOLEAN_ARROW_DOWN);

Alert(signal[0], "MACD Alert", Alert.BAR, Sound.Ring);

# chimes, ding, bell,
 

Pensar

Active member
VIP
@Daughters Keeper You seem to already have the necessary method. :) So for the RSI, it would be something like
Code:
Alert(RSI crosses below Oversold, " Your Text Here ", Alert.Bar, Sound.Ring);
and for the Awesome Oscillator
Code:
Alert(AO crosses below Zero, " Your Text Here ", Alert.Bar, Sound.Ring);
 

jcga1981

Member
There is the possibility of creating an alert, for example that warns me when the RSI crosses 60 ... and that this alert remains in effect indefinitely until I decide it ... every time I put an alert, it warns me, but then the alert is no longer in effect.
Thank you!
 

oswald57

New member
VIP
I just copied TOS' RSI study,, made a new study and added alerts in the code. Mine plays a bell when the RSI crosses above OverSold (30) and a ring when RSI crosses below Overbought (70). I also added vertical lines.

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2020
# Revised to add Alerts

declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
Alert(UpSignal, "Possible Long", Alert.BAR, Sound.Bell);
AddVerticalLine (UpSignal, "", Color.GREEN);
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;
Alert(DownSignal, "Possible Short", Alert.BAR, Sound.Ring);

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 

jcga1981

Member
Perhaps I express myself wrong ... I mean an alert via email ... that is ... to have the possibility of receiving an email when the RSI crosses the level 30 downwards. thinkorswim offers this option, which cancels the alert once it is fulfilled ... my question is if there is a possibility of having the alert indefinitely, having the possibility of receiving an email every time the RSI crosses level 30.
 

rad14733

Well-known member
VIP
Perhaps I express myself wrong ... I mean an alert via email ... that is ... to have the possibility of receiving an email when the RSI crosses the level 30 downwards. thinkorswim offers this option, which cancels the alert once it is fulfilled ... my question is if there is a possibility of having the alert indefinitely, having the possibility of receiving an email every time the RSI crosses level 30.
Without checking into your email request let me inform you that a majority of email notifications are delayed and would only be worthwhile for longer timeframes... I have had emails to multiple addresses delayed from different Alerts for extended periods of time... I would imagine that the reason for this would be server priority related, meaning that email notifications have a lower priority than some more mission critical processes... Just a heads-up...
 

jcga1981

Member
I mean that the alert is constantly active, that is ... if they send me the alert because the RSI crossed 60 ... if the RSI falls again and after two hours it crosses it again ... well let me know again.
 

jcga1981

Member
as @MerryDay says ... they are conditional alerts ... that is, they notify me via email if, for example, the RSI crosses the level 80, but once it is activated, it is an alert and is no longer valid (active), Is there the possibility of having an alert (via email) that warns me every time the RSI in the SPY exceeds the level 80?
 

MerryDay

Well-known member
VIP
@jcga1981 Chart alerts are built on the same engine as conditional orders, once activated; it is no longer valid. You can search this forum for more information if you want to understand what you can and can not do w/ chart alerts and conditional orders.

The TOS platform and its rules can not be worked around. It is what it is.
 

corello

New member
2019 Donor
Hi Everyone,

I am looking to add an alert to the RSI indicator each time it goes below 34.

Please advise on how to add this code to the current RSI study.

My goal is to be able to get an alert each time a stock in my flexible grid goes below RSI of 34 in real-time.

Thank you.
 

BenTen

Administrative
Staff
VIP
@corello Follow the tutorial posted in message #2

Or...you can use the code below:

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

declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;

def custom = 34;
def data = RSI crosses below custom;

Alert(data, "RSI crosses below 34", Alert.Bar, Sound.Chimes);
 

scott69

Member
I have created the following to use both labels and alerts. Use the inputs or comment out (#) any functions that you don't want
Code:
# SD_RSILabel
# Last Mod: December 14, 2020

##### Begin Code #####
declare upper;

input length = 14;
input RSIOverbought = 70;
input RSIOversold = 30;
input RSIPos = 60;
input RSINeg = 40;
input median = 50;
input RSI_to_Median = yes;
input RSI_Warning = yes;
input AlertHiLevel = 70;
input AlertLoLevel = 30;

def RSIlabel = reference RSI(length,price = close);

AddLabel(yes, if RSIlabel > RSIlabel[1] then "                           RSI RISING                           " else "                          RSI FALLING                         ", if RSIlabel > RSIlabel[1] then Color.GREEN else Color.RED);

AddLabel(yes, if RSIlabel >= RSIOverbought then "                    RSI OVERBOUGHT                    " else "", Color.RED);

AddLabel(yes, if RSIlabel <= RSIOversold then "                       RSI OVERSOLD                       " else "", Color.GREEN);

AddLabel(RSI_Warning, if RSIlabel >= RSIPos then "                RSI HIGH WARNING                " else "", Color.RED);

AddLabel(RSI_Warning, if RSIlabel <= RSINeg then "                RSI LOW WARNING                " else "", Color.GREEN);

AddLabel(RSI_to_Median, " RSI TO MEDIAN " + Round(RSILabel,0) + " ", if RSIlabel > median then Color.LIME else if RSIlabel <= median then Color.ORANGE else Color.WHITE);

Alert(RSILabel > AlertHiLevel, "", Alert.Bar, Sound.Ring);
Alert(RSILabel < AlertLoLevel, "", Alert.Bar, Sound.Ring);

##### End Code #####
 

Similar threads

Top