Skip to content

Commit

Permalink
add moment value for MFI
Browse files Browse the repository at this point in the history
  • Loading branch information
BusinessDuck committed Sep 19, 2024
1 parent 7392b5e commit f7189b3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/mfi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ export class MFI {
}

momentValue(high: number, low: number, close: number, volume: number) {
return 0;
const typicalPrice = (high + low + close) / 3;
const moneyFlow = typicalPrice * volume;

if (!this.pevTypicalPrice) {
return;
}

const positiveMoneyFlow = typicalPrice > this.pevTypicalPrice ? moneyFlow : 0;
const negativeMoneyFlow = typicalPrice < this.pevTypicalPrice ? moneyFlow : 0;

if (!this.posCircular.filled) {
return;
}

const posRedunant = this.posCircular.peek();
const negRedunant = this.negCircular.peek();
const negativeMoneyFlowSum = this.negativeMoneyFlowSum + negativeMoneyFlow - negRedunant;
const positiveMoneyFlowSum = this.positiveMoneyFlowSum + positiveMoneyFlow - posRedunant;
const moneyFlowRatio = positiveMoneyFlowSum / negativeMoneyFlowSum;

return 100 - 100 / (1 + moneyFlowRatio);
}
}

0 comments on commit f7189b3

Please sign in to comment.