Scan for stocks that have spiked at least once in the past


Hello Pete,


So below I have provided the code for a chart label that counts the amount of time a stock has spiked in the past (aka a former runner). My question is, how can we turn this into scan criteria. When using this scanner, I only want to return stocks that have spiked at least 1 day in the past on the daily chart in the within past 2 years. This code works well as a label, now let’s see if we can create a scan.


input percentSpike = 40.0;

input countLimit = 5;

def percentRise = 100 * (high / open – 1);

def condition = percentRise >= percentSpike and volume > 5000000;

rec counter = if condition and BarNumber() >= 0 then counter[1] + 1 else counter[1];






*Bonus, this will be even cooler if we can add a slider (optional)

Marked as spam
Posted by (Questions: 16, Answers: 43)
Asked on February 14, 2019 5:32 am
Private answer

plot scan = counter >= 1;

We just set the plot statement to return true/false based on the value of the counter variable. Greater than or equal to 1 means there is been at least 1 spike. The 2 year thing, well you are restricted to two years historical data by the scan engine. So we don’t need any code to handle the length of time.

Marked as spam
Posted by (Questions: 35, Answers: 1784)
Answered on February 16, 2019 11:21 am