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

I was able to get this setup on my chart but was hoping it would be created as a scanner/watchlist so that alerts could notify me 3 candles before the crossover happens. Has this been scripted?
 
Try using crosses above instead of crosses in your script, otherwise it will indicate on above and below by default...
 
Hi everyone. im trying to write a strategy that is based on the 8MA crossing above the VWAP, i have a simple MA crossing the 50MA strategy that i started with but im not getting many signals and it seems to be missing a lot of crosses that i see happening on the chart, plus i would like to add a certain volume + percentage to trigger a signal if conditions are met.
1) 8MA crossing above VWAP
2) volume +200 percent above average on the candle that is trading when 8MA crosses.
Also was wondering if a early alert could be put into the script to alert that a cross is getting close

sounds impossible but if it can be done i would be extremely grateful

Thank you in advance for any response or help
 
Last edited:
Hey guys, i was able to use this for the upper request i put in last week, it was moved this thread. Thank you. i tried to add a buy and sell order to this so i can back test it but im not getting any signals. Here is the code i have input, can anyone see if its the code or is it something im doing wrong?
Thank you in advance for any help

AddOrder(OrderType.BUY_AUTO, PriceMA crosses above PriceVWAP, tickColor = GetColor(1), arrowColor = GetColor(1), name = "VWAPCross");

AddOrder(OrderType.SELL_TO_CLOSE,PriceMA crosses below VWAP, tickColor = GetColor(2), arrowColor = GetColor(2), name = "VWAPCross");
 
@Break Trader Are you trying to create a backtesting strategy for 9 EMA crossing VWAP? Try this script:

Code:
# Price crossing above or below 9 EMA and VWAP
# By BenTen of useThinkScript.com

declare upper;

# Moving Average
input priceMA = close;
input lengthMA = 9;
input displace = 0;
input showBreakoutSignals = yes;
input price = close;

def EMA = ExpAverage(priceMA[-displace], lengthMA);

# 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 priceVWAP = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(priceVWAP), 0));

def VWAP = priceVWAP;

def bullish_signal = EMA crosses above priceVWAP;
def bearish_signal = EMA crosses below priceVWAP;

# Plot Signals
plot bullish = bullish_signal;
bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish.SetDefaultColor(Color.CYAN);
bullish.SetLineWeight(3);

plot bearish = bearish_signal;
bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish.SetDefaultColor(Color.CYAN);
bearish.SetLineWeight(3);

AddOrder(OrderType.BUY_TO_OPEN, condition = bullish_signal, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Long");

AddOrder(OrderType.SELL_TO_CLOSE, condition = bearish_signal, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Cover");
 
@BenTen, thank you, this is doing almost everything i want it to do, im not getting a "buy" or "sell" signal on my chart where the MA crosses the VWAP i am getting a arrow but i cant get a report from the arrow

I got it to work, i had originally placed in through studies, after i put through in the strategy tab it worked.
Thank you for your help
 
Last edited:
BenTen - The ToS editor displays "Exactly one plot expected" at the bottom when I add your code to it. Does it require an if-else condition? Pls advise. Thanks.
 
BenTen - The ToS editor displays "Exactly one plot expected" at the bottom when I add your code to it. Does it require an if-else condition? Pls advise. Thanks.

I've attached a screenshot of the bottom half of your code. It won't let me save until I hashtag out one of the plots- either bullish or bearish. I can't leave both open.

7ODsxDu.png


Also, how is the scan supposed to work? Only list tickers that cross-over either direction at that point in time?

Appreciate your help.
 
@Shawtysto Change the close is greater than or equal VWAP filter to this:

Code:
close is greater than or equal to reference VWAP()."VWAP" * .98 and close is less than reference VWAP ()."VWAP" * 1.02
 
Can I ask - how would you adjust this so that it would only pull stocks that just crossed in the last 5 minutes, not stocks that crossed an hour ago that are still above the VWAP. I am trying to scan for only NEW crosses

Y81U4MS.png
 
I have done that but what its doing is then pulling all stocks that are “still above”. What I’m looking to scan for are those stocks that within the last 5 minutes “just crossed”
 
And if I set it to 5 minutes it will only shows symbols that just crossed (ie: 5 minutes ago)in the watch list? Can i set it to 1 min or will it not work that fast?
 

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
284 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