RSI-VWAP Indicator for ThinkorSwim

germanburrito

Active member
In honor of GME going to 300 I'm sharing a script that uses the RSI instead of price for the VWAP. I use it on the today 5 minute graph if anyone knows how to set it up daily, weekly or monthly it would be great.

Mdr7RZp.png


Code:
declare lower;

input length = 14;
input price = close;
input averageType = AverageType.simple;
input ratio = 2.236;
DefineGlobalColor("RisingMA", color.uptick);
DefineGlobalColor("FallingMA", color.downtick);

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;

def RSI = 50 * (ChgRatio + 1);


def o = (RSI + RSI[1]) / 2;

def h = Max(RSI, RSI[1]);

def l = Min(RSI, RSI[1]);

def c = RSI;

def hl2 = (h+l)/2;
AddChart(high = h, low = l, open = o, close = c, type = ChartType.CANDLE, Color.WHITE);
input charttype = ChartType.CANDLE;


def Data = BarNumber();
input Number_Of_Bar = 1;

def bar =  Data >= Number_Of_Bar;
def pv = if bar then pv[1] + hl2 * volume else 0;
def cumvolume = if bar then cumvolume[1] + volume else 0;
plot vw = pv / cumvolume;
def bars = Data - Number_Of_Bar;
def sample = if bar then sample[1] + Sqr(hl2 - vw) else 0;
def var = sample / bars;
def dev = Sqrt(var);

plot dev1 =  vw + (dev * ratio);
plot dev2 = vw - (dev * ratio);

vw.setdefaultColor(color.yellow);
dev1.SetDefaultColor(Color.White);
dev2.SetDefaultColor(Color.White);


dev1.Setlineweight(2);
dev2.Setlineweight(2);


vw.SetLineWeight(3);
#vw.AssignValueColor(if rsi > vw
                           #then color.light_GREEN
                           #else color.light_RED);
 
Hello German, When I Plotted your indicator , I didn't get the RED & Green MA ? So I added a simple 3 per smoothing of the hl2 value of the RSI

I also took out your ratio for the Dev Channels and added a 1 st dev channel, added clouds this is my amended version
Code:
declare lower;

input length = 14;
input price = close;
input averageType = AverageType.simple;
Input smooth = 3;
DefineGlobalColor("RisingMA", color.uptick);
DefineGlobalColor("FallingMA", color.downtick);

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;

def RSI = 50 * (ChgRatio + 1);

def o = (RSI + RSI[1]) / 2;

def h = Max(RSI, RSI[1]);

def l = Min(RSI, RSI[1]);

def c = RSI;

def hl2 = (h+l)/2;
Plot RSPlain = hl2;
RSPlain.SetPaintingStrategy(PaintingStrategy.Line);
RSPlain.SetLineWeight(2);
RSPlain.AssignValueColor( if RSPlain>RSPlain[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
Plot RSAVG = MovingAverage(averageType,hl2,Smooth);
RSAvg.SetPaintingStrategy(PaintingStrategy.Line);
RSAvg.SetLineWeight(2);
RSAvg.AssignValueColor( if RSAvg>RSAvg[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
AddCloud(RSPlain,RSAvg,GlobalColor("RisingMA"),GlobalColor("FallingMA"));
AddChart(high = h, low = l, open = o, close = c, type = ChartType.CANDLE, Color.WHITE);
input charttype = ChartType.CANDLE;

def Data = BarNumber();
input Number_Of_Bar = 1;

def bar =  Data >= Number_Of_Bar;
def pv = if bar then pv[1] + hl2 * volume else 0;
def cumvolume = if bar then cumvolume[1] + volume else 0;
plot vw = pv / cumvolume;
def bars = Data - Number_Of_Bar;
def sample = if bar then sample[1] + Sqr(hl2 - vw) else 0;
def var = sample / bars;
def dev = Sqrt(var);

plot Udev1 =  vw + (dev * 1);
plot Ldev1 = vw - (dev * 1);
plot Udev2 =  vw + (dev * 2);
plot Ldev2 = vw - (dev * 2);

#vw.setdefaultColor(color.yellow);
Udev1.SetDefaultColor(Color.Yellow);
Udev2.SetDefaultColor(Color.Yellow);
Udev1.SetPaintingStrategy(PaintingStrategy.dashes);
Udev2.SetPaintingStrategy(PaintingStrategy.dashes);
Udev1.Setlineweight(1);
Udev2.Setlineweight(1);
Ldev1.SetDefaultColor(Color.Yellow);
Ldev2.SetDefaultColor(Color.Yellow);
Ldev1.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev2.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev1.Setlineweight(1);
Ldev2.Setlineweight(1);
vw.SetLineWeight(3);
vw.AssignValueColor(if rsi > vw
                           then color.light_GREEN
                           else color.light_RED);
 
Last edited:
Hello German, I made a few revisions to your code, I added a Cloud, I also removed the ratio for the Deviation bands and made them 1 & 2 standard deviations. I'm not seeing much of a difference with the miniscule amount 2.236 and 2
 
Hello German, When I Plotted your indicator , I didn't get the RED & Green MA ? So I added a simple 3 per smoothing of the hl2 value of the RSI

I also took out your ratio for the Dev Channels and added a 1 st dev channel, added clouds this is my amended version
Code:
declare lower;

input length = 14;
input price = close;
input averageType = AverageType.simple;
Input smooth = 3;
DefineGlobalColor("RisingMA", color.uptick);
DefineGlobalColor("FallingMA", color.downtick);

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;

def RSI = 50 * (ChgRatio + 1);

def o = (RSI + RSI[1]) / 2;

def h = Max(RSI, RSI[1]);

def l = Min(RSI, RSI[1]);

def c = RSI;

def hl2 = (h+l)/2;
Plot RSPlain = hl2;
RSPlain.SetPaintingStrategy(PaintingStrategy.Line);
RSPlain.SetLineWeight(2);
RSPlain.AssignValueColor( if RSPlain>RSPlain[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
Plot RSAVG = MovingAverage(averageType,hl2,Smooth);
RSAvg.SetPaintingStrategy(PaintingStrategy.Line);
RSAvg.SetLineWeight(2);
RSAvg.AssignValueColor( if RSAvg>RSAvg[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
AddCloud(RSPlain,RSAvg,GlobalColor("RisingMA"),GlobalColor("FallingMA"));
AddChart(high = h, low = l, open = o, close = c, type = ChartType.CANDLE, Color.WHITE);
input charttype = ChartType.CANDLE;

def Data = BarNumber();
input Number_Of_Bar = 1;

def bar =  Data >= Number_Of_Bar;
def pv = if bar then pv[1] + hl2 * volume else 0;
def cumvolume = if bar then cumvolume[1] + volume else 0;
plot vw = pv / cumvolume;
def bars = Data - Number_Of_Bar;
def sample = if bar then sample[1] + Sqr(hl2 - vw) else 0;
def var = sample / bars;
def dev = Sqrt(var);

plot Udev1 =  vw + (dev * 1);
plot Ldev1 = vw - (dev * 1);
plot Udev2 =  vw + (dev * 2);
plot Ldev2 = vw - (dev * 2);

#vw.setdefaultColor(color.yellow);
Udev1.SetDefaultColor(Color.Yellow);
Udev2.SetDefaultColor(Color.Yellow);
Udev1.SetPaintingStrategy(PaintingStrategy.dashes);
Udev2.SetPaintingStrategy(PaintingStrategy.dashes);
Udev1.Setlineweight(1);
Udev2.Setlineweight(1);
Ldev1.SetDefaultColor(Color.Yellow);
Ldev2.SetDefaultColor(Color.Yellow);
Ldev1.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev2.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev1.Setlineweight(1);
Ldev2.Setlineweight(1);
vw.SetLineWeight(3);
vw.AssignValueColor(if rsi > vw
                           then color.light_GREEN
                           else color.light_RED);
@henry1224, @germanburrito I am using this indicator for few days and it's really giving amazing results. Is there any way you can add two
input averageType = AverageType.simple;
Input smooth = 3;
I would like to add input smooth 3 and 13 so that I will get a more clear indication for an entry point. Thank you very much in advance.
 
@henry1224, @germanburrito I am using this indicator for few days and it's really giving amazing results. Is there any way you can add two
input averageType = AverageType.simple;
Input smooth = 3;
I would like to add input smooth 3 and 13 so that I will get a more clear indication for an entry point. Thank you very much in advance.
Hello Astro_phx,

I added RSAvg as a smoother & Signal. My question to you , Do you want me to smooth the RSI and then add a signal of that smoothed signal?

My thoughts about smoothing is similar to sanding wood, you want to just take off enough ,a little at a time
 
Hello Astro_phx,

I added RSAvg as a smoother & Signal. My question to you , Do you want me to smooth the RSI and then add a signal of that smoothed signal?

My thoughts about smoothing is similar to sanding wood, you want to just take off enough ,a little at a time
Hello Henry1224 thank you for a quick reply. The existing indicator is good but if you could just add an option to slow the fast average that would be great. I am attaching an image to explain my question. I added a length of rsi 21 and smoothed it with 144 so if you see a quick line that seems like some kind of fast average turning green and red line (which is generating cloud area when it crossover to smoothen avg). if we get some kind of option to slow the average that would be great. Right now it looks like it's moving along with rsi candles with avg 1 but if we can make that avg 5 or option to make a different avg length that would be great. Thank you very much again.

Here is the link to see the image.

sJpXC9G.jpeg
 
Last edited:
so you just want he rsi average.

Code:
declare lower;

input length = 14;
input price = close;
input averageType = AverageType.simple;
Input smooth = 3;
DefineGlobalColor("RisingMA", color.uptick);
DefineGlobalColor("FallingMA", color.downtick);

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;

def RSI = 50 * (ChgRatio + 1);

def o = (RSI + RSI[1]) / 2;

def h = Max(RSI, RSI[1]);

def l = Min(RSI, RSI[1]);

def c = RSI;

def hl2 = (h+l)/2;
Plot RSPlain = hl2;
RSPlain.SetPaintingStrategy(PaintingStrategy.Line);
RSPlain.SetLineWeight(2);
RSPlain.AssignValueColor( if RSPlain>RSPlain[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
Plot RSAVG = MovingAverage(averageType,hl2,Smooth);
RSAvg.SetPaintingStrategy(PaintingStrategy.Line);
RSAvg.SetLineWeight(2);
RSAvg.AssignValueColor( if RSAvg>RSAvg[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
AddCloud(RSPlain,RSAvg,GlobalColor("RisingMA"),GlobalColor("FallingMA"));
AddChart(high = h, low = l, open = o, close = c, type = ChartType.CANDLE, Color.WHITE);
input charttype = ChartType.CANDLE;

def Data = BarNumber();
input Number_Of_Bar = 1;

def bar =  Data >= Number_Of_Bar;
def pv = if bar then pv[1] + hl2 * volume else 0;
def cumvolume = if bar then cumvolume[1] + volume else 0;
plot vw = pv / cumvolume;
def bars = Data - Number_Of_Bar;
def sample = if bar then sample[1] + Sqr(hl2 - vw) else 0;
def var = sample / bars;
def dev = Sqrt(var);

plot Udev1 =  vw + (dev * 1);
plot Ldev1 = vw - (dev * 1);
plot Udev2 =  vw + (dev * 2);
plot Ldev2 = vw - (dev * 2);

#vw.setdefaultColor(color.yellow);
Udev1.SetDefaultColor(Color.Yellow);
Udev2.SetDefaultColor(Color.Yellow);
Udev1.SetPaintingStrategy(PaintingStrategy.dashes);
Udev2.SetPaintingStrategy(PaintingStrategy.dashes);
Udev1.Setlineweight(1);
Udev2.Setlineweight(1);
Ldev1.SetDefaultColor(Color.Yellow);
Ldev2.SetDefaultColor(Color.Yellow);
Ldev1.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev2.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev1.Setlineweight(1);
Ldev2.Setlineweight(1);
vw.SetLineWeight(3);
vw.AssignValueColor(if rsi > vw
                           then color.light_GREEN
                           else color.light_RED);

input length2 = 10;
plot average = average(rsi,Length2);
average.Setlineweight(3);
 
Last edited:
so you just want he rsi average.

Code:
declare lower;

input length = 14;
input price = close;
input averageType = AverageType.simple;
Input smooth = 3;
DefineGlobalColor("RisingMA", color.uptick);
DefineGlobalColor("FallingMA", color.downtick);

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;

def RSI = 50 * (ChgRatio + 1);

def o = (RSI + RSI[1]) / 2;

def h = Max(RSI, RSI[1]);

def l = Min(RSI, RSI[1]);

def c = RSI;

def hl2 = (h+l)/2;
Plot RSPlain = hl2;
RSPlain.SetPaintingStrategy(PaintingStrategy.Line);
RSPlain.SetLineWeight(2);
RSPlain.AssignValueColor( if RSPlain>RSPlain[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
Plot RSAVG = MovingAverage(averageType,hl2,Smooth);
RSAvg.SetPaintingStrategy(PaintingStrategy.Line);
RSAvg.SetLineWeight(2);
RSAvg.AssignValueColor( if RSAvg>RSAvg[1] then GlobalColor("RisingMa") else GlobalColor("FallingMa"));
AddCloud(RSPlain,RSAvg,GlobalColor("RisingMA"),GlobalColor("FallingMA"));
AddChart(high = h, low = l, open = o, close = c, type = ChartType.CANDLE, Color.WHITE);
input charttype = ChartType.CANDLE;

def Data = BarNumber();
input Number_Of_Bar = 1;

def bar =  Data >= Number_Of_Bar;
def pv = if bar then pv[1] + hl2 * volume else 0;
def cumvolume = if bar then cumvolume[1] + volume else 0;
plot vw = pv / cumvolume;
def bars = Data - Number_Of_Bar;
def sample = if bar then sample[1] + Sqr(hl2 - vw) else 0;
def var = sample / bars;
def dev = Sqrt(var);

plot Udev1 =  vw + (dev * 1);
plot Ldev1 = vw - (dev * 1);
plot Udev2 =  vw + (dev * 2);
plot Ldev2 = vw - (dev * 2);

#vw.setdefaultColor(color.yellow);
Udev1.SetDefaultColor(Color.Yellow);
Udev2.SetDefaultColor(Color.Yellow);
Udev1.SetPaintingStrategy(PaintingStrategy.dashes);
Udev2.SetPaintingStrategy(PaintingStrategy.dashes);
Udev1.Setlineweight(1);
Udev2.Setlineweight(1);
Ldev1.SetDefaultColor(Color.Yellow);
Ldev2.SetDefaultColor(Color.Yellow);
Ldev1.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev2.SetPaintingStrategy(PaintingStrategy.dashes);
Ldev1.Setlineweight(1);
Ldev2.Setlineweight(1);
vw.SetLineWeight(3);
vw.AssignValueColor(if rsi > vw
                           then color.light_GREEN
                           else color.light_RED);

input length2 = 10;
plot average = average(rsi,Length);
average.Setlineweight(3);
@germanburrito Exactly!!! thank you very much. This is what I was looking for. Only one issue happening. When I change input length2 from 10 to3 or 5 it's not changing to that avg price. It just remains the same as the default. Can you please look at it and it would be great if you can fix it. Thank you again.
 
@germanburrito Exactly!!! thank you very much. This is what I was looking for. Only one issue happening. When I change input length2 from 10 to3 or 5 it's not changing to that avg price. It just remains the same as the default. Can you please look at it and it would be great if you can fix it. Thank you again.
oh there i fixed it, I would like to hear how you use this indicator and hy you changed the settings to 21 period as well as the time frames and you may use, we can exchange ideas if you like .
 
thank you @germanburrito it is working now. here how I use it. I use vwap on an upper study with slim ribbon and ichimoku kijun for profit booking or stop loss on the lower studies I use macd_BB and the study discussed here rsivwap (length 13 and smooth 21 and now length2=8)
1. entry short when price below vwap and rsivwap in red cloud take profit when macd_BB turn green.
2. entry long when price above vwap and rsivwap in green cloud take profit when macd_BB turns red.

i hope i explained it right. I am attaching image to show how it look.

 
thank you @germanburrito it is working now. here how I use it. I use vwap on an upper study with slim ribbon and ichimoku kijun for profit booking or stop loss on the lower studies I use macd_BB and the study discussed here rsivwap (length 13 and smooth 21 and now length2=8)
1. entry short when price below vwap and rsivwap in red cloud take profit when macd_BB turn green.
2. entry long when price above vwap and rsivwap in green cloud take profit when macd_BB turns red.

i hope i explained it right. I am attaching image to show how it look.

thanks for that ill try out those settings, what was the average for?
 
thanks for that ill try out those settings, what was the average for?
If the average is below rsi vwap trend get stronger for sell and above for buy. also if you see if average gets near vwap level 2 then there is a strong chance of price retrace but that is mostly happening in the futures not in stocks since stocks can just keep going with the trend. :)
 
If the average is below rsi vwap trend get stronger for sell and above for buy. also if you see if average gets near vwap level 2 then there is a strong chance of price retrace but that is mostly happening in the futures not in stocks since stocks can just keep going with the trend. :)
man this works great on a 4 hour day chart for stocks, wow man how did you discovered those settings? i understand those are fib numbers but great job man.
 
Thank you @germanburrito you guys with great script helped me so much. I just tried different settings and checked which one works best for trading. I hope you come up with more great new scripts and I will play with them.

https://twitter.com/astro_vadic

It would be great if you share your knowledge. Thank you very much for your kindness.

I tried it on 4 hours on stock and yes it really works great. There are a few other observations I just found out which I am sharing with you.
1. If you just keep kijun(setting 34) with just main vwap on 4 hours and check the crossover on it then you will find real good trending in any stock. this give really good trade on long of short both sides. I checked about 25 different large-cap stocks and all of them work great.
2. If you change some settings in rsivwap then it will work more efficiently in my view if you can edit this script by following settings I feel it will give better results.
if you take off RS ave and just make length2 settings to 3 then it automatically giving good crossover with smooth (21) if is giving really good entry points. Along with this if you could add lenth3 = 8 that will give another great trending indicator my point of view.

so along with just macd_BB rsivwapavg and vwap/kijun crossover this system will give great profits. in future if you could build up scanner of vwap/kijun scanner for 4 hours then it will give amazing results.

vwap/kijun crossover can be a great strategy too and I think it will give good backtesting results.

If there is any good scrip editor there who would like to help or if you get time to edit these It will be really great help for everyone.

I hope I am not asking too much since I don't know how to write scripts but I like playing with new settings and observed it on different stocks.

Thank you very much.
 

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
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