• LIMITED TIME ONLY: Take $40 off VIP with code: BTD40.

Weird Secondary Aggregration Period errors in scanner custom filter.

new_spy123

New member
What I am trying to do is setup a scanner custom filter that alerts me when 150 daily EMA is breached on the hourly chart. For this, I wrote the below script:

Ruby:
# Alert when 150 daily ema is breached on the hourly chart


input aggHourly = AggregationPeriod.HOUR;
input aggDaily = AggregationPeriod.DAY;
input lengthDaily = 150;
plot expAvgDaily = ExpAverage( close( period = aggDaily), lengthDaily );

# true when close is between both lines
def condMet = close(period = aggHourly) < expAvgDaily;

Alert(condMet, "150 daily ema breached on the hourly chart", alert.once, Sound.ding);

I set aggregation to 1h on the filter but then it says, Secondary Aggregation period not allowed: DAY. Refer to the below screenshot.

r3mzGFR.png


Interestingly, if I chart aggregation to Daily (D), error goes away but I doubt it will work as I am not sure how we can reference hourly data on Daily chart. Refer to the below screenshot

7ucUYLG.png


What am I missing here? I have gone through the documentation on secondary aggregation and the only thing I see is that we cannot reference smaller period than chart time period but in this case, it seems inverse.
 
Solution
@new_spy123
The Peculiarities Of Secondary Aggregations
There is no real work-around to the limitation of no secondary aggregations can be used in the TOS Scan Hacker
For those w/ in-depth coding skills there is an attempt at scripting w/o using timeframes but successes have been few: https://usethinkscript.com/threads/fix-secondary-period-not-allowed-in-thinkorswim-scanner.927/)
a2.png

You can read about it here:
https://tlc.tdameritrade.com.sg/center/howToTos/thinkManual/Scan/Stock-Hacker/studyfilters

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
@new_spy123
The Peculiarities Of Secondary Aggregations
There is no real work-around to the limitation of no secondary aggregations can be used in the TOS Scan Hacker
For those w/ in-depth coding skills there is an attempt at scripting w/o using timeframes but successes have been few: https://usethinkscript.com/threads/fix-secondary-period-not-allowed-in-thinkorswim-scanner.927/)
a2.png

You can read about it here:
https://tlc.tdameritrade.com.sg/center/howToTos/thinkManual/Scan/Stock-Hacker/studyfilters
 
Last edited:
Solution

new_spy123

New member
@new_spy123
The Peculiarities Of Secondary Aggregations
There is no real work-around to the limitation of no secondary aggregations can be used in the TOS Scan Hacker
(Some extremely good scripters, experiment w/ re-writing their studies. Instead of using aggregations, they calculate everything in seconds :eek:)
a2.png

You can read about it here:
https://tlc.tdameritrade.com.sg/center/howToTos/thinkManual/Scan/Stock-Hacker/studyfilters
Can you point to me such workaround/hack? I am curious about it. Thanks!
 

Similar threads

Top