OPEN-SOURCE SCRIPT
Seasonality Calculation & Statistics

Seasonality Calculation & Statistics
Key Features
Visual Chart Elements
Dashboard Tables
1. Summary Table: Displays overall strategy performance across the entire selected backtest horizon
2. Yearly Table: Provides a granular, year-by-year historical audit containing
3. Period Summary Table: Breaks down win rates across customizable historical segments (e.g., last 3, 5, 10, or 15 years) to help identify if a seasonal pattern is strengthening, decaying, or completely cooked in modern market regime
How to Use
- The Seasonality Calculation & Statistics indicator is a quantitative tool designed to backtest, track, and visually analyze specific seasonal recurring calendar patterns across historical data directly on the daily timeframe
- It eliminates guesswork by isolating user-defined date windows (e.g., May 1 to May 15), calculating historical performance metrics, projecting upcoming seasonal cycles, and providing detailed table dashboards
Key Features
- Custom Seasonal Windows: Define exact start and end dates (Day/Month) and evaluate both Long and Short seasonal directions
- Smart Vertical Timeline Markers: Clean visual boundaries marking every historical cycle and projecting upcoming future opportunities
- Shifted Exit Boundary for Visual Clarity: The vertical exit line is deliberately placed one trading day to the right ($t + 1$), cleanly enclosing the entire holding period so you can analyze every historical price bar inside the pattern without overlapping visual obstruction
- Three Built-in Statistical Tables: Comprehensive performance summaries, year-by-year logs, and multi-period lookback comparisons
- SQN & Risk Metrics: Real-time calculation of System Quality Number (SQN), Win Rate, Average Return, Average Profit, and Maximum/Average Drawdown
Visual Chart Elements
- Entry Line & Label: A vertical line (default lime) placed on the entry candle close
- Shifted Exit Line & Label: A vertical boundary line (default red) shifted one trading day to the right of the exit candle, framing the trade window perfectly for post-trade review
- Result Badges: Clean floating labels displaying the percentage return and maximum intra-trade drawdown for each individual year
- Future Projections: Forward-projected dashed lines plotted into empty chart space to highlight when the next seasonal window opens and closes
Dashboard Tables
1. Summary Table: Displays overall strategy performance across the entire selected backtest horizon
- Direction (Long / Short)
- Calendar Window & Trade Duration
- Winning Trades ratio and Win Rate percentage
- Average Return and Average Winning Trade Profit
- Average Drawdown and Maximum Intra-trade Drawdown
- System Quality Number (SQN) to evaluate statistical edge
2. Yearly Table: Provides a granular, year-by-year historical audit containing
- Specific trading cycle year
- Executed start and end dates
- Trade Return (%)
- Trade Maximum Drawdown (%)
3. Period Summary Table: Breaks down win rates across customizable historical segments (e.g., last 3, 5, 10, or 15 years) to help identify if a seasonal pattern is strengthening, decaying, or completely cooked in modern market regime
How to Use
- Apply the indicator to any asset on the Daily (1D) timeframe
- Set your desired seasonal window via Start Day / Start Month and End Day / End Month
- Select Long or Short bias
- Adjust the lookback starting years to focus on specific economic cycles
- Use the projected lines to prepare for upcoming seasonal setups ahead of time
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.