VWAP Scalp/Reversal Indicator - 1min chart - for ThinkorSwim

R

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.






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:
U

uawgmsmco

New member
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
 
W

willohara131

New member
VIP
Very interesting I love trading 1min for scalp opportunities. I will have to give this a try!
 
T

Trading51

Active member
2019 Donor
Warehouse
@RConner7 Only blue arrows show up is that correct ?
 
K

KKaiser

Member
@RConner7 , uploaded the script. Can see anything like what you see on your screen. Any thoughts?
 
T

TradeUp

New member
2019 Donor
@RConner7 not showing up on my screen either. Can you share your chart? Thanks.
 
T

tradingit

New member
VIP
I like the High Low indicator...where could I find that?
 
R

RConner7

Member
@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


this was $AMD:
 
Last edited:
R

RConner7

Member
R

RConner7

Member
caught a nice retrace in $INO

Updating on how this INO played out:


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:
B

barbaros

Member
@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.

 
R

RConner7

Member
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.
 
B

barbaros

Member
Do you have any statistics for backtesting of wins vs losses?
 
R

RConner7

Member
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.
 
T

tabs999

New member
i can't actually see the vwrap on the chart is it invisible ? and can someone explain what filters are involved in the signals?
 

Top