Join useThinkScript to post your question to a community of 21,000+ developers and traders.
# VWAP Bounce
# and a bunch of other things
# @Mashume
# 2021-02-03 V0.1
# Released to UseThinkScript Community
declare upper;
input timeFrame = {default DAY, WEEK, MONTH};
input display_bubbles = {default "yes", "no"};
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 entry = if (close[1] > VWAP[1] and close[2] > VWAP[2] )within 15 bars
and low < VWAP
and close > VWAP
and VWAP > VWAP[3]
and low[1] > VWAP[1] then low else double.nan;
entry.setPaintingStrategy(PaintingStrategy.ARROW_UP);
entry.SetDefaultColor(COLOR.DARK_ORANGE);
entry.setLineWeight(3);
AddChartBubble("time condition" = entry and display_bubbles, "price location" = low * 0.995, text = "VWAP BOUNCE", color = Color.LIME, up = No);
plot exit = if (close[1] < VWAP[1] and close[2] < VWAP[2]) within 15 bars
and high > VWAP
and Close < VWAP
and VWAP < VWAP[3]
and high[1] < VWAP[1] then high else double.nan;
exit.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);
exit.SetDefaultColor(COLOR.DARK_ORANGE);
exit.setLineWeight(3);
AddChartBubble("time condition" = exit and display_bubbles, "price location" = high * 1.005, text = "VWAP BOUNCE", color = Color.PINK);
plot brokenbull = if ((close[1] > VWAP[1] and close[2] > VWAP[2] )within 15 bars
and low < VWAP
and Close > VWAP
and VWAP > VWAP[3]
and low[1] > VWAP[1]) within 4 bars
and (max(close, open) < VWAP and max(close[1], open[1]) < VWAP[1])
then low else double.nan;
brokenbull.setPaintingStrategy(PaintingStrategy.ARROW_DOWN);
brokenbull.SetDefaultColor(COLOR.RED);
brokenbull.setlineWeight(3);
# AddChartBubble("time condition" = brokenbull, "price location" = low * 0.995, text = "BROKEN BULL", up = No, color = Color.YELLOW);
plot brokenbear = if ((close[1] < VWAP[1] and close[2] < VWAP[2]) within 15 bars
and high > VWAP
and CLOSE < VWAP
and VWAP < VWAP[3]
and high[1] < VWAP[1] ) within 4 bars
and (min(close, open) > VWAP and min(close[1], open[1]) > VWAP[1])
then low else double.nan;
brokenbear.setPaintingStrategy(PaintingStrategy.ARROW_UP);
brokenbear.SetDefaultColor(COLOR.GREEN);
brokenbear.setlineWeight(3);
# AddChartBubble("time condition" = brokenbear, "price location" = high * 1.005, text = "BROKEN BEAR", up = Yes, color = Color.YELLOW);
AssignPriceColor(if brokenbear or brokenbull then color.orange else color.current);
Great one. Thank you. Is there a way we can scan for this? Can you help me with scan for vwap bounce?I've got a vwap bounce upper study.
Code:# VWAP Bounce # and a bunch of other things # @Mashume # 2021-02-03 V0.1 # Released to UseThinkScript Community declare upper; input timeFrame = {default DAY, WEEK, MONTH}; input display_bubbles = {default "yes", "no"}; 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 entry = if (close[1] > VWAP[1] and close[2] > VWAP[2] )within 15 bars and low < VWAP and close > VWAP and VWAP > VWAP[3] and low[1] > VWAP[1] then low else double.nan; entry.setPaintingStrategy(PaintingStrategy.ARROW_UP); entry.SetDefaultColor(COLOR.DARK_ORANGE); entry.setLineWeight(3); AddChartBubble("time condition" = entry and display_bubbles, "price location" = low * 0.995, text = "VWAP BOUNCE", color = Color.LIME, up = No); plot exit = if (close[1] < VWAP[1] and close[2] < VWAP[2]) within 15 bars and high > VWAP and Close < VWAP and VWAP < VWAP[3] and high[1] < VWAP[1] then high else double.nan; exit.setPaintingStrategy(PaintingStrategy.ARROW_DOWN); exit.SetDefaultColor(COLOR.DARK_ORANGE); exit.setLineWeight(3); AddChartBubble("time condition" = exit and display_bubbles, "price location" = high * 1.005, text = "VWAP BOUNCE", color = Color.PINK); plot brokenbull = if ((close[1] > VWAP[1] and close[2] > VWAP[2] )within 15 bars and low < VWAP and Close > VWAP and VWAP > VWAP[3] and low[1] > VWAP[1]) within 4 bars and (max(close, open) < VWAP and max(close[1], open[1]) < VWAP[1]) then low else double.nan; brokenbull.setPaintingStrategy(PaintingStrategy.ARROW_DOWN); brokenbull.SetDefaultColor(COLOR.RED); brokenbull.setlineWeight(3); # AddChartBubble("time condition" = brokenbull, "price location" = low * 0.995, text = "BROKEN BULL", up = No, color = Color.YELLOW); plot brokenbear = if ((close[1] < VWAP[1] and close[2] < VWAP[2]) within 15 bars and high > VWAP and CLOSE < VWAP and VWAP < VWAP[3] and high[1] < VWAP[1] ) within 4 bars and (min(close, open) > VWAP and min(close[1], open[1]) > VWAP[1]) then low else double.nan; brokenbear.setPaintingStrategy(PaintingStrategy.ARROW_UP); brokenbear.SetDefaultColor(COLOR.GREEN); brokenbear.setlineWeight(3); # AddChartBubble("time condition" = brokenbear, "price location" = high * 1.005, text = "BROKEN BEAR", up = Yes, color = Color.YELLOW); AssignPriceColor(if brokenbear or brokenbull then color.orange else color.current);
Unfortunately, no. THIS script cannot be used in the Scan Hacker.Great one. Thank you. Is there a way we can scan for this? Can you help me with scan for vwap bounce?
Also it would be great if you can help me create similar for EMA bounce. Thanks in advance.
def periodIndx = getYyyyMmDd();
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));
def VWAP = price;
plot entry = if (close[1] > VWAP[1] and close[2] > VWAP[2])within 15 bars and low < VWAP and close > VWAP and VWAP > VWAP[3] and low[1] > VWAP[1] then low else double.nan;
#plot exit = if (close[1] < VWAP[1] and close[2] < VWAP[2]) within 15 bars and high > VWAP and Close < VWAP and VWAP < VWAP[3] and high[1] < VWAP[1] then high else double.nan;
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
N | Extend lines from high Relative Vol and Vwap at close script. | Questions | 0 | |
B | convergence / divergence 9ema to VWAP | Questions | 0 | |
B | Anchor VWAP to specific time of day | Questions | 2 | |
M | Anchored VWAP Premarket previous days | Questions | 1 | |
T | %VWAP Watchlist Column | 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.