@Qadeer
MTF scripts are not allowed in the scanner, watchlists, or conditional orders
It is because of the fundamental way that the widget works.
In the scans, watchlists, etc... before we start to create the condition filters, we choose the aggregation period.
It is locked in.
After that, the scanner executes all filter conditions solely within the aggregation chosen.
If it encounters an aggregation period within the filter script that doesn't match what has already been chosen; it produces the error message: "secondary aggregations not allowed".
Workaround:
Normally, you could break up the scan.
Run the scan within the daily aggregation.
Scan those results into your hourly filter.
But that would not work with this script.
Even if you rewrote the script and removed all the aggregation periods
and created the multi-scans;
the scanner would not yield results you are expecting.
There are HighestAll() functions in this script.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/HighestAll
HighestAll is a function used on a CHART.
Its calculations are arbitrarily based on how many bars are on your CHART.
The scanner has no idea how many bars happen to be on your CHART at the moment,
So while it would run without errors; it would not be able to return the results you are seeking.