Trade Winds: Can’t Find the Indicator You’re Looking For? thinkScript Has You Covered

You don't need to be a coding expert to create trading systems. You can write one yourself using thinkScript in thinkorswim.

https://tickertapecdn.tdameritrade.com/assets/images/pages/md/Message in a Bottle: thinkScript
5 min read
Photo by Dan Saelinger

Key Takeaways

  • Create a thinkScript to alert you when a simple moving average crossover takes place
  • Follow six steps to create your own indicator or trading system

Sure, there are lots of charting studies and tools at your disposal, but what if you want something that mimics a trading system you read about, or a new indicator or pattern you just can’t find? You may need to build it yourself.

The thinkorswim® platform from TD Ameritrade lets traders create their own indicators, scans, alerts, and trading systems using thinkScript. And you don’t need to be a computer programming whiz. To get your feet wet, you can use the Condition Wizard and start with something simple, like scanning for moving average crossover. 

To get started building your own indicator or system, I recommend following these six steps:

  1. Identify a goal
  2. Determine if thinkScript can meet that goal
  3. Outline the steps to script
  4. Apply thinkScript tools
  5. Write custom scripts if needed
  6. Test your script against your goal

Getting Started with Scripting

Suppose your goal is to be alerted when there’s a simple moving average (SMA) crossover. Instead of checking the charts for a crossover continuously throughout the day, could create a script that alerts you when the crossover occurs. 

Applying thinkScript

Let’s try creating a script that’ll alert you when a 10-period SMA crosses above a 20-period SMA.

Fire up thinkorswim and:

  1. Select the MarketWatch tab, then Alerts.
  2. Enter the stock symbol and select Study Alert.
  3. In the new window, select Condition Wizard, then Edit.
  4. In the Edit Condition window, select 10 as the length of the first SMA and crosses above.
  5. Select Study from the Select a Condition menu.
  6. Scroll down and select SimpleMovingAvg, then change length to 20.

Write Your Own thinkScript

In the thinkScript Editor, you’ll see the thinkScript code for the SMA following crossover:

SimpleMovingAvg (“length”= 10) crosses above SimpleMovingAvg (“length” = 20). “SMA” and MovingAvgCrossover (“length1”= 10, “length2”= 20) is true

Now set up an alert to notify you via text message or onscreen when the condition is met by selecting Create Alert. You can also set up Scans & Custom Columns to find stocks with crossovers.

You’ve created your first thinkScript code. You can always go into the thinkScript Editor and make changes, which will help you learn and advance your new coding career. You can also use links from other thinkorswim users and paste them into the platform.

Now that you’ve had a taste of thinkScript, you can take it further. Some of the more complex scripts can be used as investing strategies and backtested. Just keep in mind that good backtesting results don’t provide any guarantees for future performance.

Print

Key Takeaways

  • Create a thinkScript to alert you when a simple moving average crossover takes place
  • Follow six steps to create your own indicator or trading system

Do Not Sell or Share My Personal Information

Content intended for educational/informational purposes only. Not investment advice, or a recommendation of any security, strategy, or account type.

Be sure to understand all risks involved with each strategy, including commission costs, before attempting to place any trade. Clients must consider all relevant risk factors, including their own personal financial situations, before trading.

adChoicesAdChoices

Market volatility, volume, and system availability may delay account access and trade executions.

Past performance of a security or strategy does not guarantee future results or success.

Options are not suitable for all investors as the special risks inherent to options trading may expose investors to potentially rapid and substantial losses. Options trading subject to TD Ameritrade review and approval. Please read Characteristics and Risks of Standardized Options before investing in options.

Supporting documentation for any claims, comparisons, statistics, or other technical data will be supplied upon request.

This is not an offer or solicitation in any jurisdiction where we are not authorized to do business or where such offer or solicitation would be contrary to the local laws and regulations of that jurisdiction, including, but not limited to persons residing in Australia, Canada, Hong Kong, Japan, Saudi Arabia, Singapore, UK, and the countries of the European Union.

TD Ameritrade, Inc., member FINRA/SIPC, a subsidiary of The Charles Schwab Corporation. © 2024 Charles Schwab & Co. Inc. All rights reserved.

Scroll to Top