OPEN-SOURCE SCRIPT
Aggiornato Gann Swing Points

Indicator Logic
This is a GANN-style swing indicator that classifies bars based on their high/low structure relative to the previous bar.
I strongly encourage you to replay bars on Tradingview using this indicator to get a sense of how it creates pivot (or swing) points
Bar Classification:
Up-Bar (direction: 'up'): Higher High and Higher Low (HH/HL)
Down-Bar (direction: 'down'): Lower High and Lower Low (LH/LL)
Outside-Bar (generates 2 directions):
Green: 'down' then 'up'
Red: 'up' then 'down'
Inside-Bar: No direction generated (HL/LH)
Swing Line Logic
The swing line continues in the current direction until n opposite directions are detected.
n is the "n-direction" parameter (commonly set to 2, so 2 consecutive opposite direction is needed to turn the swing)
When n opposing directions occur, the swing turns, creating a pivot point
Inside bar is ignored, so e.g up-bar -> inside-bar -> up-bar generates "up", "up" direction
A top pivot is formed when the swing turns down
A bottom pivot is formed when it turns up
Note: This swing logic is inherently lagging — it only confirms tops/bottoms after the fact
This swing structure gives the system a clear and noise-resistant way to identify pivot points (swing-points)
This is a GANN-style swing indicator that classifies bars based on their high/low structure relative to the previous bar.
I strongly encourage you to replay bars on Tradingview using this indicator to get a sense of how it creates pivot (or swing) points
Bar Classification:
Up-Bar (direction: 'up'): Higher High and Higher Low (HH/HL)
Down-Bar (direction: 'down'): Lower High and Lower Low (LH/LL)
Outside-Bar (generates 2 directions):
Green: 'down' then 'up'
Red: 'up' then 'down'
Inside-Bar: No direction generated (HL/LH)
Swing Line Logic
The swing line continues in the current direction until n opposite directions are detected.
n is the "n-direction" parameter (commonly set to 2, so 2 consecutive opposite direction is needed to turn the swing)
When n opposing directions occur, the swing turns, creating a pivot point
Inside bar is ignored, so e.g up-bar -> inside-bar -> up-bar generates "up", "up" direction
A top pivot is formed when the swing turns down
A bottom pivot is formed when it turns up
Note: This swing logic is inherently lagging — it only confirms tops/bottoms after the fact
This swing structure gives the system a clear and noise-resistant way to identify pivot points (swing-points)
Note di rilascio
Updated for multi time frame strategy use. Higher time frame (htf) swings can be viewed, to check against chart time frame (ltf). Many good strategies come from anticipating htf action from ltf behavior, now we don't have to switch time frame to check the htf swings to compare with the lower time frame (ltf). It's available in the same chart.Note di rilascio
Bug fix:Corrected Pre-market weekly htf swing-lines misbehavior
Note di rilascio
More bug fixes for strange htf behavior at trading hour gapsNote di rilascio
Refactor and housekeeping.- Removed classification of current unfinished bar.
- Moved bar-classification
- removed some unused code
- refactored some variables to be more meaningful
- set default color of htf swing lines to blue
Note di rilascio
Removed bar type display from status line for less clutter Note di rilascio
- Updated input structure to be more clean and logical- Added "show swing confirmation" option to see where the swing lines confirmed a top/bottom.
- Some code refactoring that helps further dev
Note di rilascio
Accidentally renamed the indicator to "dev", naming it backNote di rilascio
- Added option to show trend based on High time frame (HTF) swings.- offset the trend background color by 1 bar to only show trend until the last finished bar (current bar not finished, swings not calculated)
Note di rilascio
- New feature: swing volume trend detectionYou can see if volume trended up or down on swing: Dashed line for falling vol, solid for rising. This is interesting if you like to watch the price action vs volume. You might want to watch convergence / divergence between these and identify potential new trend / trend exhaustion, or whatever patterns you find useful.
- Rearranged input fields
Note di rilascio
- Added checkbox to display swing turns at confirmation time (actual turn) instead of where the low/high happened- corrected swing volume MA name display from "EMA", to "MA" at input fields and code, since it's a choice of SMA or EMA
Note di rilascio
- New features (SIGNIFICANT new options)-> Outside bar logic now modifiable to only generate 1 direction (up/down based on green or red bar) instead of 2 directions. This makes the the swing overlay more adaptable how you like to treat those bars.
-> Even bigger optional setting for swing construction is the new "3BAR" vs "2BAR" Bar classification setting. 3BAR is the new option, 2BAR was the default so far, comparing bar to last bar. 3BAR makes the comparison of current bar to last 2 bar's highs (max of the 2) and lows (min of the 2). This is like melting the 2 last bar's into 1 bigger bar and classify the current based on that.
-- It creates less sensitive structure, good to use it in choppy market regime.
Coming up next update: extreme swing detection (coloring extreme in time and/or price based on last N swings)
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.