Skip to content

Commit

Permalink
Fixed typo in supertrend indicator
Browse files Browse the repository at this point in the history
Added Ehlers Simple Decycler to moving averages
  • Loading branch information
ooples committed Dec 19, 2022
1 parent 432d6bb commit f11722e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Calculations/Trend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,15 +787,15 @@ public static StockData CalculateSuperTrend(this StockData stockData, MovingAvgT
double tempLongStop = currentValue - atrValue;
double tempShortStop = currentValue + atrValue;

double prevLongStop = longStopList.LastOrDefault();
double prevLongStop = i >= 1 ? longStopList.LastOrDefault() : tempLongStop;
double longStop = prevValue > prevLongStop ? Math.Max(tempLongStop, prevLongStop) : tempLongStop;
longStopList.AddRounded(longStop);

double prevShortStop = shortStopList.LastOrDefault();
double shortStop = prevValue < prevShortStop ? Math.Max(tempShortStop, prevShortStop) : tempShortStop;
double prevShortStop = i >= 1 ? shortStopList.LastOrDefault() : tempShortStop;
double shortStop = prevValue < prevShortStop ? Math.Min(tempShortStop, prevShortStop) : tempShortStop;
shortStopList.AddRounded(shortStop);

double prevDir = dirList.LastOrDefault();
double prevDir = i >= 1 ? dirList.LastOrDefault() : 1;
double dir = prevDir == -1 && currentValue > prevShortStop ? 1 : prevDir == 1 && currentValue < prevLongStop ? -1 : prevDir;
dirList.AddRounded(dir);

Expand Down
12 changes: 6 additions & 6 deletions Calculations/Wilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static StockData CalculateAverageTrueRange(this StockData stockData, Movi
List<Signal> signalsList = new();

var (inputList, highList, lowList, _, _) = GetInputValuesList(stockData);
var emaList = GetMovingAverageList(stockData, maType, length, inputList);
var maList = GetMovingAverageList(stockData, maType, length, inputList);

for (int i = 0; i < stockData.Count; i++)
{
Expand All @@ -39,17 +39,17 @@ public static StockData CalculateAverageTrueRange(this StockData stockData, Movi
}

var atrList = GetMovingAverageList(stockData, maType, length, trList);
var atrMaList = GetMovingAverageList(stockData, maType, length, atrList);
for (int i = 0; i < stockData.Count; i++)
{
double currentValue = inputList[i];
double atr = atrList[i];
double currentEma = emaList[i];
double currentMa = maList[i];
double prevValue = i >= 1 ? inputList[i - 1] : 0;
double prevEma = i >= 1 ? emaList[i - 1] : 0;
double prevAtr = i >= 1 ? atrList[i - 1] : 0;
double atrEma = CalculateEMA(atr, prevAtr, length);
double prevMa = i >= 1 ? maList[i - 1] : 0;
double atrMa = atrMaList[i];

var signal = GetVolatilitySignal(currentValue - currentEma, prevValue - prevEma, atr, atrEma);
var signal = GetVolatilitySignal(currentValue - currentMa, prevValue - prevMa, atr, atrMa);
signalsList.Add(signal);
}

Expand Down
2 changes: 2 additions & 0 deletions Enums/MovingAvgType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public enum MovingAvgType
EhlersNoiseEliminationTechnology,
EhlersOptimumEllipticFilter,
EhlersRecursiveMedianFilter,
EhlersSimpleDecycler,
EhlersSuperSmootherFilter,
EhlersTriangleMovingAverage,
EhlersVariableIndexDynamicAverage,
Expand Down Expand Up @@ -153,6 +154,7 @@ public enum MovingAvgType
TriangularMovingAverage,
Trimean,
TripleExponentialMovingAverage,
TrueRangeAdjustedExponentialMovingAverage,
UltimateMovingAverage,
VariableAdaptiveMovingAverage,
VariableIndexDynamicAverage,
Expand Down
2 changes: 1 addition & 1 deletion OoplesFinance.StockIndicators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<NeutralLanguage>en-US</NeutralLanguage>
<Description>Largest C# stock indicator library with over 750 to choose from and easiest to use with abilities such as making an indicator out of any other indicator or using any moving average with any indicator. </Description>
<Version>1.0.48</Version>
<Version>1.0.49</Version>
<Authors>ooples</Authors>
<Company>Ooples Finance</Company>
<RepositoryUrl>https://github.com/ooples/OoplesFinance.StockIndicators</RepositoryUrl>
Expand Down

0 comments on commit f11722e

Please sign in to comment.