Scan for price touching moving average in ThinkorSwim

jas

New member
I need a Thinkorswim scanner which scan stocks whose last few previous daily bar's open, close, low or high touches or almost too close to desired moving averages means act as support or resistance. Can also able to scan for at least 2 different moving averages in a scan so that scan will return stocks which touches either of 2 moving averages.
 

tomsk

Well-known member
VIP
I'll respond on behalf of @BenTen

Scanning for stocks need to be very clearly defined. Your description above is imprecise and won't mean anything to the scanner
For example you can say something like the close crosses above the 34 EMA during yesterday's close
Once you have a clear definition, scanning for that will be easy
Help us so that someone can help you
 
Last edited:

jas

New member
Hi Tom,

Basically looking stocks whose previous last 1-4 daily bar's open, close, high or low is very close to particular moving average which means that it acts as base.

XXAPRsFg.jpg


Please check image and I have highlighted points
 

tomsk

Well-known member
VIP
You really need to define "very close" because different traders have different interpretations of what "very close" means to them
That said, assume you want to scan for stocks with a price within $0.50 of say the 21 EMA
Here is your scan code to do so.

Code:
def EMA = ExpAverage(close, 21);
plot scan = between(close, EMA-0.50, EMA+0.50);
 

jas

New member
Hi Tom,

Actually looking for scan which return stocks whose previous one to four daily candles either open, close, low or high touches desired moving average. Also I need unusual volume in scan and distance between 2 moving average is narrowing. Please see image below for reference as I highlighted for what I am looking for?

wk8Z1VU.jpg


Thanks
 

tomsk

Well-known member
VIP
Having these sorts of moving averages criss-crossing each other does not give any clear signal
Worse it may give you false positives. Probably better to wait for a clearer direction.

However since you wanted it, here is an EMA Convergence scan using 8,13,21 periods
I obtained 218 results on the scanner, scanning against the S&P 500.

Code:
# EMA Convergence Scan
# tomsk
# 12.5.2019

# Scan for convergence between EMA 8,13,21

input length1 = 8;
input length2 = 13;
input length3 = 21;

def ema1  = ExpAverage(close, length1);
def ema2  = ExpAverage(close, length2);
def ema3  = ExpAverage(close, length3);

def cond1  = between(ema1, close * .995, close * 1.005);
def cond2  = between(ema2, close * .995, close * 1.005);
def cond3  = between(ema3, close * .995, close * 1.005);

plot scan = cond1 + cond2 + cond3;
# End EMA Convergence Scan
 

jas

New member
Thanks Tom,

Actually, I am looking for scan where daily candle's either high, low, close or low is touching desired moving average. For reference, please see picture below.

5I0ixIh.jpeg
 

tomsk

Well-known member
VIP
Unfortunately I need to move on to other pressing projects. You weren't clear from the get go. I really don't see the point of the request.
 

BenTen

Administrative
Staff
VIP
Like @tomsk said, you were not specific about your request from the beginning. That makes it harder for us to help. After reading your questions multiple times, I hope I understand it correctly. You can scan for stocks that are crossing a moving average. @jas I believe you can do that using the default Scanner in ThinkorSwim. You just have to build one using their Scan Editor. It's as simple as the following:

T2K35Gg.png


The snippet for that would be:

Code:
close crosses SimpleMovingAvg("length" = 21)."SMA"

When running this on the daily chart, it will return any stocks with the close crossing above or below the 21 simple moving average.
 

ezrollin

Member
VIP
How would I scan for price touching the 50 SMA on the daily but is staying above it? Thanks

close is equal to SimpleMovingAvg("length" = 50)."SMA" within 1 bars
 
Last edited:

rad14733

Well-known member
VIP
@ezrollin As BenTen has pointed out, price either equals or crosses a moving average or other indicator line... Members need to stop using the term "touch" as there is no such thing... If members use proper terminology they will receive better help and support... If you think the price "touched", well, how did it "touch"...??? It either "equaled" or "crossed"... Terminology is everything, even for beginners... Just something that has needed to be said...
 

rad14733

Well-known member
VIP
@David45 In the future please use the search feature because its been covered multiple times... But because you don't have the will to do the research yourself, try something like the code below... We have better things to do than hand out the same code repetitively... Not to mention that it simply bloats these forums needlessly...

Ruby:
plot upArrow = ema1 crosses above ema2;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetLineWeight(3);
upArrow.SetDefaultColor(Color.DARK_ORANGE);
 

derekwfrazier

New member
Hello I was wondering if someone can lead me in the right direction to start scanning for a condition, when a 1 period, {{H+L}/2}, displaced -8 SMA, is crossed up or down by price bar on the Daily? Seems straight forward
Thank you very much
Derek
 

Similar threads

Top