Skip to content

Commit 07fd86d

Browse files
committed
fix RSI
1 parent a7a0c43 commit 07fd86d

File tree

1 file changed

+2
-2
lines changed
  • pub/bfx/src/Bfx/Indicator

1 file changed

+2
-2
lines changed

pub/bfx/src/Bfx/Indicator/Rsi.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ mkRsiConduit mkCandle (RsiPeriod natPer) =
8282
case mcandle of
8383
Nothing -> pure $ Right ()
8484
Just (c, loss, gain) -> do
85-
let nextAvgLoss = prevAvgLoss * (ratPer - 1) + loss / ratPer
86-
let nextAvgGain = prevAvgGain * (ratPer - 1) + gain / ratPer
85+
let nextAvgLoss = (prevAvgLoss * (ratPer - 1) + loss) / ratPer
86+
let nextAvgGain = (prevAvgGain * (ratPer - 1) + gain) / ratPer
8787
let rs = nextAvgGain / nextAvgLoss
8888
let rsi = Rsi $ 100 - (100 / (1 + rs))
8989
C.yield (c, rsi)

0 commit comments

Comments
 (0)