# ThinkorSwim don't accept two aggregation periods?

#### fcastrof

##### New member
i have this study in a scanner but the scanner do not accept two aggregation periods. i nned to scan if the candle of current day is hammer but this candle need to close upper month support level and the low need to close below the month support level. i already have an study with month supports but the scanner do not work.

Code:
``````def n1 = 0.25;
def n2 = 0.50;
def n3 = 0.618;
def d = 1;
def p = AggregationPeriod.MONTH;
def na = Double.NaN;

def today = if GetDay() == GetLastDay() then 1 else 0;
def h = if today then high(period = p)[d] else high(period = p);
def l = if today then low(period = p)[d] else Double.NaN;
def rango = h - l;

def m = l + (rango / 2);
def pbn1 = l  - (rango * n1);
def pbn2 = l  - (rango * n2);
def pbn3 = l - (rango * 1);

def uWick = high - Max(open, close);
def lWick = Min(open, close) - low;
def body = AbsValue(open - close);
def hammer = (lWick / body >= 1.5) and (uWick / body <= 1);

def cond = (close > pbn1 and low < pbn1) or (close > pbn2 and low < pbn2) or (close > pbn3 and low < pbn3);

plot scan = hammer and cond;``````

#### tomsk

##### Well-known member
VIP
As you've discovered, the scanner does not accept secondary aggregations. So rather than test your intended conditions within a single scan code, break it up into two scan filters. First scan filter using daily aggregation to detect the hammer condition. Then add a second scan filter using monthly aggregation to test the condition you seek. Once both scan filters are true then you would have obtained the scan you seek

#### fcastrof

##### New member
As you've discovered, the scanner does not accept secondary aggregations. So rather than test your intended conditions within a single scan code, break it up into two scan filters. First scan filter using daily aggregation to detect the hammer condition. Then add a second scan filter using monthly aggregation to test the condition you seek. Once both scan filters are true then you would have obtained the scan you seek

Thanks alot, it works!

#### user1m

##### New member
Thank @tomsk for the tip!

Last edited:

#### Pelonsax

##### Active member
VIP
As you've discovered, the scanner does not accept secondary aggregations. So rather than test your intended conditions within a single scan code, break it up into two scan filters. First scan filter using daily aggregation to detect the hammer condition. Then add a second scan filter using monthly aggregation to test the condition you seek. Once both scan filters are true then you would have obtained the scan you seek
Hi Tom. I wonder if you know of any way to get scans and watchlists to aggregate at the bottom of the hour. They have the place to select ETH but it doesn't seem to make a difference in my experience. Any help would be appreciated!

## 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?