Scan for multi-day runner


Category:
0
0

Hi!  New to ThinkScripting.

Was thinking it would be nice to be able to edit parameters without going into the code.  I want a scan that can look for stocks that have been green X number of days and are Y% over the daily 9ema.  I would like price to be last price (not open or close).  This is what I came up with but it is not working.  Can anyone please tell me what I am doing wrong?  Thank you in advance!

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on March 14, 2021 11:49 am
486 views
0
Private answer

Seems that you already have the code setup to do what you have requested. I don't see much for me to do here. Or at least nothing that I can complete in the brief 15 min I allow for free solutions I provide in the Q&A Forum.

There is one error in your code that will prevent it working as a custom scan. You cannot use secondary aggregation periods in a scan. The following lines of code require an update in order to use this as a scan:

Delete this line entirely:

Input TimeFrame = AggregationPeriod.Day;

Change the following line....

Def EMA = ExpAverage(close(period = TimeFrame), TimeLength);

...to this:

Def EMA = ExpAverage(close, TimeLength);

As far as your idea to use "last" instead of open or close. The close function in Thinkorswim's language is always the most current price. There is never a need to use "last" and in fact for most applications trying to use "last" will cause the code to fail.

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on March 14, 2021 1:20 pm
0
Thank you much Pete!
( at March 14, 2021 6:45 pm)