-
Notifications
You must be signed in to change notification settings - Fork 261
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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();
}
DaveSkender
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
Maybe