OmniTrader Professional Forum - OmniScan
Scan lookback

^ Top
Duxx

Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : Scan lookback
Posted : 1/2/2021 7:33 PM
Post #31333

How can I write a scan that looks for a condition in the last x days?

Here is a simple example

Loock for stocks that had volume of X in the last 126 days and C>O at the same time

Thank you
^ Top
Jim Dean

Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Scan lookback
Posted : 1/2/2021 7:36 PM
Post #31334 - In reply to #31333

Sum(-(V>100000 and C>O), 126) = 126

But that will never happen. No stock has 126 green bars in a row, that I know of.
^ Top
Duxx

Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : RE: Scan lookback
Posted : 1/2/2021 7:46 PM
Post #31335 - In reply to #31334

Jim

Thank you

Maybe my description was incorrect.

1) Look for the past 126 days for any stock with volume greater than X
The scan should give me only stocks that had that volume condition in the past 126 days
2) The second condition was that on the specific days the volume was met on condition 1.... the price ended higher

Maybe the second condition cannot be done in omniscan... but the first should be doable? I took out the C>O and still did not get what I was looking for.

Thanks
^ Top
Jim Dean

Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Scan lookback
Posted : 1/2/2021 8:42 PM
Post #31336 - In reply to #31335

Sum(-(V>100000 and C>O), 126) >= 1

The and-condition being true results in (-1), otherwise it’s zero. Negative sign converts it to positive one. Sum function processes that rule for 126 days and adds the results. If it was true for one or more of those days, the sum will report the number of days it was true for.
^ Top
Duxx

Posts: 881

Joined: 2/18/2009

User Profile
 
Subject : RE: Scan lookback
Posted : 1/3/2021 4:33 PM
Post #31337 - In reply to #31336

This worked. Thank you Jim and Happy New Year
^ Top
Jim Dean

Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Scan lookback
Posted : 1/3/2021 5:03 PM
Post #31338 - In reply to #31337

Always happy to help.
Keep that Sum( -( boolean ), periods ) trick in mind. It can be very useful for a lot of situations.


https://www.omnitrader.com/currentclients/proforum/thread-view.asp?threadid=7903&posts=6