Alert when RSI is overbought and oversold


0
0

I would like to have a sound alert when the RSI (n period) closes “overbought” or “oversold”. I tried adding alert text  to the code but I haven’t gotten the syntax right yet.  I use RSI 3.80.20 on a 5 min chart and RSI 5.80.20 on a 1 min chart. These are trade alerts. Buy or sell depends on whether price is in a range or is trending.

Marked as spam
Posted by (Questions: 2, Answers: 3)
Asked on November 16, 2018 7:54 am
346 views
0
Private answer

I updated your question title so that is clearly states the context of your question. Please review the title I chose and in the future make sure you are very specific, yet brief, in your question titles.

It is a shame you did not include you code. If you are trying to learn this stuff then make sure to provide your code, even if it’s not functional. I will take the time to explain the items you missed and help you understand how to do it right. But since you did not provide your code I only have the solution.

I have copied the major portions of the built-in study so that it plots on a lower subgraph just like the original The two statements at the very bottom create your alerts.

declare lower;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
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;
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));
Alert(RSI > over_Bought and RSI[1] < over_Bought, "RSI Overbought", Alert.BAR, Sound.RING);
Alert(RSI < over_Sold and RSI[1] > over_Sold, "RSI Oversold", Alert.BAR, Sound.RING);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 16, 2018 9:46 am