Moving Average Crossover Watchlist Column for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
If anyone uses EMA crossover as a way to identify trend or point of entry/exit, knowing when there is a moving average crossover on your watchlist column can certainly be helpful. Here is a quick snippet that let you do just that.



It includes lookback period so that you can set to X amount of when there is an EMA (exponential moving average) crossover. For example, the default is 5. The column will turn green when there is a bullish crossover within the last 5 bars and vice versa. Orange for neutral.



thinkScript Code
Rich (BB code):
# WalkingBallista EMA Lookback Cross
# https://usethinkscript.com/d/119-moving-average-crossover-watchlist-column-for-thinkorswim

declare lower;

input lookback = 5;
input ema1_len = 10;
input ema2_len = 20;
input averageType = AverageType.EXPONENTIAL;

def ema1 = MovAvgExponential(length=ema1_len);
def ema2 = MovAvgExponential(length=ema2_len);

def bull_cross = ema1 crosses above ema2;
def bear_cross = ema1 crosses below ema2;

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.Dark_Green else if signal == 1 then Color.Dark_Red else Color.Dark_Orange);
AssignBackgroundCOlor(if signal == 2 then Color.Dark_Green else if signal == 1 then Color.Dark_Red else Color.Dark_Orange);
The default values for EMAs are _10_ and _20_. You can change the input to whichever EMA you use on your chart.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
[[2],[2,15]]
 
Last edited:
markos

markos

Well-known member
VIP
Warehouse
@BenTen Now, that is an efficient way of using a watchlist...just scroll!

 
Last edited:
J

jan_angel

New member
VIP
Hi BenTen. This is a great script. How do i customize it to use it for daytrading? I added to my WL, but it is working for a daily timeframe. I would like to watch if there is a MA cross over at 5 minute interval.

Thanks again,

J

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@jan_angel When adding the script to your watchlist, you should be able to select to the timeframe of your liking. Daily is by default.



 
Last edited:
J

jan_angel

New member
VIP
Thank you! that did the trick. Appreciate the quick response.

 
Last edited:
J

jan_angel

New member
VIP
Hi BenTen - i have been using your MA crossover script all this week...and it worked great. However, for some reason, today all day it kept on saying 'loading' in the WL column. Do you have any ideas why? I thought it was TOS issue, but the helpdesk guy was totally helpless. Any info that you can provide will be great. I love this script.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@jan_angel Hey, I had the same problem for other indicators that I include in the watchlist columns too. It's totally ToS issue. Nothing we can do here ☹

 
Last edited:
J

jan_angel

New member
VIP
Good to know! and thank you again for the super fast reply.

 
Last edited:

Top