How to create a thinkorswim (TOS) dollar gainer scan

If you’re just starting out, be sure to visit the thinkorswim Learning Center first. The video on that page describes how to get started with creating your first scan. I’ll keep this simple, and even provide the code for you! In this scan we will meet the following criteria. 1) The stock must have gained at least one dollar from the previous day’s close during the pre-market trading session. The pre-market is defined as the time between 4:00am and 9:29am. 2) The pre-market cumulative volume must exceed 5,000 shares traded. Here are the steps to create a thinkorswim (TOS) dollar gainer scan. Feel free to update the change and preMktVolMin variables to meet your needs.

  1. For the “Scan in:” section, choose All Stocks from the Category list
  2. For the “Exclude:” section, choose All OTC Stocks from the Category list (unless you like to trade OTC stocks, of course)
  3. Add a filter using the “+ Add filter” button. Choose Stock. Under the first drop-down, choose Last and set the min and max price for the stocks you like to trade
  4. Add another filter. This time choose Study. At the bottom of the first drop-down list, choose custom. A window will open. Click the “thinkScript Editor” tab at the top of the window. Also, change the Aggregation (also at the top of the window) to 1 min. Remove the default code from the editor window and copy/paste the code from below. Update the “change” or “preMktVolMin” variable values as needed.
  5. Add another “Stock” filter. Set it to a Market cap min. of 1M. This will filter out some things that are not stocks.
def change = 1.00;
def preMktVolMin = 50000;
def mktClose = 1559;
def preMktStart = 0400;
def preMktEnd = 0929;
rec closePrice = CompoundValue(1, if SecondsTillTime(mktClose) == 0 then close else closePrice[1], close);
def gainers = (close - closePrice) >= change;
def preMkt = SecondsFromTime(preMktStart) >= 0 and SecondsTillTime(preMktEnd) >= 0;
def preMktVol = if preMkt and !preMkt[1] then volume else if preMkt then preMktVol[1] + volume else preMktVol[1];
plot scan = preMkt and gainers and preMktVol > preMktVolMin;
  1. Click OK to exit the window.
  2. Click the menu to the far right of the “Add condition group” button, and click “Save scan query…”
  3. Give your scan a name, and save it.
  4. Click the Scan button and await your results! NOTE: If you’re not scanning during the pre-market, you’ll get no results.