Thinkorswim scan for cummuative or total session tick_count()


Category:
0
0

Good evening, I have been searching for hours for a workaround on the limited aggregation period for the TOS scanner. I am trying to create a scan that will return stocks with a tick count > 5000 over a 24 hour, Intraday period. As you probably know, tick_count() does not work with the Daily aggregation period, and the highest available Intraday aggregation period is 4 hours on the drop down in the scan configuration. I have been all over Google, with people pointing to ideas of possibly including multiple aggregation periods in the script, or defining start and end times, or possibly using some variable other than aggregation period to achieve the result. My thinkscript knowledge is limited, so I have been unable to build on any of that, but I was curious if your response to another question might be useful in this situation (https://www.hahn-tech.com/ans/how-do-i-get-a-count-of-the-number-of-ticks-bars-over-a-certain-time-period/). Tick_count() is easily achieved on the chart using a custom 24h/Intraday time frame and simple study, but that doesn’t help much in regards to scanning for stocks in that time frame.
I appreciate your time and any help you can provide.

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on October 4, 2024 4:46 pm
53 views
0
Private answer

The good news is that, if I understand your request, there is a solution.

You simply want a scan that will measure the total number of "ticks" within each 24 hour session. And you want to be able to scan for a value which is greater than 5,000, total ticks. If that is correct, the following solution is exactly what you are seeking.

The only detail that was not perfectly clear is whether you want to

  1. scan for these conditions during the trading session (cumulative total up to that point in time you run the scan).
  2. scan for the stocks which met these conditions for the entirety of the previous session. Regardless of what time you run the scan.

So I created a chart study and a scan which performs both. The chart study will show you exactly what the scan is measuring. The cyan line is the cumulative tick_count for the current live session. The red line is the complete tick_count for the entirety of the previous session. I also included a user input so you can change the tick_count threshold you want the scan to identify.

Here is the script for the chart study:

# Chart Study Version
declare lower;
def newDay = GetDay() <> GetDay()[1];
rec countTicks = if newDay then tick_count() else countTicks[1] + tick_count;
plot dataOne = countTicks;
rec countPriorSession = if newDay then countTicks[1] else countPriorSession[1];
plot dataTwo = countPriorSession;

And here is the script for the scan version:

# Scan Version
input tickCountThreshold = 5000;
def newDay = GetDay() <> GetDay()[1];
rec countTicks = if newDay then tick_count() else countTicks[1] + tick_count;
def dataOne = countTicks;
rec countPriorSession = if newDay then countTicks[1] else countPriorSession[1];
def dataTwo = countPriorSession;
# use this to scan the current session for stocks exceeding the tickCountThreshold
plot scan = dataOne > tickCountThreshold;
# use this to scan stocks which have exceeded the tickCountThreshold in the prior 24 hour session
# plot scan = dataTwo > tickCountThreshold;

Screenshots below show scan results for each of the options included in the scan. Each scan result includes an example chart set to one of the stocks in the results list. Comments and drawings have been added to demonstrate exactly what each scan option is identifying in the results list.

I have a few comments to help everyone understand some of the limitations in Thinkorswim.
  1. We cannot use any other time frame except those which are listed for the Study Filter.
  2. We cannot combine multiple time frames within the script of any Study Filter.
  3. This solution avoids the need to work with start and end times. Because it merely checks when the date changes from one day to the next. This is the cheapest and easiest solution, and fits within the limits of free solutions I can provide in this forum.

For those interested in further study. You can read about the tick_count() function here:

https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/tick-count

And if you want to know just about everything there is to know about using the Stock Hacker scan tool on Thinkorswim.... I suggest you view my Master Class video on this topic, located here:

https://www.hahn-tech.com/thinkorswim-scans-beginner-to-advanced/

If you found this solution helpful and educational, please support my work by sharing this post with everyone you know.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 4, 2024 5:05 pm