Momentum down event
Marks stretches where price has fallen more than a set fraction over the last N bars.
It takes the close now divided by the close `period` bars ago, minus one: the fractional change over that window. The output is on while that change is below minus the absolute value of `thresh`. With the default threshold of 0, it is on for any stretch where the close is lower than it was `period` bars earlier.
How to read it
- The output stays on for every bar while the drop holds, so one down-move can cover many consecutive bars.
- At default settings it is on for about half the bars in the sample month, so it tracks short-term direction rather than rare turns.
- It turns on only after the close has already fallen over the window, so it confirms a drop rather than predicting one.
What it outputs
- Momentum down
- On while the close is more than the threshold below its close `period` bars earlier.
When it fires
On each bar where the close is more than the threshold below its close `period` bars earlier, and it stays on through the rest of that drop. The first bar of each run is what the events count: about 75 runs per day with default settings on SPY.
Settings
- period
- How many bars back the comparison looks. Short windows (3 to 5) flag small dips and switch on and off quickly. Long windows (60 and up) react only to drops that last, and react later.
- thresh
- The fraction a drop must exceed before the output turns on. 0 turns it on for any drop. Raising it to 0.002 keeps only drops over 0.2 percent. The sign is ignored, so a negative value acts like its positive value.
Pitfalls
- The name says event, but the output is a state that stays on through the whole drop, not a single point per move.
- The threshold is a fraction, not a percent: 0.5 asks for a 50 percent drop. On the sample month no window fell more than about 3.3 percent, so a threshold above 0.033 never fires there.
- The code uses abs(thresh), so a negative threshold behaves like its positive value even though the field accepts negatives.