VWAP Retest Indicator for ThinkorSwim

desiben

Member
VIP
I am looking for a retest script where the indicator tells me that it successfully retested a resistance, this resistance could be a EMA or a VWAP or anything.

Here is an example showing a VWAP retest

image.png


1. Breaks Down
2. Breaks up
3. Retesting VWAP
4. Bounced succesfully
 

iSultan

Member
VIP
Is there any indicator that show breakout and retest and give a alert about it . ?! For example breakout for point ( 1 ) and retest ( 2 ) , then will go up. It is hard to check all the stocks .

ZsuLxUu.png
 

BenTen

Administrative
Staff member
Staff
VIP
@iSultan Your question is similar to @desiben. These patterns are way too subjective to be incorporated into a scanner unless you can come up with a clear condition to define "breakout" and "retest."
 

mashume

Well-known member
VIP
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);
 

Similar threads

Top