Scanning for historical after hours spikes?


Category:
0
0

Hi all. So I have an idea I’d like to test out, but I’m not sure how to put it together into a working thing.

I basically want to scan for premarket price spikes that have happened say up to 30 days ago. I want the scanner to return the list of tickers and some basic info (how many days back the premarket price spike was, how big a percentage did it spike from from the close of the day prior, etc).

I know you can use the AfterHours_Percent_Change study for the current day, but how would you go about scanning the last 30 days to return a list of stocks that spiked to an extended hours high for some after hours/premarket session within those 30 days, with that high being greater than some defined percentage from the close prior to the spike?

I only know how to return the list for the current day:

def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();
def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime();
def PMStart = RMhrs[1] and PMhrs;
def PMHigh = CompoundValue(1, if PMStart then high else if PMhrs then Max(high, PMHigh[1]) else PMHigh[1], 0);

plot scan = PMHigh > 1.15*close[0];

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on July 11, 2021 6:10 am
225 views
0
Private answer

Custom scans on Thinkorswim only have access to 11 trading sessions of historical data when using an intraday time frame:

https://tlc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker/studyfilters

Here is a more detailed list of limitations:

  1. Yes, it is possible to scan for historical spikes occurring during the extended hour session on Thinkorswim.
  2. You can only look back 11 trading sessions on Thinkorswim.
  3. The scan will only return a list of ticker symbols.
  4. Scans can NOT return anything other than a list of symbols. The additional information you requested the scan to output are completely impossible.
  5. The following items would need to be accomplished through the use of custom watchlist columns: "...how many days back the premarket price spike was, how big a percentage did it spike from from the close of the day prior..."
  6. The solution is far more complex than any solution I can provide free of charge in the Q&A Forum.
  7. In order to run a scan on historical data more than 11 trading sessions ago you must use another trading platform.

 

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on July 11, 2021 8:10 am
0
Thank you. 11 trading sessions is plenty. How would you return just the list of tickers?
( at July 13, 2021 6:57 am)
0

Copy the code from the "AfterHours_Percent_Change" Study Filter of the scan tool. Remove the last line of code and replace it with the following:

rec trackSpikes = if BarNumber() == 0 then 0 else if meet_scan_criteria then 1 else trackSpikes[1];
plot hasSpiked = trackSpikes > 0;

Adjust the various inputs parameters as needed.

( at July 13, 2021 1:17 pm)
0
Thank you.
( at July 15, 2021 8:03 am)