Moving Average Crossover Watchlist Column for ThinkorSwim

@tradeking313 See if this watchlist works for you. It's after trading hours now so I can't test in a live environment, but from minimal testing on my end, it should work

Code:
# EMA Crossover Watchlist
# tomsk
# 1.11.2020

def ema1 = ExpAverage(close,9);
def ema2 = ExpAverage(close,26);

def crossOver = if ema1 crosses above ema2 then 1 else if ema1 crosses below ema2 then -1 else 0;
AddLabel(1, if crossOver == 1 then "Up" else if crossOver == -1 then "Down" else "  ", Color.BLACK);
AssignBackgroundColor(if crossOver == 1 then Color.GREEN else if crossOver == -1 then Color.RED else Color.BLACK);
# EMA Crossover Watchlist
 

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

Hello, this a great column and I am going to attempt to reverse hack it and substitute the Simple Moving Average (SMA) for the EMA.
Ben (or can anyone) comment on what this part I quoted means. Its the only part of the logic I don't follow. What are you looking at to see what is the "highest" of between the crosses and lookback for?

def bull_lookback = highest(bull_cross, lookback); def bear_lookback = highest(bear_cross, lookback);
 
Hi Ben,
Thanks for the script! This is very useful. I also modified it to see close price crossing VWAP on 1-minute chart within last 2 candle stick. But it seems to picking up crossing even 7-8 sticks before. I did't select the 1 min, as you have described above. Here is the script, what am I doing wrong?
Code:
# Modifying it for close price crosses the VWAP
# https://usethinkscript.com/d/119-moving-average-crossover-watchlist-column-for-thinkorswim
declare lower;
input lookback = 2;
def bull_cross =close crosses above VWAP;
def bear_cross = close crosses below VWAP;
def bull_lookback = highest(bull_cross, lookback);
def bear_lookback = highest(bear_cross, lookback);
plot signal = if bull_lookback then 2 else if bear_lookback then 1 else 0;
signal.AssignValueColor(if signal == 2 then Color.MAGENTA else if signal == 1 then Color.VIOLET else Color.WHITE );
AssignBackgroundCOlor(if signal == 2 then Color.MAGENTA else if signal == 1 then Color.VIOLET  else Color.WHITE);
 
@rokeyaalamr Can you share a screenshot of your watchlist setting? The screen where you paste the script above into.
 
Thanks BenTen! you are really active. Here's the link of the screen shot.

3eGwmha.png


Also is there script or study for automatic support and resistances lines drawing? And drawing for pre-market highs and lows?
 
Last edited by a moderator:
Hi Benten can we write EMA alert for above code that cross 20 in last 2 minutes? Can we write a code to give different alert that crossed EMA cross over in last 2 minutes. Because that helps from not catching the already running trades.
 
Hi @BenTen, I was trying to create a query in TOS, but don't see watch changing colors. I know script has been more than year, have you made any new enhancements to it
 
Hi @BenTen . Is it possible to alter your code so that it will notify me when the Ema line crosses over the SMA line. I changed your code to include SMA 2 instead of ema 2. Thanks
 
Last edited:
@Tdnation12 Sure, you can modify the existing script. MovAvgExponential will call for EMA while SimpleMovingAvg will call for SMA.
 
@BenTen perfect thanks. For the line: input averageType = AverageType.EXPONENTIAL; do I leave this as is, or change to include both exponential and simple? Thanks once again!
 
@BenTen Can we have some instruction regarding how to create the scanner alerts. Do i need to separate the bull and bear in code for scanner alerts. As in this code both are present. Appreciate your help sir.
 
@Sagar This is for your watchlist column. If you want to get alerted for new crossovers all you have to do is create a scanner > save the scanner as a watchlist > Alerts when scan result change...

FWbm0jG.png
 
Looking for some help with getting the EMA9 crossing the VWAP on 1min? Not sure if I can use this script for that? And the best to be able to add to watchlist and get alerted?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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