34 EMA Trending Up 20 Days?


Category:
0
0

Hi Pete,

How to scan for stocks that have 34 EMA Trending Up 20 Days? I tried to set up using default study filter on TOS, but they don’t have that condition.

Thanks!

Marked as spam
Posted by (Questions: 23, Answers: 57)
Asked on October 3, 2017 8:05 pm
667 views
0
Private answer

def ema34 = ExpAverage(close, 34);
plot scan = ema34 > ema34[20];

Compares the value of the 34 period ema of the current bar to the value of the 34 period ema of 20 bars ago.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 3, 2017 9:18 pm
0
So to create a scan, I just change def scan to: plot scan = ema34 > ema34[20];? and to create a scan for stocks trending down, plot scan = ema34 ema34[20];), but there’s no result. It seems strange that there’re no stocks above 34 EMA for 20 days
( at October 4, 2017 3:53 am)
0

yes, sorry about the typo. it was late. I just corrected that in my response. This code is simply looking for stocks that have the current 34 ema higher than 34 ema from 20 bars ago. The opposite of this would be:
plot scan = ema34 < ema34[20];

( at October 4, 2017 8:02 am)
0

Thank you, Pete!

( at October 4, 2017 8:50 am)
0
HI Pete, I realize I did not describe the condition correctly. Here’s the code from TC2000 that scanning for stocks trending up for 20 days (above 34 EMA): XAVGC34.20 < XAVGC34.15 AND XAVGC34.15 < XAVGC34.10 AND XAVGC34.10 < XAVGC34.5 AND XAVGC34.3 < XAVGC34 How do we duplicate that logic on TOS?
( at October 4, 2017 4:35 pm)
0
Private answer

There we go. I was pretty sure you had left out some details there. I can translate TC2000 directly into Thinkscript. We’ll grab that first line of code to create our 34 period ema:
def ema34 = ExpAverage(close, 34);

And to that we’ll add the following:

def trendUp = ema34[20] < ema34[15] and ema34[15] < ema34[10] and ema34[10] < ema34[5] and ema34[3] < ema34;

And all you need to reverse this is to switch each of the ‘<‘ to ‘>’. Then you can add your plot scan statements as needed.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 4, 2017 5:33 pm
0

Thanks, Pete! That was a nice translation!

( at October 4, 2017 7:43 pm)