Handsome_Rob
New member
If anyone could help me with this I'd appreciate it.
https://www.tradingview.com/script/jz39ymWe-RSI-Algo-with-alert/
https://www.tradingview.com/script/jz39ymWe-RSI-Algo-with-alert/
Last edited by a moderator:
check the belowIf anyone could help me with this I'd appreciate it.
https://www.tradingview.com/script/jz39ymWe-RSI-Algo-with-alert/
I was able to get much of the behavior, but the buy and sell toggles arent working properly for me.
Thank you!
Code:study("RSI Algo", overlay=true) myPeriod = input(defval=14, type=integer, title="Period") myThresholdUp = input(defval=70, type=float, title="Upper Threshold") myThresholdDn = input(defval=30, type=float, title="Lower Threshold") myAlgoFlipToggle = input(defval=false, type=bool, title="Imverse Algorthim") myLineToggle = input(defval=true, type=bool, title="Show Lines") myLabelToggle = input(defval=true, type=bool, title="Show Labels") myRSI=rsi(close, myPeriod) buy = myAlgoFlipToggle ? falling(myRSI,1) and cross(myRSI, myThresholdDn) : rising(myRSI, 1) and cross(myRSI,myThresholdUp) sell = myAlgoFlipToggle ? rising(myRSI, 1) and cross(myRSI,myThresholdUp) : falling(myRSI,1) and cross(myRSI, myThresholdDn) myPosition = buy==1 ? 0 : sell==1 or myPosition[1]==1 ? 1 : 0 trendColor = buy ? red : sell ? green : na plot(myLineToggle ? buy and myPosition[1]==1 ? low - 0.004: sell and myPosition[1]==0 ? high + 0.004 : na : na, color=trendColor, style=line, linewidth=4, editable=false) plotshape(myLabelToggle ? buy and myPosition[1]==1 ? low - 0.005 : na : na, style=shape.labelup, location=location.absolute, text="Buy", transp=0, textcolor = white, color=black, editable=false) plotshape(myLabelToggle ? sell and myPosition[1]==0 ? high + 0.005 : na : na, style=shape.labeldown, location=location.absolute, text="Sell", transp=0, textcolor = white, color=black, editable=false) alertcondition(buy, title='Buy Trend', message='Buy') alertcondition(sell, title='Sell Trend', message='Sell') alertcondition(myPosition, title='Trend Change', message='Trend Change')
# @legalMeerkat56102
#study("RSI Algo", overlay=true)
# Converted by Sam4Cok@Samer800 - 01/2023
input alerts = yes;
input sound = {default "NoSound", "Ding", "Bell", "Chimes", "Ring"};
input rsiPeriod = 14; # "Period"
input ThresholdUp = 70; # "Upper Threshold"
input ThresholdDn = 30; # "Lower Threshold"
input myAlgoFlipToggle = no; # "Imverse Algorthim"
input myLineToggle = yes; # "Show Lines"
input myLabelToggle = yes; # "Show Labels"
def na = Double.NaN;
def srcDiff = close - close[1];
def NetChgAvg = MovingAverage(AverageType.WILDERS, srcDiff, rsiPeriod);
def TotChgAvg = MovingAverage(AverageType.WILDERS, AbsValue(srcDiff), rsiPeriod);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def nRSI = 50 * (ChgRatio + 1);
def myRSI = nRSI;
def crossUp = (myRSI crosses ThresholdUp);
def crossDn = (myRSI crosses ThresholdDn);
def buy = if myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else
if !myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else buy[1];
def sell = if myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else
if !myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else sell[1];
def myPosition = if buy == 1 then 0 else if sell == 1 or myPosition[1] == 1 then 1 else 0;
def trendColor = if buy then 1 else if sell then -1 else trendColor[1];
def rsiAlgo = if buy and myPosition[1] == 1 then low - 0.004 else
if sell and myPosition[1] == 0 then high + 0.004 else na;
plot RSIAlgoLine = if myLineToggle then rsiAlgo else na;
RSIAlgoLine.SetLineWeight(2);
RSIAlgoLine.EnableApproximation();
RSIAlgoLine.AssignValueColor(if trendColor[1] > 0 then Color.UPTICK else if trendColor[1] < 0 then Color.DOWNTICK else Color.GRAY);
#--- Bubbles
AddChartBubble(myLabelToggle and buy and myPosition[1] == 1, low - 0.005, "Buy", Color.GREEN, no);
AddChartBubble(myLabelToggle and sell and myPosition[1] == 0, high + 0.005, "Sell", Color.RED, yes);
#---- Alerts
Alert(alerts and buy, "Buy Trend", Alert.BAR, sound);
Alert(alerts and sell, "Sell Trend", Alert.BAR, sound);
Alert(alerts and myPosition, "Trend Change", Alert.BAR, sound);
#--- END CODE
Curious if this is a repainting indicator?check the below
CSS:# @legalMeerkat56102 #study("RSI Algo", overlay=true) # Converted by Sam4Cok@Samer800 - 01/2023 input alerts = yes; input sound = {default "NoSound", "Ding", "Bell", "Chimes", "Ring"}; input rsiPeriod = 14; # "Period" input ThresholdUp = 70; # "Upper Threshold" input ThresholdDn = 30; # "Lower Threshold" input myAlgoFlipToggle = no; # "Imverse Algorthim" input myLineToggle = yes; # "Show Lines" input myLabelToggle = yes; # "Show Labels" def na = Double.NaN; def srcDiff = close - close[1]; def NetChgAvg = MovingAverage(AverageType.WILDERS, srcDiff, rsiPeriod); def TotChgAvg = MovingAverage(AverageType.WILDERS, AbsValue(srcDiff), rsiPeriod); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def nRSI = 50 * (ChgRatio + 1); def myRSI = nRSI; def crossUp = (myRSI crosses ThresholdUp); def crossDn = (myRSI crosses ThresholdDn); def buy = if myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else if !myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else buy[1]; def sell = if myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else if !myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else sell[1]; def myPosition = if buy == 1 then 0 else if sell == 1 or myPosition[1] == 1 then 1 else 0; def trendColor = if buy then 1 else if sell then -1 else trendColor[1]; def rsiAlgo = if buy and myPosition[1] == 1 then low - 0.004 else if sell and myPosition[1] == 0 then high + 0.004 else na; plot RSIAlgoLine = if myLineToggle then rsiAlgo else na; RSIAlgoLine.SetLineWeight(2); RSIAlgoLine.EnableApproximation(); RSIAlgoLine.AssignValueColor(if trendColor[1] > 0 then Color.UPTICK else if trendColor[1] < 0 then Color.DOWNTICK else Color.GRAY); #--- Bubbles AddChartBubble(myLabelToggle and buy and myPosition[1] == 1, low - 0.005, "Buy", Color.GREEN, no); AddChartBubble(myLabelToggle and sell and myPosition[1] == 0, high + 0.005, "Sell", Color.RED, yes); #---- Alerts Alert(alerts and buy, "Buy Trend", Alert.BAR, sound); Alert(alerts and sell, "Sell Trend", Alert.BAR, sound); Alert(alerts and myPosition, "Trend Change", Alert.BAR, sound); #--- END CODE
There is nothing in this code that presents as an obvious repainter.Curious if this is a repainting indicator?
I could be off base here but it reminded me of a zig zag style indicator when I loaded it up. I'll chk it out on Tuesday and see how it reacts.
Put it up on a bunch of different charts. Definitely NOT a repainter. First chart I put it up on it looked too perfect... just a winning streak. My apologies for the false alarm!There is nothing in this code that presents as an obvious repainter.
Please update us with your findings. Thanks
# @legalMeerkat56102
#study("RSI Algo", overlay=true)
# Converted by Sam4Cok@Samer800 - 01/2023
input alerts = yes;
input sound = {default "NoSound", "Ding", "Bell", "Chimes", "Ring"};
input rsiPeriod = 14; # "Period"
input ThresholdUp = 70; # "Upper Threshold"
input ThresholdDn = 30; # "Lower Threshold"
input myAlgoFlipToggle = no; # "Imverse Algorthim"
input myLineToggle = yes; # "Show Lines"
input myLabelToggle = yes; # "Show Labels"
input NetChgAvgType = AverageType.WILDERS;
input TotChgAvgType = AverageType.WILDERS;
def na = Double.NaN;
def srcDiff = close - close[1];
def NetChgAvg = MovingAverage(NetChgAvgType, srcDiff, rsiPeriod);
def TotChgAvg = MovingAverage(TotChgAvgType, AbsValue(srcDiff), rsiPeriod);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def nRSI = 50 * (ChgRatio + 1);
def myRSI = nRSI;
def crossUp = (myRSI crosses ThresholdUp);
def crossDn = (myRSI crosses ThresholdDn);
def buy = if myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else
if !myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else buy[1];
def sell = if myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else
if !myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else sell[1];
def myPosition = if buy == 1 then 0 else if sell == 1 or myPosition[1] == 1 then 1 else 0;
def trendColor = if buy then 1 else if sell then -1 else trendColor[1];
def rsiAlgo = if buy and myPosition[1] == 1 then low - 0.004 else
if sell and myPosition[1] == 0 then high + 0.004 else na;
plot RSIAlgoLine = if myLineToggle then rsiAlgo else na;
RSIAlgoLine.SetLineWeight(2);
RSIAlgoLine.EnableApproximation();
RSIAlgoLine.AssignValueColor(if trendColor[1] > 0 then Color.UPTICK else if trendColor[1] < 0 then Color.DOWNTICK else Color.GRAY);
#--- Bubbles
AddChartBubble(myLabelToggle and buy and myPosition[1] == 1, low - 0.005, "Buy", Color.GREEN, no);
AddChartBubble(myLabelToggle and sell and myPosition[1] == 0, high + 0.005, "Sell", Color.RED, yes);
#---- Alerts
Alert(alerts and buy, "Buy Trend", Alert.BAR, sound);
Alert(alerts and sell, "Sell Trend", Alert.BAR, sound);
Alert(alerts and myPosition, "Trend Change", Alert.BAR, sound);
#--- END CODE
Sure the filter is:Is there anyway to make a scanner with this??
Do you have the link to your RSI ALGO Chart with the squeeze and the Momentum indicator@samer800 Thank you for sharing the TOS script !
I have externalized following parameters, tuning to values
NOTE: This setup still requires further testing
Happy to hear your feedback.
input rsiPeriod = 13;
input NetChgAvgType = AverageType.WILDERS;
input TotChgAvgType = AverageType.HULL;
See 1Y/1D chart image link below:
RSI Algo TOS
See updated script below:
Code:# @legalMeerkat56102 #study("RSI Algo", overlay=true) # Converted by Sam4Cok@Samer800 - 01/2023 input alerts = yes; input sound = {default "NoSound", "Ding", "Bell", "Chimes", "Ring"}; input rsiPeriod = 14; # "Period" input ThresholdUp = 70; # "Upper Threshold" input ThresholdDn = 30; # "Lower Threshold" input myAlgoFlipToggle = no; # "Imverse Algorthim" input myLineToggle = yes; # "Show Lines" input myLabelToggle = yes; # "Show Labels" input NetChgAvgType = AverageType.WILDERS; input TotChgAvgType = AverageType.WILDERS; def na = Double.NaN; def srcDiff = close - close[1]; def NetChgAvg = MovingAverage(NetChgAvgType, srcDiff, rsiPeriod); def TotChgAvg = MovingAverage(TotChgAvgType, AbsValue(srcDiff), rsiPeriod); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def nRSI = 50 * (ChgRatio + 1); def myRSI = nRSI; def crossUp = (myRSI crosses ThresholdUp); def crossDn = (myRSI crosses ThresholdDn); def buy = if myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else if !myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else buy[1]; def sell = if myAlgoFlipToggle then (myRSI > myRSI[1]) and crossUp else if !myAlgoFlipToggle then (myRSI < myRSI[1]) and crossDn else sell[1]; def myPosition = if buy == 1 then 0 else if sell == 1 or myPosition[1] == 1 then 1 else 0; def trendColor = if buy then 1 else if sell then -1 else trendColor[1]; def rsiAlgo = if buy and myPosition[1] == 1 then low - 0.004 else if sell and myPosition[1] == 0 then high + 0.004 else na; plot RSIAlgoLine = if myLineToggle then rsiAlgo else na; RSIAlgoLine.SetLineWeight(2); RSIAlgoLine.EnableApproximation(); RSIAlgoLine.AssignValueColor(if trendColor[1] > 0 then Color.UPTICK else if trendColor[1] < 0 then Color.DOWNTICK else Color.GRAY); #--- Bubbles AddChartBubble(myLabelToggle and buy and myPosition[1] == 1, low - 0.005, "Buy", Color.GREEN, no); AddChartBubble(myLabelToggle and sell and myPosition[1] == 0, high + 0.005, "Sell", Color.RED, yes); #---- Alerts Alert(alerts and buy, "Buy Trend", Alert.BAR, sound); Alert(alerts and sell, "Sell Trend", Alert.BAR, sound); Alert(alerts and myPosition, "Trend Change", Alert.BAR, sound); #--- END CODE
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Triangular Stoch RSI Bands For ThinkOrSwim | Custom | 1 | ||
RSI and ATR Trend Reversal SL/TP for ThinkOrSwim | Custom | 5 | ||
R | Webby RSI 2.0 For ThinkOrSwim | Custom | 4 | |
Heikin Ashi RSI candlesticks For ThinkOrSwim | Custom | 2 | ||
Supertrended RSI [AlgoAlpha] for ThinkOrSwim | Custom | 3 |
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.