Skip to content

Average Daily Range (ADR) #1250

@bobtabor

Description

@bobtabor

the problem

The library contains ATR (Average True Range). The ADR (Average Daily Range) has been popularized recently by popular trader Qullamaggie (Kristjan Kullamägi ... https://qullamaggie.com/). The formula and intent is slightly different -- ATR captures movement with pre-market gaps, but ADR captures intraday only and is used by swing traders (and maybe day traders) to decide if there's enough movement in the stock to warrant taking a position.

See: https://www.alpharithms.com/average-daily-range-adr-090415/

I was able to ask ChatGPT for an implementation, but I have no confidence in the algorithm.

an idea

No response

code example

public static decimal CalculateDailyRangePercentage(Daily day)
        {
            return ((day.High - day.Low) / day.Close) * 100;
        }

        public static decimal CalculateAverageDailyRangePercentage(List<Daily> data, int period = 20)
        {
            List<decimal> dailyRangePercentages = new List<decimal>();

            if (data.Count < period) return 0M;

            for (int i = data.Count - period; i < data.Count; i++)
            {
                decimal dailyRangePercentage = CalculateDailyRangePercentage(data[i]);
                dailyRangePercentages.Add(dailyRangePercentage);
            }

            return dailyRangePercentages.Average();
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Maybe

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions