Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Money Flow Index (MFI) as custom indicator and as PCF Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
krck
Posted : Thursday, March 16, 2006 6:21:51 PM
Registered User
Joined: 2/27/2006
Posts: 16
I would like to plot Money Flow Index (MFI) as a custom indicator and/or PCF.
Say over a 5 day period.

The formula is calculated as follows:

Typical price for the day is (H+L+C)/3.
Money for the day = V*(H+L+C)/3.

If ( H+L+C ) >= (H1+L1+C1) then the volume V is considered positive volume.
If ( H+L+C ) < (H1+L1+C1) then the volume V is considered negative volume.

( positive money/negative money ) in a 5 day period
pnRatio = sum of positive money / sum of negative money

Money flow index = 100 - 100 / ( 1 + pnRatio ).

If the denominator of pnRatio is 0 (divide by zero) MFI is 100.

---------
I fave so far tried deducing the positive and negative volume by solving
linear equations.

This is what I did so far:
X = (H+L+C)*V +...+ (H4+L4+C4)*V
Y = ABS((H+L+C)*V) +...+ ABS((H4+L4+C4)*V)

Then positive money sum total is
positiveMoney = 0.5*(X+Y)
negativeMoney = 0.5*(X-Y)

pnRatio = (X+Y)/(X-Y)

MFI = 100 - 100 / ( 1 + pnRatio )

When I get the formula out of Maple and put it in a PCF
I always get divide by zero error.

----------

Please can you give me something that will work even if with a slight approximation.
As I am not a mathematician please can you advise me of ways to get around
divide by zeros in PCF's even with appropriate approximations.

Ideally, Worden language should include simple script capability.


Thanks.
Craig_S
Posted : Thursday, March 16, 2006 6:56:58 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
I just did a search for MONEY FLOW INDEX and found:

Money Flow Index

You too can search these forums for anything. Watch this short video on how to get the most from these forums:
Learn how to use the forums: post a new topic, reply, Search existing topics


- Craig
Here to Help!
sttstt
Posted : Thursday, March 16, 2006 8:49:47 PM
Registered User
Joined: 10/7/2004
Posts: 39
A better way to calculate MFI is to rearrange the formula, the textbook formula is
100*(1-1/(PMF/NMF)). In many cases it will get divide by 0 error because the time period you specify could be consecutively positive, therefore, there is no NMF. NMF=0 then cause divide by 0 error.

what you can do is to reduce the formula to
100*PMF/(PMF+NMF) = 100*PMF/total MF
where total MF is summation of all price*volume (without the conditional statement)
This way you won't get the divide by 0 error.

Good luck.

QUOTE (krck)
I would like to plot Money Flow Index (MFI) as a custom indicator and/or PCF.
Say over a 5 day period.

The formula is calculated as follows:

Typical price for the day is (H+L+C)/3.
Money for the day = V*(H+L+C)/3.

If ( H+L+C ) &gt;= (H1+L1+C1) then the volume V is considered positive volume.
If ( H+L+C ) &lt; (H1+L1+C1) then the volume V is considered negative volume.

( positive money/negative money ) in a 5 day period
pnRatio = sum of positive money / sum of negative money

Money flow index = 100 - 100 / ( 1 + pnRatio ).

If the denominator of pnRatio is 0 (divide by zero) MFI is 100.

---------
I fave so far tried deducing the positive and negative volume by solving
linear equations.

This is what I did so far:
X = (H+L+C)*V +...+ (H4+L4+C4)*V
Y = ABS((H+L+C)*V) +...+ ABS((H4+L4+C4)*V)

Then positive money sum total is
positiveMoney = 0.5*(X+Y)
negativeMoney = 0.5*(X-Y)

pnRatio = (X+Y)/(X-Y)

MFI = 100 - 100 / ( 1 + pnRatio )

When I get the formula out of Maple and put it in a PCF
I always get divide by zero error.

----------

Please can you give me something that will work even if with a slight approximation.
As I am not a mathematician please can you advise me of ways to get around
divide by zeros in PCF's even with appropriate approximations.

Ideally, Worden language should include simple script capability.


Thanks.
bustermu
Posted : Thursday, March 16, 2006 9:12:33 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
The form:

100*PMF/(PMF+NMF) = 100*PMF/total MF

does not always solve the divide by zero problem.

If you change the form to:

100*PMF/(totalMF+0.000001)

or to:

100*(1-1/(PMF/(NMF+0.000001)))

it will solve the divide by zero problem. This works because the smallest positive number NMF can be is 0.01.

Thanks,
Jim Murphy
krck
Posted : Friday, March 17, 2006 6:28:24 PM
Registered User
Joined: 2/27/2006
Posts: 16
Thank you all for your help.

I have been successful in creating the 5 day indicator.
There have been no divide by zero episodes even without putting 0.00001.

After having reviewed the links and implemented your suggestions I can say that I am very much relieved that SGN() function can be used in the expressions to test tautologies and implement logical conditions.

But had I not reviewed those posts I would have never guessed the
use for SGN. I think that SGN (signum) in math returns +1 for positive,
-1 for negative and 0 for undefined.

I was therefore automatically biased to think that it tested numbers
for positive or negative. The booleans did not come into mind.

Thanks once again.
bustermu
Posted : Saturday, March 18, 2006 6:38:39 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (krck)
I think that SGN (signum) in math returns +1 for positive,
-1 for negative and 0 for undefined.


The signum function on the real numbers is defined by:

SGN( x ) = +1, x > 0
SGN( x ) = 0, x = 0
SGN( x ) = -1, x < 0

The SGN( x ) is not 0 in mathematics when x is undefined, it remains equally undefined.

Thanks,
Jim Murphy
krck
Posted : Sunday, March 19, 2006 1:51:43 AM
Registered User
Joined: 2/27/2006
Posts: 16
True, my error.

Sgn(0) is undefined but can be either 0 or 1.
Other undefined values are undefined.

signum

or signum function, n. the real function, denoted sgn or sg, that assigns the sign of a nonzero number to that number; alternatively, sgn can be defined as +1 for positive x and -1 for negative x. The term is also used for the corresponding function that sends x to x / || x || for any nonzero x, in any normed space, and especially complex numbers. sgn(0) is generally undefined, but it can be assigned a complex number of absolute value 0 or 1.

krck
Posted : Sunday, March 19, 2006 1:57:11 AM
Registered User
Joined: 2/27/2006
Posts: 16
Heh, just pasted the definition, did not realize that '( x )' was an emoticon.
Sorry, I'll be sure to use preview next time.
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.