Triple VWAP Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Regular VWAP indicator with additional standard deviations added. Now you can use the 1 and 3 Stdev Bands along with the default standard deviation bands (set to 2). Requested by a member on the forum.

There is also an advanced version called Ultimate VWAP by @Welkin. You should check it out here.

zsPlgeQ.png


thinkScript Code

Code:
# VWAP(3)
# Assembled by BenTen at UseThinkScript.com

input numDevDn1 = -1.0;
input numDevUp1 = 1.0;
input numDevDn2 = -2.0;
input numDevUp2 = 2.0;
input numDevDn3 = -3.0;
input numDevUp3 = 3.0;
input showCloud = yes;

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;
plot UpperBand1 = price + numDevUp1 * deviation;
plot LowerBand1 = price + numDevDn1 * deviation;
plot UpperBand2 = price + numDevUp2 * deviation;
plot LowerBand2 = price + numDevDn2 * deviation;
plot Upperband3 = price + numDevUp3 * deviation;
plot LowerBand3 = price + numDevDn3 * deviation;

VWAP.setDefaultColor(getColor(6));
UpperBand1.setDefaultColor(getColor(9));
UpperBand1.setStyle(Curve.SHORT_DASH);
LowerBand1.setDefaultColor(getColor(9));
LowerBand1.setStyle(Curve.SHORT_DASH);
UpperBand2.setDefaultColor(getColor(9));
LowerBand2.setDefaultColor(getColor(9));

AddCloud(if showCloud then UpperBand2 else Double.NaN, Upperband3, color.light_green, color.light_green);
AddCloud(if showCloud then LowerBand2 else Double.NaN, LowerBand3, color.light_red, color.light_red);
 
Last edited:

sp9099

New member
VIP
I recollected SPX does not have volume as it is index , so this will not work for SPX) . Got it working for SPY . that is enough.
 

Mr_Wheeler

Active member
I created something like this but better. It has the VWAP line and 4 Std. Deviations lines that you configure in the study config menu.

I configured the lines's & label's colors to be organized by maching the order the colors are displayed with both the lines as well as the labels so you can quickly find each other. Red line, orange line, Purple line, orange line, red line - Red Labels, Orange labels, purple labels, orange labels, red labels.

https://usethinkscript.com/threads/...n-money-with-a-quick-glance.11107/#post-97310

You enter a budget in the study config and it spits out how much you'll lose at each of the lines. If you're wondering, yes, it does have stop-lost labels, but I disabled them for myself. If you want them then just toggle them in the config.

dZnIHr1.png
 
Last edited:

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
I got it to work on the 5, 15, min. How can I get it to work on the daily, weekly?
Having Problems? Does the MTF indicator appear to be not working or partially working when you load the study onto your chart?
A common error when using MTF indicators is trying to use a time frame that is lower than the chart you are posting it on. On the TOS platform, you can display data from a higher timeframe onto a lower timeframe but not the other way around.
https://tlc.thinkorswim.com/center/...hapter-11---Referencing-Secondary-Aggregation
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-58081
 

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top