• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

VWAP Volume Breakout Indicator for ThinkorSwim

BenTen

Administrative
Staff
VIP
@RichSprinkles Actually, I found the reason. It was due to the condition below:

Code:
def above_volume = Vol crosses above VolAvg;

I changed it to:

Code:
def above_volume = Vol > VolAvg;

And that seems to fix the issue. Recheck the code in the first post. I just updated it.
 

RichSprinkles

New member
@BenTen Yeah that totally fixes it. Great find and thanks a lot. Interesting how the crosses function doesn't work every time as it's essentially the same idea as greater than.
 

victorfvm

New member
2019 Donor
VIP
Hello Ben, All - Hope all is well. For the VWAP volume break out indicator. Would it be possible to add the criteria of the stock price and the VWAP being over the 200 MovAvgExponential value?? The idea is that the crossover signals would only bet triggered if the original criteria were met as well as the stock price and VWAP were over this 200 MovAvgExponential value. The premise is that the smaller time frame chart one looks at (3 minutes in my case) would have to be in an uptrend of sorts (above the 200 MovAvgExponential) value to trigger. Right now I can simulate the same by displaying the 200 EMA in the chart and just following my own guidelines criteria once a signal is triggered Or are you or one of the more savvy transcripts are just able to provide the scripting for it to add to the existing VWAP Volume Break Out indicator. Thanks for all your support. Victor.
 

BenTen

Administrative
Staff
VIP
@victorfvm Sure, that is possible. See the modified code below.

Up arrows are visible only if the candle crossing above VWAP has abnormal volume and the stock is currently above 200 EMA.

Code:
# VWAP Breakout Above Average Volume
# Assembled by BenTen at useThinkScript.com

input price_EMA = close;
input length_EMA = 200;
input displace_EMA = 0;
def AvgExp = ExpAverage(price_EMA[-displace_EMA], length_EMA);
def condition_ema = close > AvgExp;

# Start VWAP
input numDevDn = -2.0;
input numDevUp = 2.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;
#plot UpperBand = price + numDevUp * deviation;
#plot LowerBand = price + numDevDn * deviation;

VWAP.setDefaultColor(getColor(0));

# Start Volume
input length = 20;
def Vol = volume;
def VolAvg = Average(volume, length);

def above_volume = Vol > VolAvg;
def bullish_vwap = close crosses above VWAP;

plot bull = above_volume and bullish_vwap and condition_ema;
bull.AssignValueColor(Color.CYAN);
bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

def bearish_vwap = close crosses below VWAP;
plot bear = above_volume and bearish_vwap;
bear.AssignValueColor(Color.CYAN);
bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 

SMB777

New member
VIP
This breakout indicator identifies bullish and bearish trend when a candle crosses VWAP with abnormal volume. The way it defines high volume breakout is by using the Volume Average indicator with the length of 20 simple moving average. You can adjust this settings to your liking once you have the indicator added.

You will see a buy or sell signal when the breakout is detected.

ZMcN6hl.png

yfPBKbb.png


thinkScript Code

Code:
# VWAP Breakout Above Average Volume
# Assembled by BenTen at useThinkScript.com

# You are free to use this code for personal use, and make derivative works from it.
# You are NOT GRANTED permission to use this code (or derivative works) for commercial
# purposes which includes and is not limited to selling, reselling, or packaging with
# other commercial indicators. Headers and attribution in this code should remain as provided,
# and any derivative works should extend the existing headers.

# Start VWAP
input numDevDn = -2.0;
input numDevUp = 2.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;
#plot UpperBand = price + numDevUp * deviation;
#plot LowerBand = price + numDevDn * deviation;

VWAP.setDefaultColor(getColor(0));

# Start Volume
input length = 20;
def Vol = volume;
def VolAvg = Average(volume, length);

def above_volume = Vol > VolAvg;
def bullish_vwap = close crosses above VWAP;

plot bull = above_volume and bullish_vwap;
bull.AssignValueColor(Color.CYAN);
bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

def bearish_vwap = close crosses below VWAP;
plot bear = above_volume and bearish_vwap;
bear.AssignValueColor(Color.CYAN);
bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

Shareable Link

https://tos.mx/cK8isN
@BenTen is it possible to make this script to become active after first 30 min of market open?
 
Thread starter Similar threads Forum Replies Date
H Current VWAP with current volume Questions 3
K VWAP at a specific time Questions 5
desiben High low of VWAP in a Day Indicators 0
R VWAP OPEN line Questions 7
C VWAP Modification Experiment Questions 3

Similar threads

Top