Skip to content

Commit 0bc2086

Browse files
committed
Fix DivideByZeroException exception in CCI. fixes #1
1 parent a89f51f commit 0bc2086

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/TALib.NETCore/Functions/TA_Cci.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,8 @@ private static Core.RetCode CciImpl<T>(
198198
var tempReal2 = CalcSummation(circBuffer, theAverage);
199199

200200
var tempReal = lastValue - theAverage;
201-
outReal[outIdx++] = !T.IsZero(tempReal) && !T.IsZero(tempReal2)
202-
? tempReal / (tPointZeroOneFive * (tempReal2 / timePeriod))
203-
: T.Zero;
201+
var denominator = tPointZeroOneFive * (tempReal2 / timePeriod);
202+
outReal[outIdx++] = !T.IsZero(tempReal) && !T.IsZero(denominator) ? tempReal / denominator : T.Zero;
204203

205204
// Move forward the circular buffer indexes.
206205
if (circBufferIdx > maxIdxCircBuffer)

0 commit comments

Comments
 (0)