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

Hello,
I am trying to create a scanner for candles in 10 minutes chart.. Candles at or below standard devchannel middle line and VWAP lower band is crossing MA9 and stays below. Thanks for the help!
 
Hey guys, I saw this VWAP Indicator and thought it was really cool, but I have no idea how to recreate it?

Do you like it? Can someone tell me how to create it? (Or hopefully someone already has a code for it)

Thanks a million


I think this looks about right, the reason I used this one is because in the image you provided it looked more smoothed than a typical VWAP so I thought it might be a volume weighted moving average price, though it is still a little off I think I roughly got the length down.
8CsY5Tp.png

Code:
input price = VWAP;
input length1 = 5;
input length2 = 25;
input AverageType1 = AverageType.SIMPLE;
input AverageType2 = AverageType.SIMPLE;

plot MA1 = MovingAverage(AverageType1, price, length1);
plot MA2 = MovingAverage(AverageType2, price, length2);
AddCloud(MA1, MA2, Color.GREEN, Color.RED, no);
or this one, also little off but holds true to VWAP's cumulative nature than using moving averages as above
PumFufw.png


Code:
input cumulativePeriod = 5;
input cumulativePeriod2 = 25;

def typicalPrice = (high + low + close) / 3;
def typicalPriceVolume = typicalPrice * volume;
def cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod);
def cumulativeVolume = sum(volume, cumulativePeriod);
plot VWAP1 = cumulativeTypicalPriceVolume / cumulativeVolume;

def typicalPrice2 = (high + low + close) / 3;
def typicalPriceVolume2 = typicalPrice2 * volume;
def cumulativeTypicalPriceVolume2 = sum(typicalPriceVolume2, cumulativePeriod2);
def cumulativeVolume2 = sum(volume, cumulativePeriod2);
plot VWAP2 = cumulativeTypicalPriceVolume2 / cumulativeVolume2;

AddCloud(VWAP1, VWAP2, Color.GREEN, Color.RED, no);
 
Last edited:
Hi Ben,

Do you know whether I can find a script to create a column indicating whether the stock breaks yesterday high or low? If you have it, could you please share with me?

Thanks.
 
In order to receive alerts based off the cross over, i did not see that as an option in the alerts section. How do i incorporate that? Also, to get this as a scan is that code just pasted into the scan section?

I am unable to paste this code into the alerts and custom scanner, after i paste the ok box is greyed out and it won't let me finish.
 
Hi,

I want to submit the following chart study code that shows when the price crosses above VWAP. A blue arrow and sound is generated on the chart when this happens. This is useful when tracking a stock for a red to green move, especially a low float, low priced stock with a catalyst in the early time frame (9:30am to 11am). Please pass this on!

Thanks,
Sonny

n8tyw8P.png


Code:
#Price crosses above 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));
plot vwapValue = price;
plot crossingAbove = close[1] < vwapValue[1] and close > vwapValue;
crossingAbove.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
crossingAbove.SetDefaultColor(Color.CYAN);
crossingAbove.SetLineWeight(1);
Alert(crossingAbove[1], "Cross Above VWAP", Alert.BAR, Sound.Bell);
 
Last edited by a moderator:
HEY @BenTen I tried this code but it plots the arrow everywhere, and not just when EMA crosses above/below vwap. Please take a look at the attached screenshot. Can you modify the code so the arrows are plotted ONLY when EMA crosses above/below vwap. I have marked one area with BLUE ARROW for reference.

NvmCfCe.png
 
Last edited:
Thanks for the code. Is there anyway to get an alert via email or text using a 1 or 5 minute time frame if you are not at your computer?
 
Adding to what @Sonny said, you can also create a scanner for this indicator, save it as a watclist, and then get alerted for new changes within that watchlist.
 
Hi all , I am wanting to create a scan that can find stocks which x amount of ticks have been above VWAP, is this possible?

Tick as in each candle. What if a line for the price close was created then create a scan that is below or equal to the close line? To be clear I am looking to scan: Stocks where the last 20 five minute candles lows close above VWAP.
 
@Vincenzo I'm no expert at thinkscript but see if this works.

Code:
input priceLow = low;
input totalBars = 20;

def myVWAP = reference VWAP()."VWAP";
def lowsAboveVWAP = Lowest(priceLow,totalBars) > myVWAP;

plot scan = lowsAboveVWAP;

results:

Q8XQMd4.png
 
Hello all,

I am trying to use this code to search for stocks where the last 20 five minute candles closed above VWAP. I am having trouble creating the correct settings in the study to create this. How would I use this code to search for the desired parameters ?

Code:

Code:
input priceLow = low;
input totalBars = 20;

def myVWAP = reference VWAP()."VWAP";
def lowsAboveVWAP = Lowest(priceLow,totalBars) > myVWAP;

plot scan = lowsAboveVWAP;

thank you!

eU22FZq.png


I have tried changing that too with no luck. The screen shot from @luicius was the exact result i am looking for

I found my solution:

Add a study filter with 5-min aggregation and use the following code to find symbols with last 20 bars having low price greater than cumulative VWAP for that day:

Code:
def cumulativeVWAP = reference VWAP;
plot scan = sum(low > cumulativeVWAP, 20) == 20;
 
@Vincenzo It's actually not complicated at all and you don't even need any external script.

Start by setting up a scanner to look for close crossing above VWAP.

xBen1h9.png


Adjust the within X bars value. By default, it's set to one, so it will be scanning for the latest bar. This field is optionable. I would leave it as 1.

Next, select the timeframe before you hit the Scan button.

HUSAnar.png
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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