What kind of offset were you looking for besides by StdDev??Hello,
Does anyone know how to code a fixed offset VWAP? The one currently available only allows the upper and lower bands to be based off of standard deviations.
Thanks!
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
I’m looking for a fixed offset where I can displace the upper/lower band by a fixed dollar amount. For instance, the upper band would be $x above the VWAP.What kind of offset were you looking for besides by StdDev??
An error you would run into with this method would be that each ticker moves at different rates, so it would only be usable on certain stocks at a time and would NEED to be adjusted for each stock you want to pull up on your chart, which would be a waste of time to be honest. Similar to what @Playstation said I guess you could make it a 5% or a 10% offset in the bands to make it a tad more reliable on multiple tickers with little need to adjust, or set a multiplier X * ATR away from VWAP to use. The second would have similar to a bollinger band-esque style to it which would be kinda cool i guess. These would be my suggestions to make a more universal indicator with little need to tweak from asset to assetI’m looking for a fixed offset where I can displace the upper/lower band by a fixed dollar amount. For instance, the upper band would be $x above the VWAP.
Could you please share the script? I cannot use the link. ThanksTry this. I did something similar to setting up the offset for measuring gamma. Just place the input you want. For example, if you want to track $5 on either side, just put 5 for up, and -5 for down. https://tos.mx/VUHhgVu
Could you please share the script? I cannot use the link. Thanks
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;
plot LowerBand = price + numDevDn;
VWAP.setDefaultColor(getColor(0));
UpperBand.setDefaultColor(getColor(2));
LowerBand.setDefaultColor(getColor(4));
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
R | When adding Plot with EMA on Chart it doesn't stay fixed to bar. | Questions | 1 | |
S | Indicator with fixed range | Questions | 1 | |
![]() |
Fixed Price Risk/Reward & Targets | Questions | 4 | |
T | OnBalanceVolume fixed to a symbol | Questions | 2 | |
J | Fixed length Plot | Questions | 2 |
Start a new thread and receive assistance from our community.
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.
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.