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

henry1224

Member
VIP
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:

henry1224

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

astro_phx

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

Member
VIP
@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
 

astro_phx

New member
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:

germanburrito

Active member
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:

astro_phx

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

Active member
@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 .
 

astro_phx

New member
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.

 

germanburrito

Active member
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?
 

astro_phx

New member
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. :)
 

germanburrito

Active member
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.
 

Similar threads

Top