Can someone help creating scan code in ThinkorSwim? - futures io
futures io futures trading

Can someone help creating scan code in ThinkorSwim?

Discussion in ThinkOrSwim

    1. trending_up 9,388 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 2 posts
    2. attach_file 0 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

Search this Thread

Can someone help creating scan code in ThinkorSwim?

(login for full post details)
  #1 (permalink)
Chicago IL
Posts: 1 since Feb 2013
Thanks: 0 given, 0 received

Scan stocks on the short side

[type = stock] and [country = us] and[daily ema(60,daily volume) > 300000] and
[daily low > yesterday's daily low] and
[yesterday's daily low > 2 days ago daily low] and
[SMA(10, close) < EMA(30, close)]and
[daily close > daily SMA(10,daily close)]and
[daily close < daily EMA(30,daily close)]and
[weekly sma(10,weekly close) < weekly ema(30,weekly close)]and
[ADX Line(10) > 20.0]and
[close >= 10]

Scan stocks on the Long side

[type = stock] and [country = us] and[daily ema(60,daily volume) > 300000] and
[daily high < yesterday's daily high] and
[yesterday's daily high < 2 days ago daily high] and
[sma(10, close) > ema(30, close)]and
[daily close > daily ema(30,daily close)]and
[daily close < daily sma(10,daily close)]and
[daily close > daily sma(200,daily close)]and
[weekly sma(10,weekly close) > weekly ema(30,weekly close)]and
[ADX Line(10) > 20.0]and
[close >= 5]

Reply With Quote

Journal Challenge February 2021 results:
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(173 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(120 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(35 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
(login for full post details)
  #2 (permalink)
Dubai, UAE
Experience: Intermediate
Platform: TOS, TradeStation
Broker: OX, TradeStation
Trading: Stocks & Basic Options
RedK's Avatar
Posts: 171 since May 2012
Thanks: 44 given, 143 received

here's how I would do this... for example your SHORT scan would look like this

def Vol = if ExpAverage (volume, 60 ) > 300000 then 1 else 0;
def daily = if low > low[1] and low[1] > low [2] then 1 else 0 ;
def SMA10vsEMA30 = if Average(close, 10) < ExpAverage(close, 30) then 1 else 0;
def ClosevsSMA10 = if close > Average(close, 10)  then 1 else 0;
def ClosevsEMA30 = if close < ExpAverage(close, 30)  then 1 else 0;
def wkSMA10vswkEMA30 = if Average(close(period = AggregationPeriod.WEEK), 10) < ExpAverage(close(period = AggregationPeriod.WEEK), 30) then 1 else 0;def ADX = if DMI(10).ADX > 20 then 1 else 0;
def Price = if close >= 10 then 1 else 0;

Plot Short = Vol * (Daily + SMA10vsEMA30 + ClosevsSMA10 + ClosevsEMA30 + WkSMA10vswkEMA30 + ADX + Price);
I didn't test this as a scan, only as a normal study .. and AFAIK, TOS scans don't allow calling a secondary aggregation, so although the bold line would work in a plot study, it may/should not work in a scan.. so it may need to be separated in a different scan "column"

the successful short candidates will show max score in the scan (in this case a 7), the non-candidates will have lower values, including a 0 if they fail the volume condition .. but that last "plot" line can be changed to show only these ones with a full score and ignore all others, with an IF statement (if the sum is 7 show a "SHORT!" otherwise a blank.

the Long scan would be similar after changing the logical operators ">" and "<"

an interesting exercise thanks for sharing, and hope this helps,


Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to RedK for this post:
(login for full post details)
  #3 (permalink)
Carteret NJ
Posts: 7 since Oct 2014
Thanks: 3 given, 0 received

I know how to insert the scans into TOS platform,
I,m just not savvy enough to know how to create the thinkscripts.

The filter scan i'm looking for are.

#1 50 sma must be angling or moving up

#2 slow stochastic with sma % D period 3 crosses oversold 15

#3 momentum lenght 9,price close, turning up and crossing -5

#4 MACD with sma,fast lenght 5,slow lenght 15,macd lenght 20 and crossing above -2.00

Thanks in advance
Dedicated To Your Success!

Reply With Quote

futures io Trading Community Platforms and Indicators ThinkOrSwim > Can someone help creating scan code in ThinkorSwim?

Last Updated on October 13, 2014

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


Battlestations! Show us your trading desk - $1,500 in prizes!


Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only

Importance of Finding Your Own Way w/Adam Grimes

Elite only

New Challenge (TBD)


Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts