Scanner for RSI and MACD at yearly lows


Category:
0
0

Hello Pete,

Please see attached scanner:

 

RSI the lowest it has been in the past 250 days

MACD the lowest it has been in the past 250 days

 

The issues I am facing are:

 

Plot under ##1 works fine by itself. However, when I run ##2 or ##3, I either get no results or I get “Script Timed Out” error after a few minutes.

Plot under ##2 gave results one time only. All other times, I get “Script Timed Out” error after a few minutes.

 

I also tried the following method:

 

##4 works similarly to the above, i.e., MACD code results in a few ticker symbols, RSI code does not.

 

Please share some thoughts on how to make these two conditions work together. Also, if at all possible, please advise on how to check for “lowest” values of RSI or MACD starting a few days in the past – i.e., MACD should have established the yearly low in the past 2-3 bars, and should have started curling up.

 

Kind thanks.

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on March 19, 2021 3:34 pm
186 views
0
Private answer

In the future, please include your code in text rather than a screenshot. I only get 15 minutes to provide each free solution and if I have to type out all of your code manually you get zero solution from me.

The issue with the scan timing out. That has very little to do with your scan and almost everything to do with your pre-filters. Almost any scan can be made to time out if you try to run it against the entire universe of ticker symbols.

Details here:

https://www.hahn-tech.com/thinkorswim-scans-beginner-to-advanced/

As for your scan signals. Based on the variables you have included in your code I would write them like this:

plot scan = macdValue < Lowest(macdValue[1], 251) and rsiValue < Lowest(rsiValue[1], 251);

 

Marked as spam
Posted by (Questions: 37, Answers: 4117)
Answered on March 19, 2021 7:15 pm
0
Hello Pete, Thank you for this methodical and minimalistic approach to coding. Best Regards.
( at March 20, 2021 3:52 pm)
0
Private answer

Simplified it.  Unable to "tag" the code here.

<code>

declare lower;

##Daily

input howFarBack = 200;

##MACD

def MACDValue = reference MACD().VALUE;

##RSI

def rsiValue = reference RSI()."RSI";

def rsiOverS = rsiValue <=30;

##Scanner

plot scan = macdValue < Lowest(macdValue[1], howFarBack) and rsiValue < Lowest(rsiValue[1], howFarBack) and rsiOverS;

</code>

Marked as spam
Posted by (Questions: 1, Answers: 1)
Answered on March 20, 2021 4:20 pm