allnetbrett
New member
Can someone help with this coding? I am not following. I have been trying to get a VWAP scan for the longest.... any help?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Hey guys, I saw this VWAP Indicator and thought it was really cool, but I have no idea how to recreate it?
Do you like it? Can someone tell me how to create it? (Or hopefully someone already has a code for it)
Thanks a million
input price = VWAP;
input length1 = 5;
input length2 = 25;
input AverageType1 = AverageType.SIMPLE;
input AverageType2 = AverageType.SIMPLE;
plot MA1 = MovingAverage(AverageType1, price, length1);
plot MA2 = MovingAverage(AverageType2, price, length2);
AddCloud(MA1, MA2, Color.GREEN, Color.RED, no);
input cumulativePeriod = 5;
input cumulativePeriod2 = 25;
def typicalPrice = (high + low + close) / 3;
def typicalPriceVolume = typicalPrice * volume;
def cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod);
def cumulativeVolume = sum(volume, cumulativePeriod);
plot VWAP1 = cumulativeTypicalPriceVolume / cumulativeVolume;
def typicalPrice2 = (high + low + close) / 3;
def typicalPriceVolume2 = typicalPrice2 * volume;
def cumulativeTypicalPriceVolume2 = sum(typicalPriceVolume2, cumulativePeriod2);
def cumulativeVolume2 = sum(volume, cumulativePeriod2);
plot VWAP2 = cumulativeTypicalPriceVolume2 / cumulativeVolume2;
AddCloud(VWAP1, VWAP2, Color.GREEN, Color.RED, no);
#Price crosses above 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 vwapValue = price;
plot crossingAbove = close[1] < vwapValue[1] and close > vwapValue;
crossingAbove.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
crossingAbove.SetDefaultColor(Color.CYAN);
crossingAbove.SetLineWeight(1);
Alert(crossingAbove[1], "Cross Above VWAP", Alert.BAR, Sound.Bell);
input priceLow = low;
input totalBars = 20;
def myVWAP = reference VWAP()."VWAP";
def lowsAboveVWAP = Lowest(priceLow,totalBars) > myVWAP;
plot scan = lowsAboveVWAP;
def cumulativeVWAP = reference VWAP;
plot scan = sum(low > cumulativeVWAP, 20) == 20;
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
RSI (or MACD) with VWAP & MA & div for ThinkOrSwim | Indicators | 11 | ||
J | High/Low Anchored VWAP For ThinkOrSwim | Indicators | 16 | |
Opening Range Indicator with Measured Moves and VWAP For ThinkOrSwim | Indicators | 43 | ||
RSI-VWAP Indicator for ThinkorSwim | Indicators | 68 | ||
Squeeze Clouds based on SMA and VWAP | Indicators | 7 |
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.