# 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

• BenTen

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