OPEN-SOURCE SCRIPT
Gann Impulse Time Structures

This is a very insightful observation based on W.D. Gann's teachings! The concept of viewing market structures through time divisions rather than just price volatility opens up a mathematical dimension to market rhythm.
What the Script Does:
1.Swing Identification: It uses standard ta.pivothigh and ta.pivotlow functions to construct a zigzag that identifies the fundamental swings (impulses and retracements).
2.Time Duration Labels: Instead of focusing on the price movement, it automatically calculates the temporal duration of each swing (in bars) and places the number directly in the middle of the drawn impulse line.
3.Color Coding: Upward swings are marked green, and downward swings are red, making it easier to see the structure of a multi-swing cycle.
How to use it to analyze your theory:
Gann mentioned observing the initial impulse in terms of 2 parts (like an up-swing and a down-swing). With this script, look closely at pairs of swings to observe if the combined unit adds up to an important Gann number (like 36, 72, or 144 bars).
You can change the Pivot Length in the settings. For shorter rhythmic cycles (like the 12-12 or 9-9-9-9 mentioned in your images), you'll want a shorter pivot length. For macroscopic market cycles (like 144 units), you might want to increase the pivot length.
Label Placement: The labels are now placed directly at the pivot points (above the highs and below the lows) instead of the middle of the line.
Text Size: Increased the label size to size.large.
Peak-to-Peak & Trough-to-Trough: Added tracking for the last peak and last trough. The labels now display the current swing duration, followed by the peak-to-peak (P-P) distance above highs, and the trough-to-trough (T-T) distance below lows.
1.Cycle Projections: Whenever a new pair of swings completes (creating a new Peak-to-Peak or Trough-to-Trough distance), the script takes that temporal duration and projects it forward into the future from that pivot point.
2.Vertical Lines & Labels: It draws a subtle dashed vertical line (green for projected peaks, red for projected troughs) extending infinitely into the future/past so you can easily spot when price approaches these rhythmic time points. It also includes a small label indicating which cycle multiple it is (e.g., P-P 1x (36) or P-P 2x (72)).
3.Multipliers: I added a setting called Projection Multipliers (defaulting to 2). This means it will project the cycle duration forward 1x and 2x. You can increase this if you want to project 3x, 4x, etc., into the future.
4.Toggle Option: If the chart gets too cluttered with vertical lines, you can easily turn them off by unchecking "Project Future Time Points" in the settings.
Previously, the indicator strictly alternated between every single local high and local low it found. This resulted in fragmented impulse lines (like the small red downswings in your image) when price paused or made minor retracements within a larger trend.
Now, if the script is drawing a downward swing and encounters multiple small bounces (lower highs and lower lows), it will intelligently extend the existing downswing line to the lowest point rather than reversing early. It will only lock in that downswing and reverse direction when a distinct upward pivot high is confirmed, breaking the downward sequence.
This behavior will natively merge those 5+5+5 micro-swings into the true overarching 15-bar continuous impulse as requested.
What the Script Does:
1.Swing Identification: It uses standard ta.pivothigh and ta.pivotlow functions to construct a zigzag that identifies the fundamental swings (impulses and retracements).
2.Time Duration Labels: Instead of focusing on the price movement, it automatically calculates the temporal duration of each swing (in bars) and places the number directly in the middle of the drawn impulse line.
3.Color Coding: Upward swings are marked green, and downward swings are red, making it easier to see the structure of a multi-swing cycle.
How to use it to analyze your theory:
Gann mentioned observing the initial impulse in terms of 2 parts (like an up-swing and a down-swing). With this script, look closely at pairs of swings to observe if the combined unit adds up to an important Gann number (like 36, 72, or 144 bars).
You can change the Pivot Length in the settings. For shorter rhythmic cycles (like the 12-12 or 9-9-9-9 mentioned in your images), you'll want a shorter pivot length. For macroscopic market cycles (like 144 units), you might want to increase the pivot length.
Label Placement: The labels are now placed directly at the pivot points (above the highs and below the lows) instead of the middle of the line.
Text Size: Increased the label size to size.large.
Peak-to-Peak & Trough-to-Trough: Added tracking for the last peak and last trough. The labels now display the current swing duration, followed by the peak-to-peak (P-P) distance above highs, and the trough-to-trough (T-T) distance below lows.
1.Cycle Projections: Whenever a new pair of swings completes (creating a new Peak-to-Peak or Trough-to-Trough distance), the script takes that temporal duration and projects it forward into the future from that pivot point.
2.Vertical Lines & Labels: It draws a subtle dashed vertical line (green for projected peaks, red for projected troughs) extending infinitely into the future/past so you can easily spot when price approaches these rhythmic time points. It also includes a small label indicating which cycle multiple it is (e.g., P-P 1x (36) or P-P 2x (72)).
3.Multipliers: I added a setting called Projection Multipliers (defaulting to 2). This means it will project the cycle duration forward 1x and 2x. You can increase this if you want to project 3x, 4x, etc., into the future.
4.Toggle Option: If the chart gets too cluttered with vertical lines, you can easily turn them off by unchecking "Project Future Time Points" in the settings.
Previously, the indicator strictly alternated between every single local high and local low it found. This resulted in fragmented impulse lines (like the small red downswings in your image) when price paused or made minor retracements within a larger trend.
Now, if the script is drawing a downward swing and encounters multiple small bounces (lower highs and lower lows), it will intelligently extend the existing downswing line to the lowest point rather than reversing early. It will only lock in that downswing and reverse direction when a distinct upward pivot high is confirmed, breaking the downward sequence.
This behavior will natively merge those 5+5+5 micro-swings into the true overarching 15-bar continuous impulse as requested.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.