# Scanning For The Past

#### JJJJJJ11111

##### Member
#Scan for Stockbee Combo Scan

#This is a scan

def day_range = Round(((close - low) / (high - low)) * 100, 0);

plot bull_combo= if ((Close-Open)>=.90 and (Close[1]-Open[1])<(Close-Open) and day_range>=70 and Volume>100000 and (Close[1]/Close[2])<1.02) or ((Close/Close[1])>=1.04 and Volume>Volume[1] and day_range>=70 and Volume>100000 and (Close[1]/Close[2])<1.02 and Close>=3) then 1 else 0;

Code:
``````#Combo Bearish Scan for ToS

def minvol3=lowest(volume,3);

plot signal= ((open-close)>=.90 and volume>=100000 and (open[1]-close[1])<(open-close) and Close>=3 and minvol3>=100000) or ((Close/Close[1])<=0.96 and Volume>Volume[1] and volume>=100000 and (Close[1]/Close[2])>=.98 and Close>=3 and minvol3>=100000);``````

this is a scan which shows which stocks has move more than 4% today when i run it today.
As i want to see the result from yesterday , or even days 3, 4, 5 days in the past so i can backtest it.
Is there a way to add a length option in it scan for historical days?

Solution
anyone can help to create a script for to search for reversal daily candle in the past maybe up to 5 days(customizable day) .

Code:
``````#Past 5 days reversal candle
def reversalcandle1 = (AbsValue(close - high ) > 6 * AbsValue ( open - close ) and AbsValue(close - open ) < .1 * AbsValue ( high - low ));
def reversalcandle2 = (AbsValue(close - low ) > 6 * AbsValue ( open - close ) and AbsValue(close - open ) < .1 * AbsValue ( high - low )) ;

input daysLookBack = 5;
plot scan = true(reversalcandle1 , daysLookBack);``````

look at my upper study, it uses sum() to check if a condition happened

#### JJJJJJ11111

##### Member
anyone can help to create a script for to search for reversal daily candle in the past maybe up to 5 days(customizable day) .

Code:
``````#Past 5 days reversal candle
def reversalcandle1 = (AbsValue(close - high ) > 6 * AbsValue ( open - close ) and AbsValue(close - open ) < .1 * AbsValue ( high - low ));
def reversalcandle2 = (AbsValue(close - low ) > 6 * AbsValue ( open - close ) and AbsValue(close - open ) < .1 * AbsValue ( high - low )) ;

input daysLookBack = 5;
plot scan = true(reversalcandle1 , daysLookBack);``````

#### halcyonguy

##### Well-known member
VIP
anyone can help to create a script for to search for reversal daily candle in the past maybe up to 5 days(customizable day) .

Code:
``````#Past 5 days reversal candle
def reversalcandle1 = (AbsValue(close - high ) > 6 * AbsValue ( open - close ) and AbsValue(close - open ) < .1 * AbsValue ( high - low ));
def reversalcandle2 = (AbsValue(close - low ) > 6 * AbsValue ( open - close ) and AbsValue(close - open ) < .1 * AbsValue ( high - low )) ;

input daysLookBack = 5;
plot scan = true(reversalcandle1 , daysLookBack);``````

look at my upper study, it uses sum() to check if a condition happened

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?