Repository: cinar/indicatorts (ts)

Issue:
MoneyFlowIndex values well above 100
High | Low | Close | Vol | MFI
-- | -- | -- | -- | --
2390.9 | 2373.15 | 2373.39 | 1621 | 100
2386.3 | 2370 | 2382.47 | 1387 | 53.884998
2395.33 | 2380.77 | 2394.4 | 1444 | 68.888204
2399 | 2384.28 | 2387.51 | 1298 | 53.300054
2402.46 | 2387.46 | 2395.64 | 1629 | 63.645476
2401.15 | 2385.02 | 2389.47 | 1598 | 52.296425
2421.98 | 2383.18 | 2410.24 | 2311 | 62.119198
2430.31 | 2408.39 | 2425.37 | 2934 | 70.011701
2426.33 | 2410.59 | 2422.33 | 2128 | 60.826077
2434.93 | 2420.89 | 2430.29 | 1823 | 54.659774
2470.83 | 2428.92 | 2465.76 | 5078 | 64.728457
2483.36 | 2456.77 | 2466.27 | 6693 | 72.749002
2467.19 | 2437.65 | 2440.07 | 3960 | 64.185176
2450.72 | 2440.87 | 2445.85 | 1927 | 60.710993

Already fixed in [Indicator Go](https://github.com/cinar/indicator), can be implemented from [code change](https://github.com/cinar/indicator/pull/42).

Pull request description:
MoneyFlowIndex values well above 100
Fixed #31


Patch:
diff --git a/src/indicator/volume/moneyFlowIndex.ts b/src/indicator/volume/moneyFlowIndex.ts
index f9400b9..1afed4f 100644
--- a/src/indicator/volume/moneyFlowIndex.ts
+++ b/src/indicator/volume/moneyFlowIndex.ts
@@ -46,7 +46,7 @@ export function moneyFlowIndex(
 
   const moneyRatio = divide(
     msum(period, positiveMoneyFlow),
-    msum(period, negativeMoneyFlow)
+    msum(period, multiplyBy(-1, negativeMoneyFlow))
   );
 
   const moneyFlowIndex = addBy(


Test patch:
diff --git a/src/indicator/volume/moneyFlowIndex.test.ts b/src/indicator/volume/moneyFlowIndex.test.ts
index e1b7d93..b2ab598 100644
--- a/src/indicator/volume/moneyFlowIndex.test.ts
+++ b/src/indicator/volume/moneyFlowIndex.test.ts
@@ -10,7 +10,7 @@ describe('Money Flow Index (MFI)', () => {
     const lows = [6, 7, 9, 12, 10];
     const closings = [9, 11, 7, 10, 8];
     const volumes = [100, 110, 80, 120, 90];
-    const expected = [100, 100, 406.85, 207.69, 266.67];
+    const expected = [100, 100, 57.01, 65.85, 61.54];
     const period = 2;
 
     const actual = moneyFlowIndex(period, highs, lows, closings, volumes);