INDEX TRADING Secret

Overview
This Pine Script indicator unveils a powerful "secret" strategy inspired by WD Gann's principles for calculating support and resistance levels across multiple timeframes (daily, weekly, monthly, and yearly). It is designed specifically for intraday trading in Indian indices such as NIFTY, BANKNIFTY, FINNIFTY, and SENSEX. By leveraging Gann's Square of Nine methodology, the script derives key static support and resistance levels from significant highs and lows in each timeframe. These levels act as vibrational points where price is likely to react, based on Gann's geometric and mathematical insights into market cycles.
The script integrates Volume Weighted Average Price (VWAP) as a trend confirmation tool, helping traders filter signals and align with the prevailing market momentum. VWAP serves as a dynamic benchmark: prices above VWAP indicate bullish bias, while prices below suggest bearish conditions.
This approach combines Gann's time-price squaring with modern volume analysis, enabling precise entry/exit decisions in volatile intraday sessions. The levels are plotted as horizontal lines for easy visualization on lower timeframes (e.g., 5-min or 15-min charts), with options to toggle visibility for each timeframe to avoid clutter.
Key Features
Gann Level Calculation (Square of Nine Method):
For each timeframe (daily, weekly, monthly, yearly), the script identifies a pivot price, typically the square root of a key value like the previous period's high, low, or close.
Support levels are calculated by subtracting angular increments (e.g., 45°, 90°, 135°, 180°) from the square root of the pivot, then squaring the result:Support Level = (√Pivot - (Angle / 360))²
Resistance levels are calculated by adding the increments:Resistance Level = (√Pivot + (Angle / 360))²
Common angles used: 45° (0.125 increment), 90° (0.25), 135° (0.375), 180° (0.5), 225° (0.625), 270° (0.75), 315° (0.875), 360° (1.0).
Timeframe-specific pivots:
Daily: Based on previous day's high/low/close.
Weekly: Based on previous week's high/low/close (using security() function for higher timeframe data).
Monthly: Based on previous month's high/low/close.
Yearly: Based on previous year's high/low/close, ideal for long-term cycle analysis.
The script automatically fetches higher timeframe data via Pine's security() function, ensuring levels update in real-time on intraday charts.
VWAP Integration:
Plots the standard VWAP line (using ta.vwap for accuracy), resetting at session open for intraday focus.
VWAP acts as a trend filter: It confirms bullish conditions when price is above it and bearish when below.
Plotting and Customization:
Support levels plotted in green, resistance in red, with labels showing timeframe (e.g., "Daily S1", "Weekly R2").
User inputs for selecting which timeframes to display, line styles, and angular increments.
Alerts can be set for price crossing key levels or VWAP.
Trading Strategy: Intraday Rules Using Gann Levels and VWAP
This strategy focuses on confluence between Gann levels and VWAP for high-probability trades in Indian indices. Trade on intraday charts (e.g., 5-min) during market hours (9:15 AM - 3:30 PM IST). Always use risk management: Position size 1-2% of capital, with stops beyond the nearest Gann level.
Buy Signals:
Price above a Gann support level and above VWAP: Indicates upward momentum with support holding. Enter long, targeting the next resistance.
Price above a Gann resistance level and above VWAP: Suggests a breakout. Enter long for continuation, targeting higher timeframe resistance.
Sell Signals:
Price below a Gann support level and below VWAP: Indicates downward momentum with support broken. Enter short, targeting the next support.
Price below a Gann resistance level and below VWAP: Suggests rejection at resistance. Enter short for reversal, targeting lower support.
Alternative Use: Daily Levels as Stop Loss:
For simpler setups, ignore higher timeframes and use only daily Gann support/resistance as protective stops.
Example: In a long trade, place stop below daily support; in a short, above daily resistance. This minimizes risk while letting winners run with VWAP as the trailing guide.
Example Usage
On NIFTY 5-min chart: Daily support at 24,500 (calculated from prior day's low via Square of Nine). If price bounces above 24,500 and crosses VWAP upward, buy with target at weekly resistance (e.g., 24,800).
Risk: If price falls below support and VWAP, exit or reverse to short.
Backtesting and Notes
Backtest on historical Indian index data to validate. Gann levels work best in trending markets; combine with volume spikes or RSI for filters. Remember, markets are cyclical—yearly levels often define major turns, while daily/weekly handle intraday noise. This is not financial advice; test thoroughly
Script sur invitation seulement
Seuls les utilisateurs approuvés par l'auteur peuvent accéder à ce script. Vous devrez demander et obtenir l'autorisation pour l'utiliser. Celle-ci est généralement accordée après paiement. Pour plus de détails, suivez les instructions de l'auteur ci-dessous ou contactez directement siddanagouda.
TradingView ne recommande PAS de payer ou d'utiliser un script à moins que vous ne fassiez entièrement confiance à son auteur et que vous compreniez comment il fonctionne. Vous pouvez également trouver des alternatives gratuites et open-source dans nos scripts communautaires.
Instructions de l'auteur
Clause de non-responsabilité
Script sur invitation seulement
Seuls les utilisateurs approuvés par l'auteur peuvent accéder à ce script. Vous devrez demander et obtenir l'autorisation pour l'utiliser. Celle-ci est généralement accordée après paiement. Pour plus de détails, suivez les instructions de l'auteur ci-dessous ou contactez directement siddanagouda.
TradingView ne recommande PAS de payer ou d'utiliser un script à moins que vous ne fassiez entièrement confiance à son auteur et que vous compreniez comment il fonctionne. Vous pouvez également trouver des alternatives gratuites et open-source dans nos scripts communautaires.