Skip to content

Commit

Permalink
Update MovingAvg.cs (#77)
Browse files Browse the repository at this point in the history
added offset as var to EPMA like in https://www.tradingview.com/script/OUpQLBSv-End-Point-Moving-Average-CC/
and corrected computation of weight

Signed-off-by: quiithub <[email protected]>
  • Loading branch information
quiithub authored Sep 21, 2024
1 parent 6d2c235 commit c036fae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Calculations/MovingAvg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public static StockData CalculateArnaudLegouxMovingAverage(this StockData stockD
/// <param name="length">The length.</param>
/// <param name="offset">The offset.</param>
/// <returns></returns>
public static StockData CalculateEndPointMovingAverage(this StockData stockData, int length = 11)
public static StockData CalculateEndPointMovingAverage(this StockData stockData, int length = 11, int offset = 4)
{
List<double> epmaList = new();
List<Signal> signalsList = new();
Expand All @@ -350,7 +350,7 @@ public static StockData CalculateEndPointMovingAverage(this StockData stockData,
double sum = 0, weightedSum = 0;
for (var j = 0; j <= length - 1; j++)
{
double weight = length - j - length;
double weight = length - j - offset;
var prevValue = i >= j ? inputList[i - j] : 0;

sum += prevValue * weight;
Expand Down

0 comments on commit c036fae

Please sign in to comment.