It appears to me the subject you entered for this question has a typo. Perhaps you meant to say "scan in a defined time frame" as in, scan in a specified time frame. All scans are run in a specified time frame. You cannot run a scan that is NOT set to a defined time frame. And there is nothing you can do to the code to impact the time frame it uses. That is controlled at a higher level than the code that runs the scan. It is a user setting you apply to the Study Filter.
Your scan is very simple to create without writing a single line of code. Use the Condition Wizard, as demonstrated in the following video:
https://www.hahn-tech.com/thinkorswim-condition-wizard/