VWAP Crosses, Format, Watchlist, Label, Scan for ThinkorSwim

I want to create a study that scans stocks that have touched the vwap upper band during the day. The only similar thing I could find was the VWAP_Scan that allowed me to see which stocks were above the upper band in the current moment. I want to see the ones that have touched it anytime during the day.
 

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

@Benjaminsabe When you say "upper band", what upper band are you referring to...??? You can code this right in the Stock Hacker Scanner, or you can reference a VWAP Study... You'll be scanning for "close crosses above upperband" or whatever the upper band plot happens to be named if using a Study... A study with two StdDev's is most likely what you want if using a Study...
 
Can anyone help me with a code, please? The original code Ben posted is awesome (thanks, Ben), as I use it on my desktop version religiously for entries. Not surprisingly, on mobile it does not have the ability to show the color change and only shows the VWAP value. In order to do what I want to do on mobile, I'm looking for a code that will only show the price if it is below VWAP. Therefore, if the price is above VWAP, I would like it to be left blank. I tried a few things myself, but didn't fully accomplish what I wanted. The last code I tried displayed a value of "1.00" if the price was below VWAP and "0.00" if it was above. It served my purpose to a certain extent since I could easily distinguish what was below VWAP, but it would be nice to have the actual price show instead of "1.00". Here's what I came up with. I realize the colors are irrelevant. I tried a code without the color changes, but it didn't produce anything. Thanks in advance for any help.

Code:
plot value = close < vwap();
AssignBackgroundColor(if close > vwap then Color.DARK_GREEN else if close < vwap then Color.DARK_RED else Color.Dark_ORANGE);
 
Can anyone help me with a code, please? The original code Ben posted is awesome (thanks, Ben), as I use it on my desktop version religiously for entries. Not surprisingly, on mobile it does not have the ability to show the color change and only shows the VWAP value. In order to do what I want to do on mobile, I'm looking for a code that will only show the price if it is below VWAP. Therefore, if the price is above VWAP, I would like it to be left blank. I tried a few things myself, but didn't fully accomplish what I wanted. The last code I tried displayed a value of "1.00" if the price was below VWAP and "0.00" if it was above. It served my purpose to a certain extent since I could easily distinguish what was below VWAP, but it would be nice to have the actual price show instead of "1.00". Here's what I came up with. I realize the colors are irrelevant. I tried a code without the color changes, but it didn't produce anything. Thanks in advance for any help.

Code:
plot value = close < vwap();
AssignBackgroundColor(if close > vwap then Color.DARK_GREEN else if close < vwap then Color.DARK_RED else Color.Dark_ORANGE);

Are you looking for:

Ruby:
plot value = if close < vwap() then close else Double.NaN;
 
Are you looking for:

Ruby:
plot value = if close < vwap() then close else Double.NaN;
Yes! Thank you, it worked perfectly! Looking back at my post, though, I wasn’t very clear on exactly what I was looking for. I wanted the VWAP value to show instead of the close. I simply replaced “close” with “vwap” and it does exactly what I want. Thanks again, I really appreciate your time 👊🏻
 
@Stockmaker All of those scan can be made very easily in the TOS Scanner... You know your criteria so all you need to do is combine calls to the VWAP and SMA Studies... Once you know how you won't be needing to rely on others to do your coding for you... Give it a try and if you have questions just ask...

Here is one scan to get you started... It's really just that easy...

X9SLPik.jpg
1) example was given by RAD..Thanks.
2) List of the stocks if the price is below VWAP& 200 SMA WITHIN last candle
correct or wrong? - : close crosses below reference VWAP."VWAP"
close crosses below SimpleMovingAvg("length" = 200)."SMA"
3) List of the stocks if the price is below VWAP and touching 200 SMA WITHIN last candle

correct or wrong? - : close crosses below reference VWAP."VWAP"
close crosses is equal to SimpleMovingAvg("length" = 200)."SMA"

4) List of the stocks if the price is above VWAP and touching 200 SMA WITHIN last candle

correct or wrong? - : close crosses above reference VWAP."VWAP"
close is equal to SimpleMovingAvg("length" = 200)."SMA"

or should I go with low in case of BELOW? Thanks.
 
I wanted to quickly know if the stock price is currently above or below VWAP (Volume Weighted Average Price). One of our developers were able to help me put together a watchlist column that shows just that. Here is what it looks like.

7P8f0QI.png


Notes:
  • Green means price is currently above VWAP
  • Red means price is currently below VWAP

thinkScript Code

Rich (BB code):
plot vwap = vwap();
AssignBackgroundColor(if close > vwap then Color.DARK_GREEN else if close < vwap then Color.DARK_RED else Color.Dark_ORANGE);

Credit:
  • WalkingBallista
@BenTen This is great thank you! Is there any way to delete the vwap price from the column and just leave the background color?
 
https://tos.mx/DaNgJNY
After you add this to your watchlist column, right click and edit formula. change Day aggregation to 1min. and it will show you exactly where price is relative to vwap in deviations. If youd like to change colors im sure you can manage to do that.
 
Loose the
Code:
input time_color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input VWAP_Color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input UpperBand_Color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input LowerBand_color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};

It's making the script slower and the code less efficient
 
So no watchlist option, huh? ...dang.....sux ;(
delete the AddLabel lines and replace with
Code:
assignBackgroundColor(
  if VWAP > close  and VWAP>VWAP[1] then Color.green else
  if VWAP > close  and VWAP<VWAP[1] then color.yellow else
  if VWAP < close  and VWAP<VWAP[1] then Color.red else
  if VWAP < close  and VWAP>VWAP[1] then Color.cyan else Color.black);
 
OK...so I finally got the watchlist column to follow and show when price is above or below the VWAP....
Problem:
The font changes color and background stays black. It's soooo much easier if the background changed colors not the text. I tried to re-program the colors but keep getting errors....

Anyways.....here is the code for the one I have, that so far worked 100% for me showing price above VWAP:

#VWAP_Label
input numDevDn = -2.0;
input numDevUp = 2.0;
input timeFrame = {default DAY, WEEK, MONTH};
input time = yes;
input time_color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input VWAP_label = yes;
input VWAP_Color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input Upperbands_label = Yes;
input UpperBand_Color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input Lowerbands_label = Yes;
input LowerBand_color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};

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 UpperBand = price + numDevUp * deviation;
UpperBand.hide();
plot LowerBand = price + numDevDn * deviation;
LowerBand.hide();

AddLabel(VWAP_label, " VWAP: " + Round(VWAP, 2), if vwap<close then color.green else color.red);


And here is what I would love to see would look like!!!!! Can't figure it out......Matter of fact, I just want the colored label, preferably no text at all....it's a visual thing...like traffic lights


input fastMALength = 21;
input slowMALength = 55;
input averageTypeFast = AverageType.Exponential;
input averageTypeSlow = AverageType.Exponential;

def fastMA = MovingAverage(averageTypeFast, close, fastMALength);
def slowMA = MovingAverage(averageTypeSlow, close, slowMALength);

def above = close > fastMA and close > slowMA;
def below = close < fastMA and close < slowMA;

AddLabel(1, if above then "Above" else if below then "Below" else "Between",color.black);
AssignBackgroundColor(if above then Color.GREEN else if below then Color.RED else Color.black);

Anybody see this to work? Be fixed?
 
Hi

I am wanting to set EMA crossing the VWAP alerts in TOS.

My questions are do you need to have the EMA on the chart for this to work?

In the settings what does displacements do ?

In the settings what does displacements value relate to each bar = 1 displacement equals 1 bar?

What does "Show breakout signals" do if chosen?

I am want to set a alert of Vwap being crossed by the closing price.

Is there any way to extend a price decrease like projecting a trend line and getting a earlier alerts before the candle close past the Vwap line.

Example is that the Vwap is at $ 10.31 - last low of the 1 m in bar is $ 10.21 - this in within a 10 cent range - the alert would then trigger that price is within 10 cents of the Vwap line.

Cheers
 
OK...so I finally got the watchlist column to follow and show when price is above or below the VWAP....
Problem:
The font changes color and background stays black. It's soooo much easier if the background changed colors not the text. I tried to re-program the colors but keep getting errors....

Anyways.....here is the code for the one I have, that so far worked 100% for me showing price above VWAP:

#VWAP_Label
input numDevDn = -2.0;
input numDevUp = 2.0;
input timeFrame = {default DAY, WEEK, MONTH};
input time = yes;
input time_color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input VWAP_label = yes;
input VWAP_Color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input Upperbands_label = Yes;
input UpperBand_Color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};
input Lowerbands_label = Yes;
input LowerBand_color = {default "magenta", "green", "pink", "cyan", "orange", "red", "blue", "gray", "violet"};

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 UpperBand = price + numDevUp * deviation;
UpperBand.hide();
plot LowerBand = price + numDevDn * deviation;
LowerBand.hide();

AddLabel(VWAP_label, " VWAP: " + Round(VWAP, 2), if vwap<close then color.green else color.red);


And here is what I would love to see would look like!!!!! Can't figure it out......Matter of fact, I just want the colored label, preferably no text at all....it's a visual thing...like traffic lights


input fastMALength = 21;
input slowMALength = 55;
input averageTypeFast = AverageType.Exponential;
input averageTypeSlow = AverageType.Exponential;

def fastMA = MovingAverage(averageTypeFast, close, fastMALength);
def slowMA = MovingAverage(averageTypeSlow, close, slowMALength);

def above = close > fastMA and close > slowMA;
def below = close < fastMA and close < slowMA;

AddLabel(1, if above then "Above" else if below then "Below" else "Between",color.black);
AssignBackgroundColor(if above then Color.GREEN else if below then Color.RED else Color.black);

Anybody see this to work? Be fixed?
Here's basic red,yellow,green light for above or below vwap. background green=above, yellow=on, red=below intraday. best for small multigrids, where you just want an attention getter, like HEY! this is bullish now!", the color is super bright and cant miss it. https://tos.mx/5YOTAWh
 
Here's basic red,yellow,green light for above or below vwap. background green=above, yellow=on, red=below intraday. best for small multigrids, where you just want an attention getter, like HEY! this is bullish now!", the color is super bright and cant miss it. https://tos.mx/5YOTAWh
Beautiful......thank you brother!!! I appreciate your work and time.....it's awesome! Like you said, for multi-grids this is it!!!!
 
Im using big screen to chart 32 stock tickers and instead of having lines the cloud would be much easier for me to spot stocks where I want them.
Really appreciate any help. I know the crossovers and arrows exist but limited to only sight in left eye this would just help me a little more is all.
Thank you
 
Im using big screen to chart 32 stock tickers and instead of having lines the cloud would be much easier for me to spot stocks where I want them.
Really appreciate any help. I know the crossovers and arrows exist but limited to only sight in left eye this would just help me a little more is all.
Thank you
what do you mean by a vwap/ema cloud. are you talking about a regular daily vwap with simple EMA's crossing it up and down?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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