A Simple thinkScript Code for the Scan Tab | thinkScript Studies on thinkorswim

Education


A Simple thinkScript Code for the Scan Tab | thinkScript Studies on thinkorswim

Welcome, everybody. Happy Friday! Nice to have you back for our Think Scripting class. My name is Mike Fairboard. Today we'll be diving into some volatility in the market and exploring potential short-term trading opportunities using thinkScript on the thinkorswim platform.


Introduction

I've noticed a big spike in volatility recently, which can create potential opportunities on shorter-term time frames. Today, we'll take a look at pivot points and use thinkScript to identify specific trends on a five-minute chart.

We'll also touch on important disclosures: backtesting results are hypothetical, and investing involves risk, including the loss of principal.


Volatility and Pivot Points

The recent spike in VIX, a common measure of market volatility, has opened up shorter-term directional opportunities on the S&P 500 Index. Pivot points, widely used among technical traders, provide critical support and resistance levels derived from the previous day's price activity.

Calculation of Pivot Points

Pivot points are calculated by taking the average of the high, low, and close of the previous day. Here’s the formula:

Pivot Point = (High + Low + Close) / 3

Using pivot points, we derive:

  • R1 (Resistance 1)
  • R2 (Resistance 2)
  • S1 (Support 1)
  • S2 (Support 2)

In moments of high volatility, as represented by increased VIX, traders may use these pivot points to identify bullish or bearish trades over short time frames.

Implementing Pivot Points with thinkScript

A great way to apply this strategy is to use thinkScript to scan for stocks trading below an S1 level, indicating a potential bearish trade. Similarly, a script can be designed to identify stocks breaking above an S3, which might signal a significant reversal.

Example thinkScript Setup

Here is a thinkScript code breakdown for identifying stocks trading below an S1 level:

declare lower;
input aggregationPeriod = AggregationPeriod.FIVE_MIN;
def S1 = GetPivotLevel("S1");
def closeBelowS1 = close < S1;
def inLastFiveBars = Sum(closeBelowS1, 5) > 0;
plot scan = inLastFiveBars;

In this script:

  • aggregationPeriod is set to five minutes
  • S1 retrieves the S1 pivot level
  • closeBelowS1 checks if the current close price is below S1
  • inLastFiveBars ensures that this condition occurred within the last five bars

Application and Results

By running this scan, 25 stocks on the S&P 500 meet the criteria of trading below S1, signaling potential bearish opportunities.

Case Study: CAH Stock

For instance, Cardinal Health (CAH) showed a break below S1 and continued towards S2, aligning with the identified trend.

Sharing the thinkScript Code

I’ve shared the scan code for both bearish and bullish scenarios, ensuring that you can seamlessly integrate these strategies into your own trading practice.

Bearish Scan Link: thinkScript Code
Bullish Scan Link: thinkScript Code

Conclusion

Understanding pivot points and efficiently using thinkScript to scan for critical levels can simplify your trading strategy, especially in high volatility environments.

For further details, you can refer to our YouTube playlist: thinkScript Studies on thinkorswim. Please be sure to subscribe to our channel for more insights, and feel free to leave topic requests in the comments or through X (formerly known as Twitter).


Keywords

FAQ

What are pivot points in trading?

Pivot points are calculated based on the average of the high, low, and closing prices from the previous trading day. They help identify potential support and resistance levels for the current trading day.

How can thinkScript be used to scan for pivot points?

thinkScript can be used to create custom scans that identify stocks trading above or below specific pivot levels like S1 or S3, helping traders identify potential trading opportunities.

What is the significance of VIX in trading pivot points?

A higher VIX indicates greater market volatility, which often translates into larger price movements. This can make pivot point trading more effective as the price is more likely to move to the next pivot level.

When is the best time to employ short-term pivot point trading strategies?

While pivot point strategies can be employed at any time, they are often more effective at the beginning of the trading day or just after significant market events that increase volatility.