OPEN-SOURCE SCRIPT
Updated

Quad Rotation - 4 Stochastics Overlay with ABCD Detection

1792
"Quad Rotation - 4 Stochastics Overlay with ABCD Detection" is a momentum indicator combining four separate Stochastics and an ABCD pattern detection system.

Each Stochastic uses different parameter settings to capture potential rotation points in market momentum.

When three or more (this number is user customizable) of these Stochastics simultaneously slope downward above the 80 level (or slope upward below the 20 level), the chart background highlights in red (bearish) or green (bullish), indicating a multi-Stochastic momentum signal.

Additionally, the script tracks Stochastic #4 to detect an ABCD pattern:

Long Pattern (A-B) triggers if Stochastic #4 remains above 90 for a specified number of bars (abBars).
Short Pattern (C-D) triggers if Stochastic #4 remains below 10 for a specified number of bars (cdBars).

Visual markers (green X for long setups, red X for short setups) appear on the chart once these conditions are met. Users can enable alerts to receive real-time notifications whenever momentum signals or ABCD patterns occur.

This combination of multi-Stochastic momentum and ABCD detection helps traders gauge potential trend exhaustion and reversal points with greater confidence.
Release Notes
Added super signal logic, where all 4 stochs are above or below 80 / 20
Release Notes
added alerts
Release Notes
bug fixes etc
Release Notes
some improvements
Release Notes
Added divergence detection and some cleanup
Release Notes
I added some code that allows for divergence colors that can match the line colors for easier visual differentiation.
Release Notes
Minor bug fix
Release Notes
one more bug fix
Release Notes
Bug fix for the Alert Conditions for Divergences section

Resetting Alerts:
At the beginning of each divergence block (for Stochastics 1–4), the script resets the corresponding divergence alert flags to false. This ensures that an alert is only flagged on the bar where the divergence condition is met.

Divergence Logic:
After resetting, the script computes the pivot points and then checks if the price and the oscillator move in opposite directions. If the condition is met, it draws a line and sets the alert flag to true for that divergence.

Alert Conditions:
The final alertcondition calls trigger an alert whenever the corresponding alert flag is true on that bar.

Release Notes
Bug fix:

In this version each divergence block resets its respective alert flags at the start of every bar. This ensures the alert conditions (which remain unchanged at the bottom) only trigger on the bar where a divergence is first detected rather than on every subsequent bar.





Release Notes
I am having a lot of trouble with the divergence alerts firing all the time.

Alert Condition Updates:
Instead of having alert conditions simply check if the divergence flag is true, each alert now includes a condition to check that the flag was false on the previous bar. For example, for Stoch1 Bearish Divergence, the alert condition changed from:

alertcondition(alertDivergenceStoch1Bearish, title="Stoch1 Bearish Divergence", message="Bearish divergence detected on Stochastic 1")
to
alertcondition(alertDivergenceStoch1Bearish and not alertDivergenceStoch1Bearish[1], title="Stoch1 Bearish Divergence", message="Bearish divergence detected on Stochastic 1")

This ensures that the alert fires only at the moment the divergence is newly detected rather than continuously on subsequent bars.
This update should prevent repeated alerts for past divergences.
Release Notes
In the divergence section (step 8), after computing a one‑shot divergence condition (using persistent “last alert bar” variables) we now add the check:

and barstate.isconfirmed

to each alertcondition(). This ensures that the alert only fires once when a bar is closed (i.e. the bar is confirmed), rather than triggering repeatedly during realtime updates (which can happen every minute or more frequently).
Release Notes
reverting the code - still t'shooting divergence alerts
Release Notes
OK I think I might have fixed the stochastic divergence alert bug...
Release Notes
reverted changes
Release Notes
I think I finally fixed the stochastic divergence alerts - this was harder than doing the entire indicator.
Release Notes
reverted again! :(

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.