AlexsOptions
New member
If you're uncertain of what exactly "VWAP Boulevard" refers to here is the idea
I am very new to thinkscript, not so much new to programming but have been having some troubles with 'scanning' back through the previous bars in order to find high volume days ( volume > 30day avg.) and was wondering if anyone has some insight or even a script that does something similar that I could attempt to modify.
Below is a script that shows the previous day's VWAP which I would believe should be easy to add another check for a higher than avg volume on that day. Just unsure of exactly how to do so.
Thanks in advance,
AlexsOptions
I am very new to thinkscript, not so much new to programming but have been having some troubles with 'scanning' back through the previous bars in order to find high volume days ( volume > 30day avg.) and was wondering if anyone has some insight or even a script that does something similar that I could attempt to modify.
Below is a script that shows the previous day's VWAP which I would believe should be easy to add another check for a higher than avg volume on that day. Just unsure of exactly how to do so.
Code:
#
# Plot Previous Days VWAP
# By XeoNoX via https://usethinkscript.com/
#
input numDevDn = -4.0;
input numDevUp = 4.0;
input timeFrame = {default DAY, WEEK, MONTH};
def cap = GetAggregationPeriod();
def errorInAggregation =
timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = GetYYYYMMDD();
def periodIndx;
switch (timeFrame) {
case DAY:
periodIndx = yyyyMmDd;
case WEEK:
periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);
case MONTH:
periodIndx = RoundDown(yyyyMmDd / 100, 0);
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;
if (isPeriodRolled) {
volumeSum = volume;
volumeVwapSum = volume * vwap;
volumeVwap2Sum = volume * Sqr(vwap);
} else {
volumeSum = CompoundValue(1, volumeSum[1] + volume, volume);
volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
volumeVwap2Sum = CompoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
plot VWAP = price;
def UpperBand = price + numDevUp * deviation;
def LowerBand = price + numDevDn * deviation;
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
plot PrevDayVWAP;
if showOnlyLastPeriod and !IsNaN(vwap(period = aggregationPeriod)[-1]) {
PrevDayVWAP = Double.NaN;
} else if volume(period = aggregationPeriod) > VolumeAvg(30) {
PrevDayVWAP = Highest(vwap(period = aggregationPeriod)[-displace], length);
} else
{
PrevDayVWAP = Double.NaN;
}
PrevDayVWAP.SetDefaultColor(GetColor(9));
PrevDayVWAP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Thanks in advance,
AlexsOptions
Last edited: