Easily keep a running count of market internals, using the NYSE $TICK, and use the information to pinpoint reversals before they happen
For our 21th episode of "How to thinkScript," we're going to be building a Cumulative TICK indicator for ThinkOrSwim in less than 21 minutes.
The Cumulative TICK indicator is useful for those who day trade, specifically the indices. Keeping track of Market Internals is often challenging and akin to counting cards during a game of Blackjack.
We'll use some simple thinkScript to write the code for this indicator - in fact, our Cumulative TICK indicator uses less than 12 lines of code in total. Most of the "lessons" from this tutorial will be around learning how to read and use ThinkOrSwim documentation, to build any of your own future indicators.
There are two separate parts of this tutorial:
- Part 1 -- Free for everyone (this tutorial)
- Part 2 -- Free for Volatility Box members (available here)
For our Volatility Box members, we've taken this tutorial one step further, with an extra 1 hour and 15 minutes of content, in which we build the Cumulative TICK Pro indicator.
In the extended tutorial, we will:
- Leverage Python and Jupyter Notebook to analyze a TICK data set using some basic, yet powerful statistical functions
- Incorporate the results of our data analysis into our Cumulative TICK Pro indicator file to build a mini prediction model around future price action
- Use some clever thinkScript code to use the appropriate TICK value, based on the market you're looking at (ie. TICK for NYSE, TICK/Q for Nasdaq, TIKI for DOW)
- We'll also incorporate the Edge Signals indicator and massage the code to work seamlessly with the Cumulative TICK and give us concrete bullish and bearish signals
- Polish up the Cumulative TICK indicator code to work flawlessly with our current set of tools, and format to provide us with actionable results
Regardless of your prior thinkScript experience, I think you'll find the Cumulative TICK thinkScript episode to be a beginner-friendly tutorial, that is a gentle introduction into the world of coding in ThinkOrSwim.
What is the Cumulative TICK?
The Cumulative TICK indicator helps us to keep track of the running total of the NYSE TICK throughout the day.
A great analogy to understand the power of keeping count of the total TICK count is thinking about Blackjack. When using the Ten Count Card counting system, a running total of two different sets of cards is what gives the player an edge.
With the running count, you can make smart predictions around the remaining cards left in the deck, and make bets using that information.
Similarly, with the Cumulative TICK indicator, we're looking to do something similar. By keeping track on an aggregate basis of the total TICKs, we can then start to make educated guesses. Some ways that we use the Cumulative TICK in the Pro tutorial include:
- When we have a likely trending day vs. when we expect choppy days
- When the trend has exhauste and we expect a reversal
- Zones that signify "extreme" Cumulative TICK readings
Example of Cumulative TICK
Let's assume that we have the following TICK values:
We'll add in one extra column, to demonstrate what the Cumulative TICK value would look like:
|Time (PT)||TICK||Cumulative TICK|
Here's the same data, illustrated in a chart format:
thinkScript Code for Cumulative TICK
Let's start by writing the code for the Cumulative TICK indicator.
First, we need to start by introducing in the TICK value, and we'll use the hlc3 to take the TICK's (high + low + close)/3:
def tickData = hlc3(symbol="$TICK");
That gives us the value for just the TICK on the current bar. We need to now introduce a way to keep a running total of the TICK count.
To do so, we'll create a new variable called Cumulative TICK Value. This variable will not only keep a running total of the TICK, but also reset it to zero whenever we have a "new day." To do so, we can use the SecondsTillTime function (though there are multiple ways of solving this):
def cumulativeTickValue = if SecondsTillTime(930) < 0 and SEcondsTillTime(1600) > 0 then tickData + cumulativeTickValue else 0;
And we can then take that value, and plot it separately, so we can paint using the Double.nan variable:
plot cumulativeTickPlot = if cumulativeTickValue != 0 then cumulativeTickValue else Double.nan;
The last thing we need to do is "pretty" up the indicator with some formatting tricks.
To format the Cumulative TICK indicator, we'll start by adjusting the painting strategy for our plot variable, CumulativeTICKPlot.
cumulativeTickPlot.AssignValueColor(if cumulativeTickPlot > cumulativeTickPlot then color.cyan else color.gray);
And finally, we add a vertical line to separate each new day, so we don't see large gaps in between new days:
def newDay = GetDay() != GetDay();
AddVerticalLine(newDay, "New Day", color.gray, curve.Short_Dash);
What Else Can I Do?
You can use some of the next steps that we use in the Cumulative TICK Pro indicator and pursue those yourself.
A good first step would be to use the GetSymbol() function and have the indicator automatically cycle through the appropriate TICK value based on the chart you're currently on.
You can also leverage the Supply/Demand Edge indicator, and overlap that with the Cumulative TICK indicator to find areas of confluence for high confidence signals (we prefer the Edge Signals, if you have access to it).