RSI true swings For ThinkOrSwim

tinfox

Member
This works quite well on the 5min /m2k and whatnot. Its pine scirpt

--------------------------------------------------------------------------------------------------------------------------------------------------------------
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

This works quite well on the 5min /m2k and whatnot. Its pine scirpt
https://www.tradingview.com/script/K6YXCogW-RSI-true-swings/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tradeswithashish
//@version=5
indicator(title="RSI true swings indicator", shorttitle="RSI True swings", overlay=true)
upthresh=input.int(title="RSI Upper threshhold", defval=60, minval=50, step=5, maxval=90)
lwthresh=input.int(title="RSI Lower threshhold", defval=40, minval=10, step=5, maxval=50)
//volume criteria checkup
volcheck=volume>ta.sma(volume, 20)
my_rsi=ta.rsi(close, 14)
//Candle size must be above average
bullbar_check= close>high[1] and (high-low)>ta.sma(high-low, 20) and (close-low)>(high-close) and low<=high[1]
bearbar_check= close<low[1] and (high-low)>ta.sma(high-low, 20) and (high-close)>(close-low) and high>=low[1]
//RSI crossover/crossunder must fulfilling following criteria
rsicrossover=ta.crossover(my_rsi, lwthresh) and volcheck and bullbar_check and volume>volume[1] and close>high[1] and open<close and close>high[2] and my_rsi[1]>lwthresh-10
rsicrossunder=ta.crossunder(my_rsi, upthresh) and volcheck and close<low[1] and bearbar_check and volume>volume[1] and open>close and close<low[2] and my_rsi[1]<upthresh+10

//Plotting the signal confirming
plotshape(rsicrossover, title="Short exit or Buy Entry", style= shape.labelup, location=location.belowbar, color=color.green, size=size.tiny, text="BUY", textcolor=color.white)
plotshape(rsicrossunder, title="Bull exit or Short entry", style= shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny, text="SELL", textcolor=color.white)
rec_high=ta.highest(high,5)
rec_low=ta.lowest(low, 5)
if rsicrossover
alert(str.tostring(syminfo.ticker)+": Exit SELL or BUY now"+"\n Stoploss below " + str.tostring(rec_low) + "\n CMP "+ str.tostring(close), alert.freq_once_per_bar_close)
if rsicrossunder
alert(str.tostring(syminfo.ticker)+": Exit BUY or SELL now \n Stoploss above"+ str.tostring(rec_high) + "\n CMP "+ str.tostring(close), alert.freq_once_per_bar_close)


Using chatgpt got this failed attempt:
https://usethinkscript.com/threads/chatgpt.13822/page-2#post-120479

--------------------------------------------------------------------------------------------------------------------------------------------------------------


convert a tradingview code
includes check for min and max values


Code:
#RSI_true_swings_00

#https://usethinkscript.com/threads/convert-tradingview-rsi-true-swings-indicator.14590/
#Convert Tradingview RSI true swings indicator

#This works quite well on the 5min /m2k and whatnot. Its pine scirpt
#https://www.tradingview.com/script/K6YXCogW-RSI-true-swings/
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © tradeswithashish
#indicator(title="RSI true swings indicator", shorttitle="RSI True swings", overlay=true)

def step = 5;

input RSI_Upper_threshhold = 60;
#hint RSI_Upper3:  default = 60 \n minimum = 50 \n maximum = 90
def rsi_upper2 =  floor(RSI_Upper_threshhold/step)*step;
def upthresh = if RSI_Upper2 < 50 then 50 else if RSI_Upper2 > 90 then 90 else RSI_Upper2;
#  defval=60, minval=50, step=5, maxval=90)

input RSI_Lower_threshhold = 40;
def rsi_lower2 =  floor(RSI_lower_threshhold/step)*step;
def lwthresh = if RSI_lower2 < 10 then 10 else if RSI_lower2 > 50 then 50 else RSI_lower2;
#  defval=40, minval=10, step=5, maxval=50)

#//volume criteria checkup
input vol_avg_len = 20;
input vol_avg_type =  AverageType.simple;
def vol_avg = MovingAverage(vol_avg_type, volume, vol_avg_len);
def volcheck = (volume > vol_avg);
def my_rsi = rsi(14).rsi;

input ma1_len = 20;
input ma1_type =  AverageType.simple;
def ma1 = MovingAverage(ma1_type, (high-low), ma1_len);
def bullbar_check = close > high[1] and (high-low) > ma1 and (close-low) > (high-close) and low <= high[1];
def bearbar_check = close < low[1] and (high-low) > ma1 and (high-close) > (close-low) and high >= low[1];

#//RSI crossover/crossunder must fulfilling following criteria
def rsicrossover = (my_rsi crosses above lwthresh) and volcheck and bullbar_check and volume>volume[1] and close>high[1] and open < close and close > high[2] and my_rsi[1] > (lwthresh-10);
def rsicrossunder = (my_rsi crosses below upthresh) and volcheck and close<low[1] and bearbar_check and volume>volume[1] and open > close and close < low[2] and my_rsi[1] < (upthresh+10);

#//Plotting the signal confirming
addchartbubble(rsicrossover, low, "BUY", color.green, no);
addchartbubble(rsicrossunder, high, "SELL", color.red, yes);

def rec_high = highest(high,5);
def rec_low = lowest(low, 5);

# =====================================
# alerts , sounds
# alert(condition, text, alert type, sound);
# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(rsicrossover, (GetSymbol() + ": Exit SELL or BUY now. Stoploss below " + rec_low + " CMP " + close), alert.BAR, sound.DING);
alert(rsicrossunder, (GetSymbol() + ": Exit BUY or SELL now. Stoploss above " + rec_high + " CMP " + close), alert.BAR, sound.bell);
# =====================================

input test1_buy_sell_labels = no;
addlabel(test1_buy_sell_labels, 
(GetSymbol() + ": Exit SELL or BUY now. Stoploss below " + rec_low + " CMP " + close)
, color.cyan);

addlabel(test1_buy_sell_labels, 
(GetSymbol() + ": Exit BUY or SELL now. Stoploss above " + rec_high + " CMP " + close)
, color.magenta);

#--------------------
#
 
This works quite well on the 5min /m2k and whatnot. Its pine scirpt
https://www.tradingview.com/script/K6YXCogW-RSI-true-swings/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tradeswithashish
//@version=5
indicator(title="RSI true swings indicator", shorttitle="RSI True swings", overlay=true)
upthresh=input.int(title="RSI Upper threshhold", defval=60, minval=50, step=5, maxval=90)
lwthresh=input.int(title="RSI Lower threshhold", defval=40, minval=10, step=5, maxval=50)
//volume criteria checkup
volcheck=volume>ta.sma(volume, 20)
my_rsi=ta.rsi(close, 14)
//Candle size must be above average
bullbar_check= close>high[1] and (high-low)>ta.sma(high-low, 20) and (close-low)>(high-close) and low<=high[1]
bearbar_check= close<low[1] and (high-low)>ta.sma(high-low, 20) and (high-close)>(close-low) and high>=low[1]
//RSI crossover/crossunder must fulfilling following criteria
rsicrossover=ta.crossover(my_rsi, lwthresh) and volcheck and bullbar_check and volume>volume[1] and close>high[1] and open<close and close>high[2] and my_rsi[1]>lwthresh-10
rsicrossunder=ta.crossunder(my_rsi, upthresh) and volcheck and close<low[1] and bearbar_check and volume>volume[1] and open>close and close<low[2] and my_rsi[1]<upthresh+10

//Plotting the signal confirming
plotshape(rsicrossover, title="Short exit or Buy Entry", style= shape.labelup, location=location.belowbar, color=color.green, size=size.tiny, text="BUY", textcolor=color.white)
plotshape(rsicrossunder, title="Bull exit or Short entry", style= shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny, text="SELL", textcolor=color.white)
rec_high=ta.highest(high,5)
rec_low=ta.lowest(low, 5)
if rsicrossover
alert(str.tostring(syminfo.ticker)+": Exit SELL or BUY now"+"\n Stoploss below " + str.tostring(rec_low) + "\n CMP "+ str.tostring(close), alert.freq_once_per_bar_close)
if rsicrossunder
alert(str.tostring(syminfo.ticker)+": Exit BUY or SELL now \n Stoploss above"+ str.tostring(rec_high) + "\n CMP "+ str.tostring(close), alert.freq_once_per_bar_close)




------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Using chatgpt got this:


#RSI true swings indicator declare lower; input upthresh = 60; input lwthresh = 40; #volume criteria checkup def volcheck = volume > SimpleMovingAvg(volume, 20); def my_rsi = RSI(close, 14); #Candle size must be above average def bullbar_check = close > high[1] and (high - low) > SimpleMovingAvg(high - low, 20) and (close - low) > (high - close) and low <= high[1]; def bearbar_check = close < low[1] and (high - low) > SimpleMovingAvg(high - low, 20) and (high - close) > (close - low) and high >= low[1]; #RSI crossover/crossunder must fulfilling following criteria def rsicrossover = Crosses(my_rsi, lwthresh) > 0 and volcheck and bullbar_check and volume > volume[1] and close > high[1] and open < close and close > high[2] and my_rsi[1] > lwthresh - 10; def rsicrossunder = Crosses(my_rsi, upthresh) < 0 and volcheck and close < low[1] and bearbar_check and volume > volume[1] and open > close and close < low[2] and my_rsi[1] < upthresh + 10; #Plotting the signal confirming plotshape(rsicrossover, title="Short exit or Buy Entry", style=shape.labelup, location=LabelLocation.BELOW_BAR, color=color.green, size=size.tiny, text="BUY", textcolor=color.white); plotshape(rsicrossunder, title="Bull exit or Short entry", style=shape.labeldown, location=LabelLocation.ABOVE_BAR, color=color.red, size=size.tiny, text="SELL", textcolor=color.white); def rec_high = Highest(high, 5); def rec_low = Lowest(low, 5); if rsicrossover { Alert(str.format("{0}: Exit SELL or BUY now\n Stoploss below {1}\n CMP {2}", GetSymbolName(), rec_low, close), Alert.freq_once_per_bar_close); } if rsicrossunder { Alert(str.format("{0}: Exit BUY or SELL now\n Stoploss above {1}\n CMP {2}", GetSymbolName(), rec_high, close), Alert.freq_once_per_bar_close); }
look pretty nice, i hope samer800 can help us here!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
333 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top