OPEN-SOURCE SCRIPT
Swing from stochastic with alert

Stochastic ZigZag [SH/SL] — How It Works
This indicator uses the Stochastic %K (9,3,3) to identify and confirm Swing Highs and Swing Lows on the price chart, then connects them with a ZigZag line.
Swing Detection Logic
When %K crosses below 20 → enters "seeking Low" mode, tracking the lowest price. Once %K crosses above 80, that lowest point is confirmed as a Swing Low (SL)
When %K crosses above 80 → enters "seeking High" mode, tracking the highest price. Once %K crosses below 20, that highest point is confirmed as a Swing High (SH)
If the same swing type repeats before the opposite appears, only the more extreme value is kept
Visual Output
ZigZag line connecting alternating SH and SL points (customizable color, width, style)
Tiny SH / SL labels at each confirmed swing point
Dashed horizontal level lines extending right from each confirmed SH and SL (last 3 of each shown); a level line ends at the bar where price closes through it
This indicator uses the Stochastic %K (9,3,3) to identify and confirm Swing Highs and Swing Lows on the price chart, then connects them with a ZigZag line.
Swing Detection Logic
When %K crosses below 20 → enters "seeking Low" mode, tracking the lowest price. Once %K crosses above 80, that lowest point is confirmed as a Swing Low (SL)
When %K crosses above 80 → enters "seeking High" mode, tracking the highest price. Once %K crosses below 20, that highest point is confirmed as a Swing High (SH)
If the same swing type repeats before the opposite appears, only the more extreme value is kept
Visual Output
ZigZag line connecting alternating SH and SL points (customizable color, width, style)
Tiny SH / SL labels at each confirmed swing point
Dashed horizontal level lines extending right from each confirmed SH and SL (last 3 of each shown); a level line ends at the bar where price closes through it
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.