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 de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.