OPEN-SOURCE SCRIPT

Offence vs Defence Intraday Histogram (2)

Overview:
The "Offence vs Defence Intraday Histogram with Fixed Label" is an advanced technical indicator designed to analyze and compare the performance of offensive and defensive ETFs on an intraday basis. The indicator calculates the percentage change of selected offensive and defensive ETFs, smooths the values using exponential moving averages (EMA), and plots the cumulative difference as a histogram.

Key Features:
Offensive and Defensive ETFs:

Offensive ETFs: AMEX:XLK (Technology), AMEX:XLC (Communication Services), AMEX:XLY (Consumer Discretionary).

Defensive ETFs: AMEX:XLU (Utilities), AMEX:XLV (Healthcare), AMEX:XLP (Consumer Staples).

Percentage Change Calculation:

The indicator calculates the percentage change for each ETF and averages the values for offensive and defensive categories.

Applies a 14-period EMA to smooth the values and reduce volatility.

Cumulative Difference:

The difference between offensive and defensive values is calculated and cumulatively summed, restarting each trading day.

Plots the cumulative difference as a histogram, with color indicating whether the difference is increasing (green) or decreasing (red).

Zero Line:

A zero line is plotted to provide a reference point for the cumulative difference.

Dynamic Label Feature:

A dynamic label is created and updated based on the cumulative difference to indicate whether offensive or defensive ETFs are leading.

The label is positioned at the zero line, just to the left of the latest histogram bar, and provides real-time information on the lead.

Label Text Definitions:

Neutral

Minor Offensive Lead

Moderate Offensive Lead

Significant Offensive Lead

Minor Defensive Lead

Moderate Defensive Lead

Significant Defensive Lead

Applications:
This indicator is particularly useful for intraday traders who want to track market sentiment by observing shifts between offensive and defensive sectors. It provides a clear visual representation of which type of ETFs are currently leading, helping traders make informed decisions based on market behavior.

Clause de non-responsabilité