Convert TC2000 Scan to Thinkorswim


Category:
0
0

Hi ,

Im wondering if it’s possible to write a scan as follows in Think Or Swim

MinL5>MinL20 And MaxH7.1=maxh36 And MaxH3.1<MaxH36.1 And H>MaxH3.1*1.005

and also the opposite scan.Thanks Enjoy your site and videos!

Editor’s Note:

The title of this question has been updated to more clearly reflect the context of the request.

Marked as spam
Posted by (Questions: 3, Answers: 9)
Asked on February 11, 2017 7:51 am
1427 views
0

Please let us know what platform that code is from. We’ll need to do some research in order to be able to port that over to Thinkorswim.

( at February 11, 2017 8:43 am)
0

tc2000

( at February 11, 2017 9:57 am)
0

Thanks. I’ll be away from the computer most of the day but if I get time I will see if I can find a quick solution to your request. Otherwise, any response will be delayed until late evening.

( at February 11, 2017 10:07 am)
0

No rush. Thanks for taking the time!
Thanks

( at February 11, 2017 10:50 am)
0
Private answer

Well here is my first crack at it. I only spent about 30 minutes reading up on the TC2000 language reference and this is my best interpretation given my current knowledge. Someone will have to run this on Thinkorswim and compare it to the output of this code on TC2000 to confirm whether this is a match. Please provide screenshots from TC2000 and Thinkorswim so I can dial this in.

#MinL5>MinL20 And MaxH7.1=maxh36 And MaxH3.1MaxH3.1*1.005
declare lower;
def fiveBarLow = Lowest(low, 5);
def twentyBarLow = Lowest(low, 20);
def conditionOne = fiveBarLow > twentyBarLow;
def sevenBarHighExcludingCurrent = Highest(high[1], 1);
def thirtySixBarHigh = Highest(high, 36);
def conditionTwo = sevenBarHighExcludingCurrent == thirtySixBarHigh;
def threeBarHighExcludingCurrent = Highest(high[1], 3);
def thirtySixBarHighExcludingCurrent = Highest(high[1], 36);
def conditionThree = threeBarHighExcludingCurrent < thirtySixBarHighExcludingCurrent;
def conditionFour = threeBarHighExcludingCurrent * 1.005;
plot scan = conditionOne and conditionTwo and conditionThree and conditionFour;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 11, 2017 10:20 pm
0

The scan in TOS is only producing 1 stock out of all stocks with the same criteria. The scan is looking for a stock that is within 8 bars of a 30 day high that is closing above the highest high in the last 3 days. TC 2000 is producing a list of 43 or so! Thank You

( at February 12, 2017 8:11 am)
0
Private answer

Ok, thanks for checking. I looked over the code I posted and there were some obvious errors. Just typos for the most part. So here is my updated version. I found this description of your scan online in another forum. Your’s is leaving out the Average Volume filter. When I add that volume filter to this version for Thinkorswim I get 29 ticker symbols in the scan results. I ran the scan on a daily time frame, against All Stocks, with 50 day average volume > 500,000.

First, here is the description of your scan I found online:

MINL5 > MINL20
(the minimum low of the last five day is greater than the minimum low of the last 20 days)
AND MAXH7.1 = MAXH36
(the maximum high of the last 7 days as of 1 day ago equals the maximum high of the last 36 days)
AND MAXH3.1 < MAXH36.1
(the maximum high of the last 3 days as of 1 day ago is less than the maximum high of the last 36 days as of 1 day ago)
AND H > MAXH3.1 * 1.005
(today’s high is greater than the (high of the last three bars as of 1 day ago * 1.005))
AND AVGV50 > 5000
(the average volume of the last 50 days is greater than 500000)

And here is my revised version for Thinkorswim:

#MinL5>MinL20 And MaxH7.1=maxh36 And MaxH3.1<MaxH36.1 And H>MaxH3.1*1.005
declare lower;
def fiveBarLow = Lowest(low, 5);
def twentyBarLow = Lowest(low, 20);
def conditionOne = fiveBarLow > twentyBarLow;
def sevenBarHighExcludingCurrent = Highest(high[1], 7);
def thirtySixBarHigh = Highest(high, 36);
def conditionTwo = sevenBarHighExcludingCurrent == thirtySixBarHigh;
def threeBarHighExcludingCurrent = Highest(high[1], 3);
def thirtySixBarHighExcludingCurrent = Highest(high[1], 36);
def conditionThree = threeBarHighExcludingCurrent < thirtySixBarHighExcludingCurrent;
def conditionFour = high > threeBarHighExcludingCurrent * 1.005;
plot scan1 = conditionOne and conditionTwo and conditionThree and conditionFour;

Note: This does not include the Average Volume filter. I applied that as a separate filter criteria when creating my test scan.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 12, 2017 10:07 am
0

Yes it is working great now. I have my own criteria I scan for that is why I left volume out. To do the scan for shorts or the reverse would i just change all the highs for lows.
Thanks for your work!

( at February 12, 2017 11:12 am)
0

I have the specifications for the short side and will post that later on today. Late evening. I wanted to make sure we got the long side worked out first.

( at February 12, 2017 12:16 pm)
0
Private answer

Ok, this should be the short side of that scan. Give it a shot and let us know how it works.

#MAXH5 < MAXH20 AND MINL7.1 = MINL36 AND MINL3.1 > MINL36.1 AND L < MINL3.1 * 0.995
declare lower;
def fiveBarHigh = Highest(high, 5);
def twentyBarHigh = Highest(high, 20);
def conditionOne = fiveBarHigh < twentyBarHigh;
def sevenBarLowExcludingCurrent = Lowest(low[1], 7);
def thirtySixBarLow = Lowest(low, 36);
def conditionTwo = sevenBarLowExcludingCurrent == thirtySixBarLow;
def threeBarLowExcludingCurrent = Lowest(low[1], 3);
def thirtySixBarLowExcludingCurrent = Lowest(low[1], 36);
def conditionThree = threeBarLowExcludingCurrent > thirtySixBarLowExcludingCurrent;
def conditionFour = low < threeBarLowExcludingCurrent * 0.995;
plot scan = conditionOne and conditionTwo and conditionThree and conditionFour;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 12, 2017 10:04 pm
0

Hi and thanks again! I tried the short scan and nothing is coming up on TOS . However Im getting 5 stocks in TC200. Thanks!

( at February 13, 2017 7:31 am)
0

Yep, I got about that many scan results when I ran it on Thinkorswim last night. I reviewed the code and it should be an exact match. Please check again over the next few days and see if it lines up with the TC2000 version.

( at February 13, 2017 9:03 am)
0

Will do .
Thanks again!

( at February 13, 2017 1:53 pm)
0
Private answer

John Campbell, do you mind giving a brief explanation of your strategy your using with this code? Thanks! ?

Marked as spam
Posted by (Questions: 34, Answers: 56)
Answered on February 16, 2017 8:57 pm