# Scan for Low Tail Year Candles

#### we29125

##### Member
I can't get this scan to work. Can someone help ?

Code:
``````def agg = AggregationPeriod.YEAR;

def ydiff = (high(period = AggregationPeriod.YEAR)[1] - low(period = AggregationPeriod.YEAR)[1]);

(low(period=agg) >= (open(period=agg)-(ydiff*0.24)) and close >= (open(period=agg)))  or

(high(period=agg) <= ((open(period=agg)+(ydiff*0.24)) and close <= (open(period=agg)));``````

@we29125 The last 2 lines of code are undefined. Removing them solves your syntax problem.

But as there is no plot or label, this code will not provide any information in a chart, watchlist, or scan.

Last edited:
how to ?

@we29125 How to remove the last 2 lines? Take it out of the code.

If i take out the 2 lines code, my criteria of small tail year candle wouldn't be there.

@we29125
Code:
``````def agg = AggregationPeriod.YEAR;

def ydiff = (high(period = AggregationPeriod.YEAR)[1] - low(period = AggregationPeriod.YEAR)[1]);

plot data = (low(period=agg) >= (open(period=agg)-(ydiff*0.24)) and
close >= open(period=agg))
or
(high(period=agg) <= (open(period=agg)+(ydiff*0.24)) and
close <= open(period=agg));``````

I think secondary period can't work.

@we29125 Don't doubt it. No secondary periods allowed in scans.

@we29125 The scanner only allows up to months. You can try and manipulate it using highest(high(period = months),12) or something.

Trying to figure out a way to scan for quarterly and yearly time-frames. When you add a filter to scans, the highest timeframe only shows monthly. Would like to be able to scan for inside year and quarterly bars. Any help would be appreciated.

Is there any way to scan quarterly and yearly timeframes in TOS? the highest timeframe I see is monthly.

@Mandalorianknight63 @divinci01 with thinkscript the quarterly is pretty much just 12/4 -- so every 3 months beginning with Jan-March being Q1, so you would just define the Months of Jan Feb March.. and so on and so forth and set the aggregation to monthly.

if you want lower aggregation you can set to days and get creative

example 15 percent from the high in last 6 months

Code:
``````input Months = 6; #Months you want to scan for

input days_In_Trading_Month = 21; # average trading days in a month

input price = close;

input Pct = 15; #percent below highestHigh

Def Total_Days = Months * days_In_Trading_Month;

Def Close_True = if close <= ((1 - Pct/100) * Highest(Price,Total_Days)) then 1

else 0;

Plot scan = if Close_True then 1 else 0;``````

Last edited:

### Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
352 Online

## 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
• Add-ons and resources
• 1 full year of unlimited support

### Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.