Dynamic Sentiment RSI For ThinkOrSwim

Rajesuja

New member
VIP
Author states:
The Dynamic Sentiment RSI [UAlgo] is a technical analysis tool that combines the classic RSI (Relative Strength Index) concept with dynamic sentiment analysis, offering traders enhanced insights into market conditions. Unlike the traditional RSI, this indicator integrates volume weighting, sentiment factors, and smoothing features to provide a more nuanced view of momentum and potential market reversals. It is designed to assist traders in detecting overbought/oversold conditions, momentum shifts, and to generate potential buy or sell signals using crossover and crossunder techniques. By dynamically adjusting based on sentiment and volume factors, this RSI offers better adaptability to varying market conditions, making it suitable for different trading styles and timeframes.

This tool is particularly helpful for traders who wish to explore not only price movement but also the underlying market sentiment, offering a more comprehensive approach to momentum analysis. The sentiment factor amplifies the RSI's sensitivity to price shifts, making it easier to detect early signals of market reversals or the continuation of a trend.

0oOgPHu.png


Here is the original Tradingview code:
https://www.tradingview.com/script/b69mgjQg-Dynamic-Sentiment-RSI-UAlgo/

The new ThinkOrSwim code can be found in the next post.
 
Last edited by a moderator:

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

@samer800, can you help to convert Dynamic Sentiment RSI indicator to thinkscript. https://www.tradingview.com/script/b69mgjQg-Dynamic-Sentiment-RSI-UAlgo/

Thanks
check the below:

CSS:
#//Indicator for TOS
#// © UAlgo
#indicator(title = 'Dynamic Sentiment RSI [UAlgo]'
#Converted by Sam4Cok@Samer800    - 12/2024
declare lower;

input timeframe = AggregationPeriod.MIN;
input source = FundamentalType.CLOSE;     # 'Source'
input length = 14;                        # 'Length'
input sentimentFactor = 3;                # 'Sentiment Factor'
input smoothingPeriod = 3;                # 'Smoothing'
input volumeWeighted = yes;               # 'Volume Weighted?'
input stepSize = 5;                       # 'Step'

def na = Double.NaN;
def last = IsNaN(close);
def cap = GetAggregationPeriod();
def tf = Max(cap, timeframe);
def src = Fundamental(source, Period = tf);
script calculate_rsi {
    input source = close;
    input length = 14;
    input weight = 1;
    def change = (source - source[1]) * weight;
    def upward = WMA(Max(change , 0), length);
    def downward = WMA(- Min(change , 0), length);
    def rawRsi = if downward == 0 then 100 else if upward == 0 then 0 else 100 - 100 / (1 + upward / downward);
    def adjustedRsi = rawRsi * 2 - 100;
    plot out = adjustedRsi;
}
def weight = if volumeWeighted then volume(Period = tf) else 1;
def sentimentLength = sentimentFactor * length;
def rawRsiAdjusted = calculate_rsi(src, length, weight);
def sentimentAdjustedRsi = calculate_rsi(src, sentimentLength, weight);
def smoothedRsi = WMA(rawRsiAdjusted, smoothingPeriod);
def sentimentRsi = WMA(sentimentAdjustedRsi, smoothingPeriod);
def roundedSentimentRsi = if stepSize > 0 then Round(sentimentRsi / stepSize, 0) * stepSize else sentimentRsi;

#-- plot

plot smthRSI = smoothedRsi;
plot AdjtRSI = rawRsiAdjusted;
plot zero = if last then na else 0;
plot ob = if last then na else 40;
plot os = if last then na else -40;

smthRSI.SetLineWeight(2);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ob.SetDefaultColor(Color.DARK_GREEN);
os.SetDefaultColor(Color.DARK_RED);
zero.SetDefaultColor(Color.DARK_GRAY);
AdjtRSI.SetDefaultColor(Color.LIGHT_ORANGE);
smthRSI.AssignValueColor(if smoothedRsi >= 0 then Color.CYAN else Color.MAGENTA);

AddCloud(roundedSentimentRsi, 0, Color.UPTICK, Color.LIGHT_GRAY, yes);

#-- Signals
def signalUp = (0 Crosses Below smoothedRsi);
def signalDn = (0 Crosses Above smoothedRsi);

plot sigUp = if signalUp[-1] then -60 else na;
plot sigDn = if signalDn[-1] then 60 else na;

sigUp.SetPaintingStrategy(PaintingStrategy.SQUARES);
sigDn.SetPaintingStrategy(PaintingStrategy.SQUARES);
sigUp.SetDefaultColor(Color.GREEN);
sigDn.SetDefaultColor(Color.RED);

#-- END of CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
386 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