VWAP on Renko chart

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I'm using code from Mobius to plot an Anchored VWAP on Renko and Range Bar charts but am unable to get any cose for the deviation bands to work with these types of charts. it seems to be failing to calculate the deviation using this line of code, having defined volumevwap2sum, volumesum and price earlier.

deviation = Sqrt(Max(volumevwap2sum / volumesum - Sqr(price), 0));

Is that just a problem with using Renko and Range Bar charts?

Any help would be appreciated.


the AVWAP code I am using is

Code:
# VWAP Anchored to Date
# Mobius
# V01.01.2020

input date = 20220410;
input price = close;

def start = GetYYYYMMDD() >= date;
def sumV;
def sumCV;
if start and !start[1]
{
sumV = volume;
sumCV = close * volume;
}
else if start
{
sumV = sumV[1] + volume;
sumCV = sumCV[1] + (close * volume);
}
else
{
sumV = sumV[1];
sumCV = sumCV[1];
}
plot VWAP = sumCV / sumV;
 
I'm using code from Mobius to plot an Anchored VWAP on Renko and Range Bar charts but am unable to get any cose for the deviation bands to work with these types of charts. it seems to be failing to calculate the deviation using this line of code, having defined volumevwap2sum, volumesum and price earlier.

deviation = Sqrt(Max(volumevwap2sum / volumesum - Sqr(price), 0));

Is that just a problem with using Renko and Range Bar charts?

Any help would be appreciated.


the AVWAP code I am using is

Code:
# VWAP Anchored to Date
# Mobius
# V01.01.2020

input date = 20220410;
input price = close;

def start = GetYYYYMMDD() >= date;
def sumV;
def sumCV;
if start and !start[1]
{
sumV = volume;
sumCV = close * volume;
}
else if start
{
sumV = sumV[1] + volume;
sumCV = sumCV[1] + (close * volume);
}
else
{
sumV = sumV[1];
sumCV = sumCV[1];
}
plot VWAP = sumCV / sumV;
Almost nothing on this forum are gonna be for range or renko. Pretty much everything is gonna be time or tick based only. In the case of a vwap, the point of the system is to find the precise price/volume equilibrium over the specified length of time, if you remove any of those variables by looking at a "Range" of anything...it doesn't work and has no use
 
Last edited:
Almost nothing on this forum are gonna be for range or renko. Pretty much everything is gonna be time or tick based only. In the case of a vwap, the point of the system is to find the precise price/volume equilibrium over the specified length of time, if you remove any of those variables by looking at a "Range" of anything...it doesn't work and has no use
Thank you for your input, I agree that the VWAP is used primarily for time based charts, however I do disagree with your statement that it "does not work and has no use" on Renko or Range bar charts. It is my understanding that VWAP is calculated on a per bar basis irrespective of what type of bar that is, as it only uses the volume of that bar, the cumulative volume since the start of the current plot, and the price. Time is not a variable included in the basic calculation.

So as not to confuse anybody who may read this thread, the standard VWAP indicator on ToS will not work on Renko or Range bar charts, but several of the Anchored VWAP examples I have found on this forum that are "anchored " to a specific time of day, do work quite successfully for me on both Renko and Range bar charts. The only thing that I am having a problem with are the VWAP bands, which work on Time and Tick based charts, but I have not been able to get them to work on Renko and Range bar charts.
 
Good to know. Thanks. @Alex.
Renko is not based on Time, but Renko bricks do have Volume. I'm using this code successfully on Renko charts. The only problem is that you have to manually update the date every day. If you want to "anchor" to different times of the day, you need to search posts on this forum on "Anchored VWAP to Date and Time". I am using one of those for multiple timeframe VWAPS on my Renko charts.

Code:
# VWAP Anchored to Date
# Mobius
# V01.01.2020

input date = 20220410;
input price = close;

def start = GetYYYYMMDD() >= date;
def sumV;
def sumCV;
if start and !start[1]
{
sumV = volume;
sumCV = close * volume;
}
else if start
{
sumV = sumV[1] + volume;
sumCV = sumCV[1] + (close * volume);
}
else
{
sumV = sumV[1];
sumCV = sumCV[1];
}
plot VWAP = sumCV / sumV;
 
Thank you for your input, I agree that the VWAP is used primarily for time based charts, however I do disagree with your statement that it "does not work and has no use" on Renko or Range bar charts. It is my understanding that VWAP is calculated on a per bar basis irrespective of what type of bar that is, as it only uses the volume of that bar, the cumulative volume since the start of the current plot, and the price. Time is not a variable included in the basic calculation.

So as not to confuse anybody who may read this thread, the standard VWAP indicator on ToS will not work on Renko or Range bar charts, but several of the Anchored VWAP examples I have found on this forum that are "anchored " to a specific time of day, do work quite successfully for me on both Renko and Range bar charts. The only thing that I am having a problem with are the VWAP bands, which work on Time and Tick based charts, but I hav

If you can work with changing within the VWAP indicator the use of close rather than vwap within the volumesum... definitions then the following code will plot a possibly acceptable version of the VWAP indicator.

The upper panel is a range chart with the code below. The lower panels is both the standard VWAP indicator and also the revised version on a time based chart.

Capture.jpg
Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2011-2022
#

# Adjusted VWAP indicator to use price as close instead of vwap so that this approximate version of the VWAP indicator will plot on Range charts.

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;
def vwap = close;
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));
UpperBand.SetDefaultColor(GetColor(2));
LowerBand.SetDefaultColor(GetColor(4));
 
If you can work with changing within the VWAP indicator the use of close rather than vwap within the volumesum... definitions then the following code will plot a possibly acceptable version of the VWAP indicator.

The upper panel is a range chart with the code below. The lower panels is both the standard VWAP indicator and also the revised version on a time based chart.
Thanks, I appreciate it. I'll try that.
 
Thread starter Similar threads Forum Replies Date
T VWAP MA Trades -1st 2hrs Questions 0
S Close greater than VWAP ETH Questions 2
W Advanced VWAP Questions 8
Z Moving Average Cross When Above VWAP Questions 1
P Prior Day VWAP Questions 3

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
297 Online
Create Post

Similar threads

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.
Back
Top