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);
[/CODE
[QUOTE="germanburrito, post: 50509, member: 7382"]
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.
[ATTACH type="full" alt="Mdr7RZp.png"]9258[/ATTACH]
[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);