OPEN-SOURCE SCRIPT

Anchor-Point Average

89
Anchor-Point Average (APA) - Pine Script Indicator
Overview
The Anchor-Point Average (APA) is a unique technical indicator that calculates the average price from a user-defined starting point to the present. Unlike traditional Simple Moving Averages (SMA) that use a rolling window of fixed periods, APA uses a fixed anchor point in time, creating a cumulative average that grows with each new bar.

Key Features
Interactive Time Selection
Click-to-Select: Simply click on any bar in the chart to set your anchor point

Visual Markers: Clear labels show the start point with date/time and current average price

Flexible Analysis: Anchor to any significant event, price level, or time period

Multiple Price Types
Choose from 7 different price calculations:

Close: Standard closing price

Open: Opening price for gap analysis

High/Low: Track resistance and support levels

HL2: Midpoint price (High + Low) / 2

HLC3: Typical price (High + Low + Close) / 3

OHLC4: Average price (Open + High + Low + Close) / 4

Customizable Display
Color Settings: Customize both anchor point and current label colors

Clean Interface: Minimalist design with essential information only

Professional Labels: Display average price, sample count, and timestamps

Smart Alerts
Cross Above Alert: Notifies when price crosses above the anchor-point average

Cross Below Alert: Notifies when price drops below the anchor-point average

Visual Markers: Green triangles (bullish cross) and red triangles (bearish cross)

Why Anchor-Point Average?
Different from Traditional SMA
Traditional moving averages use a rolling window (e.g., last 20 bars), which means older data constantly drops out. APA maintains all data from your chosen anchor point, providing a true cumulative average that represents the mean price since that specific moment.

Use Cases
Long-Term Investment Analysis

Calculate average entry cost from your first purchase date

Track performance against your initial investment timing

Identify if current price is above or below your historical average

Event-Based Analysis

Anchor to product launches, earnings reports, or policy announcements

Measure price behavior after significant market events

Compare current price to post-event average levels

Support/Resistance Identification

The anchor-point average often acts as dynamic support or resistance

As more data accumulates, the line becomes increasingly stable

Price reactions to this level can signal trend continuation or reversal

Volatility Assessment

Increasing distance from anchor average indicates growing volatility

Convergence suggests consolidation or equilibrium

Track how current price deviates from long-term mean

Technical Advantages
Stability Over Time
As the sample size grows, the anchor-point average becomes progressively smoother and less sensitive to short-term volatility, providing a robust reference level.

Historical Context
Unlike moving averages that "forget" old data, APA preserves the entire price history from your chosen point, offering complete context for your analysis.

Psychological Significance
Often traders anchor mentally to specific dates or events. This indicator makes that psychological level visible and quantifiable.

How to Use
Add to Chart: Apply the indicator to any TradingView chart

Select Anchor Point: Click on the bar where you want to begin calculation

Choose Price Type: Select which price component to average (default: Close)

Customize Colors: Adjust label colors to match your chart theme

Set Alerts: Create alerts for price crossovers to stay informed

Perfect For
Long-term investors tracking cost basis

Swing traders analyzing from key pivot points

Event-driven traders measuring post-announcement trends

Anyone seeking a stable, cumulative price reference

Technical Notes
Built on Pine Script v5

Overlay indicator (plots directly on price chart)

Real-time calculation with bar-by-bar updates

Supports all timeframes and instruments

Zero repainting - calculations are final once bar closes

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.