• Get $40 off VIP by signing up for a free account! Sign Up

Scan for Low Tail Year Candles


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

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:
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))
            (high(period=agg) <= (open(period=agg)+(ydiff*0.24)) and
            close <= open(period=agg));

I think secondary period can't work.
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.
@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

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:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
352 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • 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.