jchariton 1 posts msg #162032 - Ignore jchariton |
11/19/2025 8:24:31 AM
Looking for help creating a filter that will give me stocks that:
yesterdays close is > 2x average daily price volatility
average volume > 1 millions shares per day
at least second consecutive day of this criteria
I started with this and am getting an error I can't fix - any ideas?
/* --- DEFINE AVERAGE DAILY % VOLATILITY --- */
set{avg_vol_pct, ( atr(20) / close ) * 100}
/* --- YESTERDAY'S % MOVE --- */
set{pct_move_yest, abs(close 1 day ago / close 2 days ago - 1) * 100}
/* --- 5× VOLATILITY THRESHOLD --- */
set{threshold, avg_vol_pct * 2}
/* --- FILTER: YESTERDAY'S MOVE > 5× VOLATILITY --- */
pct_move_yest > threshold
|
xarlor 625 posts msg #162033 - Ignore xarlor |
11/19/2025 9:46:32 AM
Oof, buddy. You got hit by a double whammy of SF syntax peculiarities:
1. SF can only do 1 operation per line. If you subtract something and divide in the same line, SF breaks. Split each operation into its own line.
2. abs() takes a single value. You cannot do an operation within it. Do all operations in prior lines, then take the single resulting value and put it in abs().
Here is the filter you posted in working form:
Now, to your original intent, I'm not understanding what your goal is.
"yesterdays close is > 2x average daily price volatility"
This is comparing the ticker's price with its (high - low) value. The two do not correlate. A ticker trading at $5 or more is always going to be higher than its trading range. Can you explain what you're going for in more detail?
|