VWAP Scalp/Reversal Indicator for ThinkorSwim

RConner7

Member
Hello All -

The below TOS indicator attempts to determine likelihood of an upcoming reversal, pullback, or scalp opportunity from a 1 min chart. Could be used for .20 cent moves or potential full reversal points for a hold and run.

The indicator finds opportunities by candle formation, VWAP, and Intraday Momentum.

Yellow arrows = bounce in a up/down trend towards the current trend. If above VWAP and sharp pull back towards VWAP, it will look to find a location where it might bounce and continue higher/lower. These usually happen closer to VWAP.

Blue arrows = bounce from a low or high point in a up/downtrend back towards VWAP.

These point can also be used as points of trade failure to change from long to short or vise-versa.

This main has shown promise on the 1min charts.

Includes alerts as well.

40licn.png


O3HIzG.png


O6Ghez.png

Code:
#RCONNER7 - 4/2020
#VWAP REVERSAL/BOUNCE - CANDLE FORMATION
#v1

# Length of the candle's wick
def UpperWick = high - Max(open, close);
def LowerWick = Min(open, close) - low;
def FullLength = AbsValue(high - low);

# Length of the candle's body
def CandleBody = AbsValue(open - close);
def AvgBodyFull = Round((CandleBody / FullLength) * 100, 1);

def smallbody = if AvgBodyFull < 10 then 1 else 0;

#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));

def VWAP = price;
def UpperBand = price + numDevUp * deviation;
def LowerBand = price + numDevDn * deviation;

##True Range
input RangeGreater = .01;
def Range = TrueRangeindicator();
def OK_Range = if Range > RangeGreater then 1 else 0;

#IMI
input length = 21;
input smooth_length = 1;

def CloseOpenDiff = if close > open then close - open else 0;
def OpenCloseDiff = if close < open then open - close else 0;
def avgCloseOpen = Average(CloseOpenDiff, length);
def avgOpenClose = Average(OpenCloseDiff, length);

def IMI = avgCloseOpen / (avgCloseOpen + avgOpenClose) * 100;
#IMI.SetDefaultColor(GetColor(8));
def avgIMI = Average(IMI, smooth_length);

def IMI_VWAPLower = if low < LowerBand and avgIMI < 30 then 1 else 0;
def IMI_VWAPHigher = if high > UpperBand and avgIMI > 70 then 1 else 0;

def IMI_Low = if avgIMI < 30 then 1 else 0;
def IMI_High = if avgIMI > 70 then 1 else 0;

# Compare body to wicks
input CandleWickVar = 1.75;
def Hammer = (lowerWick / CandleBody >= CandleWickVar) and if smallbody then lowerwick > upperWick * candleWickVar else upperWick / CandleBody <= 1.33;
def STAR = (UpperWick / CandleBody >= CandleWickVar) and if smallbody then LowerWick * candleWickVar < UpperWick else (LowerWick / CandleBody <= 1.33);

#trend
input trendlookback = 10;
def uptrend = isAscending(open, trendlookback)[1];
def downtrend = isdescending(open, trendlookback)[1];

#lowest/Highest within
input HiLowLookback = 10;
def hh = high == Highest(high, HiLowLookback);
def ll = low == Lowest(low, HiLowLookback);

def bullVWAP = if open >= reference VWAP()."VWAP" and close >= reference VWAP()."VWAP" then 1 else 0;
def bearVWAP = if open <= reference VWAP()."VWAP" and close <= reference VWAP()."VWAP" then 1 else 0;

plot Hammer_Signal_IMI = Hammer and ll and bullVWAP and IMI_Low and OK_Range;
plot STAR_Signal_IMI = STAR and hh and bearVWAP and IMI_High and OK_Range;

#plot Hammer_Signal = Hammer and ll and bullVWAP and OK_Range and !Hammer_Signal_IMI and downtrend;
#plot STAR_Signal = STAR and hh and bearVWAP and OK_Range and !STAR_Signal_IMI and uptrend;

plot BullRev = Hammer and ll and IMI_VWAPLower and OK_Range;
plot BearRev = STAR and hh and IMI_VWAPHigher and OK_Range;

#Hammer_Signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Hammer_Signal.AssignValueColor(Color.GREEN );
Hammer_Signal_IMI.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Hammer_Signal_IMI.AssignValueColor(Color.YELLOW);
BullRev.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BullRev.AssignValueColor(Color.BLUE );

#STAR_Signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#STAR_Signal.AssignValueColor(Color.GREEN );
STAR_Signal_IMI.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
STAR_Signal_IMI.AssignValueColor(Color.YELLOW);
BearRev.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BearRev.AssignValueColor(Color.BLUE );

alert(Hammer_Signal_IMI or BullRev, "BUY BUY BUY", Alert.Bar, Sound.Bell);
alert(STAR_Signal_IMI or BearRev, "SELL SELL SELL", Alert.Bar, Sound.Ring);

aggregate min alerts on a lower min chart:

Code:
#RCONNER7 - 5/2020
#VWAP REVERSAL/BOUNCE - Priace Action Candles
#v2 - input forced aggregation - example -- set to 3min for alerts when viewing 1min chart
# agg total arrows should show. Proper entry to should done after low or high of those agg candles.

# Length of the candle's wick
input agg = aggregationPeriod.THREE_MIN;
def UpperWick = high(period = agg) - Max(open(period = agg), close(period = agg));
def LowerWick = Min(open(period = agg), close(period = agg)) - low(period = agg);
def FullLength = AbsValue(high(period = agg) - low(period = agg));

# Length of the candle's body
def CandleBody = AbsValue(open(period = agg) - close(period = agg));
def AvgBodyFull = Round((CandleBody / FullLength) * 100, 1);

def smallbody = if AvgBodyFull < 10 then 1 else 0;

#VWAP
def VWAP = reference VWAP()."VWAP";
def UpperBand = reference VWAP()."UpperBand";
def LowerBand = reference VWAP()."LowerBand";

##True Range
input RangeGreater = .02;
def Range = TrueRangeindicator();
def OK_Range = if Range > RangeGreater then 1 else 0;

#IMI
input length = 21;
#input smooth_length = 1;

def CloseOpenDiff = if close(period = agg) > open(period = agg) then close(period = agg) - open(period = agg) else 0;
def OpenCloseDiff = if close(period = agg) < open(period = agg) then open(period = agg) - close(period = agg) else 0;
def avgCloseOpen = Average(CloseOpenDiff, length);
def avgOpenClose = Average(OpenCloseDiff, length);

def IMI = avgCloseOpen / (avgCloseOpen + avgOpenClose) * 100;
#IMI.SetDefaultColor(GetColor(8));
#def avgIMI = Average(IMI, smooth_length);

def IMI_VWAPLower = if low(period = agg) < LowerBand and IMI < 30 then 1 else 0;
def IMI_VWAPHigher = if high(period = agg) > UpperBand and IMI > 70 then 1 else 0;

def IMI_Low = if IMI < 30 then 1 else 0;
def IMI_High = if IMI > 70 then 1 else 0;

# Compare body to wicks
input CandleWickVar = 1.76;
def Hammer = (lowerWick / CandleBody >= CandleWickVar) and if smallbody then lowerwick > upperWick * candleWickVar else upperWick / CandleBody <= 1.33;
def STAR = (UpperWick / CandleBody >= CandleWickVar) and if smallbody then LowerWick * candleWickVar < UpperWick else (LowerWick / CandleBody <= 1.33);

#trend
#input trendlookback = 10;
#def uptrend = isAscending(open, trendlookback)[1];
#def downtrend = isdescending(open, trendlookback)[1];

#lowest/Highest within
input HiLowLookback = 10;
def hh = high(period = agg) == Highest(high(period = agg), HiLowLookback);
def ll = low(period = agg) == Lowest(low(period = agg), HiLowLookback);

def bullVWAP = if open(period = agg) >= VWAP and close(period = agg) >= VWAP then 1 else 0;
def bearVWAP = if open(period = agg) <= VWAP and close(period = agg) <= VWAP then 1 else 0;

plot Hammer_Signal_IMI = Hammer and ll and bullVWAP and IMI_Low and OK_Range;
plot STAR_Signal_IMI = STAR and hh and bearVWAP and IMI_High and OK_Range;

#plot Hammer_Signal = Hammer and ll and bullVWAP and OK_Range and !Hammer_Signal_IMI and downtrend;
#plot STAR_Signal = STAR and hh and bearVWAP and OK_Range and !STAR_Signal_IMI and uptrend;

plot BullRev = Hammer and ll and IMI_VWAPLower and OK_Range;
plot BearRev = STAR and hh and IMI_VWAPHigher and OK_Range;

#Hammer_Signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Hammer_Signal.AssignValueColor(Color.GREEN );
Hammer_Signal_IMI.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Hammer_Signal_IMI.AssignValueColor(Color.YELLOW);
BullRev.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#BullRev.AssignValueColor(Color.BLUE );

#STAR_Signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#STAR_Signal.AssignValueColor(Color.GREEN );
STAR_Signal_IMI.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#STAR_Signal_IMI.AssignValueColor(Color.YELLOW);
BearRev.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#BearRev.AssignValueColor(Color.BLUE );

alert(Hammer_Signal_IMI or BullRev, "3MIN BUY BUY BUY", Alert.Bar, Sound.Bell);
alert(STAR_Signal_IMI or BearRev, "3MIN SELL SELL SELL", Alert.Bar, Sound.Ring);
 
Last edited:

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

Your timing couldn't have been more perfect. Just last night I started thinking to myself "I might revisit using the VWAP for a while". Love it
 
@TradeUp

keep in mind that won't show many trades throughout the day. Possibly 1-3 if any. I know for sure $NAT and $AMD had signals today if you want to verify.

this was $NAT
HF2ilR.png


this was $AMD:
C7moaM.png
 
Last edited:
caught a nice retrace in $INO
cdyPJB.png


Updating on how this INO played out:
TEIhgp.png


The initial image was the first move higher (first retrace). You could have then taken the short break of $13.72. Followed by the signaled retracement from $12.76.

Keep in mind they don't always work this pretty but this is the trades this indicator is looking to provide.

Some trading knowledge would still be required as far as averaging in if the reversal doesn't happen immediately or when to switch from the long side to the short (or vise-versa)... this is knowledge i am personally still trying to obtain.
 
Last edited:
@RConner7 Thats good news. I trade with 2000t chart. It does show a signal for today and it is spot on, but it also missed a lot of the reversals.

Let me know if I can help in any way.

XjiDzLw.png
 
Thats good news. I trade with 2000t chart. It does show a signal for today and it is spot on, but it also missed a lot of the reversals.

Right. It won’t currently get all reversals. It only catches the reversals based on certain candle criteria.
 
Do you have any statistics for backtesting of wins vs losses?
Nope. No backtesting or attempts to turn into a strategy. I’ve just visually looked back through charts and observed.

I don’t have a clear profit taking goal defined as of yet to help create a full strategy; not saying it can’t be done. It’s a very recent indicator and could use some tweaking im sure.
 
i can't actually see the vwrap on the chart is it invisible ? and can someone explain what filters are involved in the signals?
 

i can't actually see the vwrap on the chart is it invisible ? and can someone explain what filters are involved in the signals?
The VWAP isn't active in the indicator itself but you can add it as a separate indicator if you'd like. This indicator uses the upper and lower deviation bands if you'd like to keep those active as well (most don't). I didn't keep the VWAP active on the indicator because a lot of people like to keep their charts clean and it can always be added in as a 2nd indicator.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
215 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