Scanning For Not Equal To


Category:
0
0

Hello,

I am trying to make a scan for something is that not equal to one of my criteria. I will use some demo code in this example.

 

def pop = (close[1] * 1.2)  < close and volume > 100000;

I need to scan for something where there was the following pattern:

Day 1: no pop

Day 2: pop

Day 3: no pop

I don’t know how to scan for something where there was “no pop” 1 day ago and “no pop” 3 days ago. Is there a not equals sign for think or swim?

Here’s my attempt:

plot scan = is not equal to pop[3] and pop[2] and is not equal to pop[1];

Thank you!

Marked as spam
Posted by (Questions: 34, Answers: 56)
Asked on April 5, 2018 3:27 pm
99 views
0

Day 4: Current day

( at April 5, 2018 3:29 pm)
0
Private answer

No, every Study Filter you add to the scan is added as “equals true”. So you need to construct code that will check for a condition and exclude stocks where that condition is NOT true. The way we do this in most programing languages is to create a true/false condition, then place an exclamation point immediately before it. The exclamation point is the same as saying NOT. (as in NOT true).

So from your example:

plot scan = !pop[3] and pop[2] and !pop[1];

In english this is:

return true when pop[3] is false, pop[2] is true and pop[1] is false.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 5, 2018 4:30 pm