I got tired of changing the date on the Anchored VWAP and so here is the
Thanks to a Prakash study with Converted by Sam4Cook; I was able to revamp it to a VWAP line only.
AGAIG As Good As It Gets
Auto Anchored VWAP
Auto Anchored VWAP
Thanks to a Prakash study with Converted by Sam4Cook; I was able to revamp it to a VWAP line only.
Ruby:
# Indicator for TOS
#study(title="Buy/Sell by Prakash EEE", overlay=true)
# Converted by Sam4Cok@Samer800 - 07/2024
#Revamped by C.artType.AREA Ricks to show VWAP only 5/3024
input filterSelect = {Default "Moving Average", "VWAP", "MA & VWAP", "Don't use Filter"};
input source = close; #(defval=close, title="Source")
input fastPeriod = 27; #(defval=27, minval=1, title="Fast period")
input slowPeriod = 55; #, minval=1, title="Slow period")
input fastMultiplier = 1.6; #(defval=1.6, minval=0.1, title="Fast range")
input slowMultiplier = 2.0; #(defval=2, minval=0.1, title="Slow range")
input showRangeFilterLine= yes;
input showVwapLine = yes;
input vwapTimeFrame = {default DAY, WEEK, MONTH};
def na = Double.NaN;
def quickEMA = ExpAverage(source, 9);
def wap = Reference vwap(timeFrame = vwapTimeFrame).price;
DefineGlobalColor("blue" , CreateColor(33,150,243));
DefineGlobalColor("orange" , CreateColor(255,152,0));
#smoothrng(x, t, m)
script smoothrng {
input src = close;
input per = 100;
input mult = 3;
def wper = per * 2 - 1;
def srcDif = AbsValue(src - src[1]);
def avrng = ExpAverage(srcDif, per);
def smoothrng = ExpAverage(avrng, wper) * mult;
plot result = smoothrng;
}
#// Range Filter
#rngfilt(x, r) =>
script rngfilt {
input src = close;
input r = 0;
def rngfilt = CompoundValue(1, if !rngfilt[1] then src else
if src > rngfilt[1] then
if (src - r) < rngfilt[1] then rngfilt[1] else (src - r) else
if (src + r) > rngfilt[1] then rngfilt[1] else (src + r), src);
plot result = rngfilt;
}
def smrng1 = smoothrng(source, fastPeriod, fastMultiplier);
def smrng2 = smoothrng(source, slowPeriod, slowMultiplier);
def smrng = (smrng1 + smrng2) / 2;
def filt = rngfilt(source, smrng);
def filterUp; def filterDn;
Switch (filterSelect) {
Case "VWAP" :
filterUp = filt > wap;
filterDn = filt < wap;
Case "MA & VWAP" :
filterUp = filt > quickEMA and filt > wap;
filterDn = filt < quickEMA and filt < wap;
Case "Don't use Filter" :
filterUp = yes;
filterDn = yes;
Default :
filterUp = filt > quickEMA;
filterDn = filt < quickEMA;
}
def upward = if filt > filt[1] then upward[1] + 1 else
if filt < filt[1] then 0 else upward[1];
def downward = if filt < filt[1] then downward[1] + 1 else
if filt > filt[1] then 0 else downward[1];
def col = if upward > 0 then 1 else if downward > 0 then -1 else 0;
def longCond = source > filt and source > source[1] and upward > 0 and filterUp;
def shortCond = source < filt and source < source[1] and downward > 0 and filterDn;
def CondIni = if longCond then 1 else if shortCond then -1 else CondIni[1];
def long = longCond and CondIni[1] == -1;
def short = shortCond and CondIni[1] == 1;
plot vwapLine = if showVwapLine then wap else na;
vwapLine.SetDefaultColor(Color.Yellow);
#-- END of CODE
Last edited by a moderator: