scan for Avg open price vs. close price


Category:
0
0

Hello Pete,

whats the best way to scan for stocks that have the following criteria:-

Avg. open price for the last 30 days is .30 cents of the Avg. close price.

for example .

in the last 30 days , the Avg. open price is $15.20 and Avg. close price is $15.50

Avg. open price for the last 30 days is .30 cents of the Avg. close price.

Thank you

RESOLVED
Marked as spam
Posted by (Questions: 13, Answers: 13)
Asked on October 14, 2017 9:05 pm
149 views
1
Private answer

If I understand the math correctly, we should get there with this:
def avgOpen = Average(open, 30);
def avgClose = Average(close, 30);
def exact = AbsValue(avgOpen - avgClose) == 0.3;
def greater = AbsValue(avgOpen - avgClose) > 0.3;
def lesser = AbsValue(avgOpen - avgClose) < 0.3;
plot scan = exact;

Notice we have three ways to run this. You stated that you wanted the difference between the average open and the average close to be equal to 0.3 so we scan for ‘exact’. You did not specify which average should be higher (open versus close). So we use the AbsValue() function to get the difference without the minus sign. I included a couple other calculations ‘greater’ and ‘lesser’ because I anticipated you really are not looking for an exact match. I did not test this, just tapped it out based on logic. Should work but let me know.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 15, 2017 9:01 am
0
Private answer

Pete,

Thank you for the quick response,

I ran the scan and did not get any results, I think its because of the Exact function( not sure ), would having a range work better ?

I would like to have the Avg. close price to be Higher than the Avg. open price.

 

Marked as spam
Posted by (Questions: 13, Answers: 13)
Answered on October 15, 2017 4:40 pm
0

Look more closely at the code I provided and you will see I anticipated this and also provided that as an option. Read my response and you will see how to change it’s behavior.

( at October 15, 2017 6:55 pm)
0

agreed,
how would suggest changes to the variables to have the scan return some stocks

( at October 16, 2017 8:12 am)
0

From my solution: “I included a couple other calculations ‘greater’ and ‘lesser’”

So, replace ‘exact’, with either ‘lesser’ or ‘greater’ depending on which one you want. I don’t know any clearer way to explain this.

( at October 16, 2017 1:25 pm)