Volume Weighted RSI For ThinkOrSwim

TTs_MikeC

New member
Decided to give it a shot and see if I could recreate it after recently playing with Pine Script. IMHO I think this indicator has a lot of redundancies, I do not use it to trade. However hopefully this helps somebody here. I hope I gave proper credit where due and wrote it out simply enough for people to modify as they see fit. Just for practice I added a bunch of customizable options for people as well.


Code:
### Adapted for UseThinkscript.com by TTsMikeC 5/6/2022
# Volume Weighted RSI
# idea from Lummox reference RedK Vol Weighted RSI on trading view:
#https://www.tradingview.com/script/BaTELgMy-RedK-Vol-Weighted-RSI-Extending-the-power-of-the-classic-RSI/
#
#hint Long_Rsi_Type: This setting adjusts the way the long RSI length is calculated.  Setting this to Auto will use "sentiment" to determine long RSI length.
#hint Long_Rsi_Sentiment: The factor for determining long RSI length.  Setting Long_Rsi_Type to "manual" will ignore this setting.
#hint Long_RSI_Length:  This setting is ignored if "Long RSI Type" is set to "Auto".
#hint Long_Rsi_Step:  Reduces long RSI plot readings to visualy show longer term conviction in place of actual reading.  Setting this to "1" will disply longer RSI actual.


declare lower;

input Price = close;
input RSI_Length = 10;
input Smoothing = 3;
input Avg_Type = AverageType.EXPONENTIAL;
input Long_Rsi_Type = {default "Manual" ,"Auto"};
input Long_Rsi_Sentiment = 3;
input Long_RSI_Length = 21;
input Long_Rsi_Step = .8;
input over_bought = 40;
input over_sold = -40;

## Short RSI Calc
def ShortUp = MovingAverage(averagetype = Avg_Type, if Price > Price[1] then Price * volume else 0, RSI_Length);
def ShortDown = MovingAverage(averagetype = Avg_Type, if Price < Price[1] then Price * volume else 0, RSI_Length);

def ShortRSI_Calc = 100 - (100 / (1 + ShortUp / ShortDown));
def ShortRSI_Fix = ShortRSI_Calc * 2 - 100;

## Long RSI
def Lrsi;
Switch (Long_Rsi_Type) {
    case Manual: Lrsi =  Long_Rsi_Length;
    case Auto: Lrsi = RSI_Length * Long_Rsi_Sentiment;}

def LongUp = MovingAverage(averagetype = Avg_Type, if Price > Price[1] then Price * volume else 0, Lrsi);
def LongDown = MovingAverage(averagetype = Avg_Type, if Price < Price[1] then Price * volume else 0, Lrsi);

def LongRSI_Calc = 100 - (100 / (1 + LongUp / LongDown));
def LongRSI_Fix = LongRSI_Calc * 2 - 100;

plot ShortRSI = MovingAverage(averagetype = Avg_Type, ShortRSI_Fix, Smoothing);
plot LongRSI = MovingAverage(averagetype = Avg_Type, LongRSI_Fix * Long_Rsi_Step, Smoothing);

ShortRSI.DefineColor("Positive", Color.CYAN);
ShortRSI.DefineColor("Negative", Color.ORANGE);
ShortRSI.AssignValueColor(if ShortRSI > 0 then ShortRSI.Color("Positive") else ShortRSI.Color("Negative"));
ShortRSI.setLineWeight(2);

LongRSI.DefineColor("Positive", Color.GREEN);
LongRSI.DefineColor("Negative", Color.RED);
LongRSI.AssignValueColor(if LongRSI > 0 then LongRSI.Color("Positive") else LongRSI.Color("Negative"));
LongRSI.setLineWeight(2);
AddCloud(LongRSI,0, color.green, color.red);

## Arrows
plot UpArrow = if ShortRSI > 0 and ShortRSI[1] < 0 then Over_sold else double.NaN;
plot DownArrow = if ShortRSI < 0 and ShortRSI[1] > 0 then Over_bought else double.NaN;

UpArrow.setPaintingStrategy(paintingStrategy.ARROW_UP);
UpArrow.setDefaultColor(color.GREEN);

DownArrow.setPaintingStrategy(paintingStrategy.ARROW_DOWN);
DownArrow.setDefaultColor(color.RED);

## scale/field
plot OverBought = over_bought;
plot MiddleLine = 0;
plot OverSold = over_sold;

OverBought.SetDefaultColor(color.GREEN);
OverBought.SetStyle(Curve.SHORT_DASH);
MiddleLine.SetDefaultColor(color.yellow);
MiddleLine.SetStyle(Curve.LONG_DASH);
OverSold.SetDefaultColor(color.RED);
OverSold.SetStyle(Curve.SHORT_DASH);

#END
@Lummox @astro_phx
 
Decided to give it a shot and see if I could recreate it after recently playing with Pine Script. IMHO I think this indicator has a lot of redundancies, I do not use it to trade. However hopefully this helps somebody here. I hope I gave proper credit where due and wrote it out simply enough for people to modify as they see fit. Just for practice I added a bunch of customizable options for people as well.


Code:
### Adapted for UseThinkscript.com by TTsMikeC 5/6/2022
# Volume Weighted RSI
# idea from Lummox reference RedK Vol Weighted RSI on trading view:
#https://www.tradingview.com/script/BaTELgMy-RedK-Vol-Weighted-RSI-Extending-the-power-of-the-classic-RSI/
#
#hint Long_Rsi_Type: This setting adjusts the way the long RSI length is calculated.  Setting this to Auto will use "sentiment" to determine long RSI length.
#hint Long_Rsi_Sentiment: The factor for determining long RSI length.  Setting Long_Rsi_Type to "manual" will ignore this setting.
#hint Long_RSI_Length:  This setting is ignored if "Long RSI Type" is set to "Auto".
#hint Long_Rsi_Step:  Reduces long RSI plot readings to visualy show longer term conviction in place of actual reading.  Setting this to "1" will disply longer RSI actual.


declare lower;

input Price = close;
input RSI_Length = 10;
input Smoothing = 3;
input Avg_Type = AverageType.EXPONENTIAL;
input Long_Rsi_Type = {default "Manual" ,"Auto"};
input Long_Rsi_Sentiment = 3;
input Long_RSI_Length = 21;
input Long_Rsi_Step = .8;
input over_bought = 40;
input over_sold = -40;

## Short RSI Calc
def ShortUp = MovingAverage(averagetype = Avg_Type, if Price > Price[1] then Price * volume else 0, RSI_Length);
def ShortDown = MovingAverage(averagetype = Avg_Type, if Price < Price[1] then Price * volume else 0, RSI_Length);

def ShortRSI_Calc = 100 - (100 / (1 + ShortUp / ShortDown));
def ShortRSI_Fix = ShortRSI_Calc * 2 - 100;

## Long RSI
def Lrsi;
Switch (Long_Rsi_Type) {
    case Manual: Lrsi =  Long_Rsi_Length;
    case Auto: Lrsi = RSI_Length * Long_Rsi_Sentiment;}

def LongUp = MovingAverage(averagetype = Avg_Type, if Price > Price[1] then Price * volume else 0, Lrsi);
def LongDown = MovingAverage(averagetype = Avg_Type, if Price < Price[1] then Price * volume else 0, Lrsi);

def LongRSI_Calc = 100 - (100 / (1 + LongUp / LongDown));
def LongRSI_Fix = LongRSI_Calc * 2 - 100;

plot ShortRSI = MovingAverage(averagetype = Avg_Type, ShortRSI_Fix, Smoothing);
plot LongRSI = MovingAverage(averagetype = Avg_Type, LongRSI_Fix * Long_Rsi_Step, Smoothing);

ShortRSI.DefineColor("Positive", Color.CYAN);
ShortRSI.DefineColor("Negative", Color.ORANGE);
ShortRSI.AssignValueColor(if ShortRSI > 0 then ShortRSI.Color("Positive") else ShortRSI.Color("Negative"));
ShortRSI.setLineWeight(2);

LongRSI.DefineColor("Positive", Color.GREEN);
LongRSI.DefineColor("Negative", Color.RED);
LongRSI.AssignValueColor(if LongRSI > 0 then LongRSI.Color("Positive") else LongRSI.Color("Negative"));
LongRSI.setLineWeight(2);
AddCloud(LongRSI,0, color.green, color.red);

## Arrows
plot UpArrow = if ShortRSI > 0 and ShortRSI[1] < 0 then Over_sold else double.NaN;
plot DownArrow = if ShortRSI < 0 and ShortRSI[1] > 0 then Over_bought else double.NaN;

UpArrow.setPaintingStrategy(paintingStrategy.ARROW_UP);
UpArrow.setDefaultColor(color.GREEN);

DownArrow.setPaintingStrategy(paintingStrategy.ARROW_DOWN);
DownArrow.setDefaultColor(color.RED);

## scale/field
plot OverBought = over_bought;
plot MiddleLine = 0;
plot OverSold = over_sold;

OverBought.SetDefaultColor(color.GREEN);
OverBought.SetStyle(Curve.SHORT_DASH);
MiddleLine.SetDefaultColor(color.yellow);
MiddleLine.SetStyle(Curve.LONG_DASH);
OverSold.SetDefaultColor(color.RED);
OverSold.SetStyle(Curve.SHORT_DASH);

#END
@Lummox @astro_phx
@TTs_MikeC great work!!! only one small suggestion. please look at the long rsi length again. it should look like avg. crossover that helps to book profits in the position. other than that all looks great.

I am attaching image link for the example

https://ibb.co/1bbvJLN
 
@TTs_MikeC great work!!! only one small suggestion. please look at the long rsi length again. it should look like avg. crossover that helps to book profits in the position. other than that all looks great.

I am attaching image link for the example

https://ibb.co/1bbvJLN
could you be more specific? are you referring to the choppiness of the long rsi line? If so adjusting the smoothing option would extend it a bit
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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