All indicators

Day Trader's Anchored Moving Averages

Sep 8, 2023

Static chart image
SignalsTime BasedMoving Averages

The Day Trader's Anchored Moving Averages tool plots three dynamic moving averages that reset at the start of a specified period to eliminate historical lag and provide a clearer perspective on intra-period trends.

Usage

The Usage section describes how the script can be used to identify trend direction without the interference of price data from previous sessions. This tool is specifically designed for intraday traders who require moving averages that react immediately to new market opens.

  • Trend Identification: Users can observe the relationship between the price and the three moving averages. When the price stays above the averages following a session reset, a bullish trend is confirmed for that specific period.
  • Dynamic Scaling: At the beginning of a new period (Day or Month), the moving averages start with a length of 1 and incrementally "build up" as new bars appear. This continues until the number of bars since the reset matches your specified maximum length.
  • Gap Management: Unlike traditional moving averages that may be skewed by large overnight gaps or previous days' price action, these averages are completely independent of data prior to the anchor point.

For optimal use, ensure your chosen moving average length is appropriate for the timeframe; if the length is greater than the total number of bars in a session, the average will continue to grow dynamically without ever reaching a static length before the next reset.

Details

The script functions by calculating a simple moving average (SMA) that is constrained by the time elapsed since the last anchor reset. It utilizes a custom function to track the number of bars since the period began (using ta.barssince) and compares this to the user-defined length.

By using the minimum value between the elapsed bars and the target length, the script ensures that the calculation only includes data from the current session until the target period is reached. This methodology is inspired by the Volume Weighted Average Price (VWAP), which similarly resets its calculation at the start of each session to provide a "true" daily average.

Settings

  • Source: Determines the price data used for the moving average calculations (e.g., Close, Open, HL2).
  • Highlighting: Toggles the background shading between the moving averages and the median price (HL2) for better visual trend tracking.
  • Moving Average #1/2/3: Enables or disables each individual average and allows for custom length and color selection.
  • Anchor Change Period: Sets the frequency of the reset. Options include "Day" (for daily session resets) and "Month" (for monthly resets).

FAQ

How do I use this for intraday trading? Set the "Anchor Change Period" to Day. At the market open, the averages will reset, allowing you to see how the current day's price action is developing relative to its own mean rather than yesterday's closing levels.

Why does the moving average look different at the start of the day? Because it is "anchored," it only uses data from the current session. During the first few bars of the day, the length of the average is equal to the number of bars elapsed, making it highly responsive until it reaches your maximum length setting.

How can I access this indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.