Merry Christmas useThinkScripters!
Today I want to introduce a very simple but very effective indicator. It is a custom Anchored VWAP that works based off a specific time.
The question this indicator answers is simple, are buyers mostly underwater or profitable based off the most recent rally. If buyers are mostly underwater, they are going to tend to want to get out and more likely to sell off the next rally. Pretty simple.
Likewise, if most traders are profitable, they will be more likely to defend dips and push rallies. Again, simple stuff.
The simplicity of this indicator is what makes it so powerful. Its not going to tell you whether or not to buy or sell, just whether or not market participants will be willing to support your thesis.
Code:
#
# Anchored VWAP (Exact Date + Time)
#
@Date
input beginDate = 20251215; # YYYYMMDD
input beginTime = 1030; # HHmm (24-hour clock, e.g. 0930 = open, 1600 = close)
def curDate = GetYYYYMMDD();
def seconds = SecondsFromTime(beginTime);
def isDate = curDate == beginDate;
def isStart = isDate and seconds >= 0 and seconds[1] < 0;
rec volumeSum =
if isStart then volume
else if curDate > beginDate or (isDate and seconds > 0)
then CompoundValue(1, volumeSum[1] + volume, Double.NaN)
else Double.NaN;
rec volumeVwapSum =
if isStart then volume * vwap
else if curDate > beginDate or (isDate and seconds > 0)
then CompoundValue(1, volumeVwapSum[1] + volume * vwap, Double.NaN)
else Double.NaN;
plot AVWAP = volumeVwapSum / volumeSum;
AVWAP.SetDefaultColor(GetColor(0));
AVWAP.SetLineWeight(2);