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 Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
shawnpm123
Posted : Wednesday, July 13, 2005 12:43:04 AM
Registered User
Joined: 7/12/2005
Posts: 5
I just downloaded software and was looking for an indicator, MFI. Did not see it, so thought that I would try and write it. Equation is as folows:
MFI = 100/(1+MR)
MR = positive MF / negative MF
MF = TP*Volume
TP = (H+L+C)/3
where positive MF is defined as TP(n ) > TP(n-1)

I was looking for a conditional operator like IF but did not find.
Is it possible to write the following?
positiveMF=0+if(TP>TP1,TP*V,0)+if(TP1>TP2,TP1*V1,0)+...

Also, is there a way to define each of the variable within the function and then combine?
TP=(H+L+C)/3;
positiveMF=0+if(TP>TP1,TP*V,0)+if(TP1>TP2,TP1*V1,0)+...;
negativeMF=0+if(TPMFI=100/(1+(positiveMF/negativeMF))

I'm sure this has been asked before so I apologize if you have to repeat yourself, I just could not find in the help or postings (I haven't received the doc's yet) and really wanted to get going as soon as possible looking at and evaluating the software.

Thanks - Shawn
bustermu
Posted : Wednesday, July 13, 2005 8:18:27 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Please see:

if then else syntax

I have long been looking for an example of something "useful" that could be calculated on a Symbol's data sequence by an addition to the PCF Language that can not now be calculated. Do you know of such an example?

Thanks,
Jim Murphy
Bruce_L
Posted : Wednesday, July 13, 2005 9:12:47 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
shawnpm123,
Here's one way to write a Simple 10-Period Money Flow Index. It is fairly straightforward to modify the formula to work for any period by adding or removing terms:

100/(1+((H+L+C>H1+L1+C1)*(H+L+C)*V + (H1+L1+C1>H2+L2+C2)*(H1+L1+C1)*V1 +(H2+L2+C2>H3+L3+C3)*(H2+L2+C2)*V2 + (H3+L3+C3>H4+L4+C4)*(H3+L3+C3)*V3 +(H4+L4+C4>H5+L5+C5)*(H4+L4+C4)*V4 + (H5+L5+C5>H6+L6+C6)*(H5+L5+C5)*V5 +(H6+L6+C6>H7+L7+C7)*(H6+L6+C6)*V6 + (H7+L7+C7>H8+L8+C8)*(H7+L7+C7)*V7 +(H8+L8+C8>H9+L9+C9)*(H8+L8+C8)*V8 +(H9+L9+C9>H10+L10+C10)*(H9+L9+C9)*V9) /((H+L+C<H1+L1+C1)*(H+L+C)*V + (H1+L1+C1<H2+L2+C2)*(H1+L1+C1)*V1 +(H2+L2+C2<H3+L3+C3)*(H2+L2+C2)*V2 + (H3+L3+C3<H4+L4+C4)*(H3+L3+C3)*V3 +(H4+L4+C4<H5+L5+C5)*(H4+L4+C4)*V4 + (H5+L5+C5<H6+L6+C6)*(H5+L5+C5)*V5 +(H6+L6+C6<H7+L7+C7)*(H6+L6+C6)*V6 + (H7+L7+C7<H8+L8+C8)*(H7+L7+C7)*V7 +(H8+L8+C8<H9+L9+C9)*(H8+L8+C8)*V8 + (H9+L9+C9<H10+L10+C10)*(H9+L9+C9)*V9-.00001))

Formulas in TeleChart do not currently allow for the use of variables. The topic bustermu pointed out shows several ways to implement conditionals in TeleChart formulas.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
shawnpm123
Posted : Wednesday, July 13, 2005 10:07:17 AM
Registered User
Joined: 7/12/2005
Posts: 5
Bruce,
Thanks a bunch for the code. I believe all I have to remember is:
1) string everything together
2) all conditional statements return -1 for true and 0 for false.

Just too clarify your code, given the following:
H=3,L=1,C=2,V=100
H1=3,L1=1,C1=1,V=100
Your code:(H+L+C>H1+L1+C1)*(H+L+C)*V
Would the result be 600 or -600? Which in this case should not matter since both the numerator and denominator will be either positive or negative.
Thanks again - Shawn
Bruce_L
Posted : Wednesday, July 13, 2005 10:19:27 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The results would be -600.

(H+L+C>H1+L1+C1)*(H+L+C)*V = ( -1 )*( 6 )*( 100 )

If this was not part of a ratio, you would need to divide it by -3 to get 1-Period Positive MF.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Tanstaafl
Posted : Thursday, July 14, 2005 1:10:07 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Jim M:

An excellent example of a USEFUL indicator that CANNOT be written in a PCF (from a pragmatic as opposed to ivory tower point of view) is the true Wilder's ADX.

I've posted several articles on this elsewhere. If you create a <1%error verson of the DX (useless, since no smoothing), it is a huge formula that takes quite a while to recalc.

If you are a glutton for punishment re spacebar time, you can create a CI from the DX and then apply TC's 27-pd exponential smoothing to get the ADX. But geesh it's unusable!

A PCF with <1% error that had the true ADX in it would be in the hundreds of thousands of characters. If TC did not balk at parsing it (*I'm* not gonna test THAT one!), then the recalc would probably be in excess of 24 hours.

So, there's your example. I hope that will put to rest the repeated assertions that PCF's can do anything - part of the PCF is the viability of its recalc and ability to be USED.

There are several ways that W could modify the PCF language to solve this kind of problem .. the most useful and universal would probably be simply to permit complex expressions inside the Avg() and XAvg() and Max() and Min() functions (as currently Abs and Sqr can do).

Jim Dean

Tanstaafl
Posted : Thursday, July 14, 2005 1:12:47 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Oh, yes... you might want to know why a PCF would be needed for the ADX. Simplest answer: to apply the rules that Wilder wrote up in his book about how to USE it. Lots of other examples: the ROC of the ADX (for slope), whether the ADX was at a given value several days ago, etc.

bustermu
Posted : Friday, July 15, 2005 4:52:22 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Jim D.,

Thanks for your response.

My post was in response to a post, which has since been removed, that contained the statement:

"Because TeleChart's PCF language does not include the conditional IF statement, I don't believe it is possible to write the formula for the Money Flow Index."

We have seen that it is not only possible but practical to write a PCF for Money Flow Index.

I was just looking for an example of something "useful" that could be calculated on a Symbol's data sequence by an addition to the PCF Language that can not now be calculated.

Your statement:

"I hope that will put to rest the repeated assertions that PCF's can do anything..."

is interesting. I have not seen such assertions, but it may lead us to someone who can prove such a thing in some restricted context. That would be interesting.

The practicality of the PCF Language would be immensely improved simply by adding variables, conditionals, and loops. The PCF's for Directional Movement quantities would be a breeze.

Your example of a computation impractical with the present PCF Language seems much more complex than necessary. Please consider the calculation of:

MAX((C-C1),P)

the maximum daily price change over P days. If P = 2, it is trivial. If P = 10, the PCF is getting quite long. If P = 100, I would think most would consider it completely impractical. If we just had variables, conditionals, and loops, the PCF would be trivial.

Thanks,
Jim Murphy
bustermu
Posted : Sunday, September 25, 2005 5:05:52 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Please note that MFI is usually defined as:

MFI = 100*(1-1/(1+MR))

which is equivalent to:

MFI = 100*positiveMF/(positiveMF+negativeMF)

Not as:

MFI = 100/(1+MR)

which is equivalent to:

MFI = 100*negativeMF/(positiveMF+negativeMF)

The formula

MFI = 100/(1+MR)

would be equivalent to the usual if the definition

MR = positiveMF/negativeMF

were changed to

MR = negativeMF/positiveMF

Thanks,
Jim Murphy
psrkn
Posted : Friday, October 14, 2005 6:39:19 PM
Registered User
Joined: 12/1/2004
Posts: 56
Hi,

I modified Bruce's Code with Jim's suggestion, and came up with MFI for 10 periods:
100*(1-1/(1+((H+L+C>H1+L1+C1)*(H+L+C)*V +(H1+L1+C1>H2+L2+C2)*(H1+L1+C1)*V1 +(H2+L2+C2>H3+L3+C3)*(H2+L2+C2)*V2 +(H3+L3+C3>H4+L4+C4)*(H3+L3+C3)*V3 +(H4+L4+C4>H5+L5+C5)*(H4+L4+C4)*V4 +(H5+L5+C5>H6+L6+C6)*(H5+L5+C5)*V5 +(H6+L6+C6>H7+L7+C7)*(H6+L6+C6)*V6 +(H7+L7+C7>H8+L8+C8)*(H7+L7+C7)*V7 +(H8+L8+C8>H9+L9+C9)*(H8+L8+C8)*V8 +(H9+L9+C9>H10+L10+C10)*(H9+L9+C9)*V9)/((H+L+C<H1+L1+C1)*(H+L+C)*V +(H1+L1+C1<H2+L2+C2)*(H1+L1+C1)*V1 +(H2+L2+C2<H3+L3+C3)*(H2+L2+C2)*V2 +(H3+L3+C3<H4+L4+C4)*(H3+L3+C3)*V3 +(H4+L4+C4<H5+L5+C5)*(H4+L4+C4)*V4 +(H5+L5+C5<H6+L6+C6)*(H5+L5+C5)*V5 +(H6+L6+C6<H7+L7+C7)*(H6+L6+C6)*V6 +(H7+L7+C7<H8+L8+C8)*(H7+L7+C7)*V7 +(H8+L8+C8<H9+L9+C9)*(H8+L8+C8)*V8 +(H9+L9+C9<H10+L10+C10)*(H9+L9+C9)*V9-.00001))))
The graph output from custom indicator with the above formula does not look right. Could you please let me know what I did wrong?
Thank you in advance for your help.
bustermu
Posted : Saturday, October 15, 2005 7:39:46 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
psrkn,

You have an extra ")" at the end which TC2005 just ignores. Otherwise, the PCF is apears to me to be just fine.

Your PCF,

PCF1:
100*(1-1/(1+((H+L+C>H1+L1+C1)*(H+L+C)*V+(H1+L1+C1>H2+L2+C2)*(H1+L1+C1)*V1 + (H2+L2+C2>H3+L3+C3)*(H2+L2+C2)*V2 +(H3+L3+C3>H4+L4+C4)*(H3+L3+C3)*V3 + (H4+L4+C4>H5+L5+C5)*(H4+L4+C4)*V4 +(H5+L5+C5>H6+L6+C6)*(H5+L5+C5)*V5 + (H6+L6+C6>H7+L7+C7)*(H6+L6+C6)*V6 +(H7+L7+C7>H8+L8+C8)*(H7+L7+C7)*V7 + (H8+L8+C8>H9+L9+C9)*(H8+L8+C8)*V8 + (H9+L9+C9>H10+L10+C10)*(H9+L9+C9)*V9)/((H+L+C<H1+L1+C1)*(H+L+C)*V + (H1+L1+C1<H2+L2+C2)*(H1+L1+C1)*V1 +(H2+L2+C2<H3+L3+C3)*(H2+L2+C2)*V2 + (H3+L3+C3<H4+L4+C4)*(H3+L3+C3)*V3 +(H4+L4+C4<H5+L5+C5)*(H4+L4+C4)*V4 + (H5+L5+C5<H6+L6+C6)*(H5+L5+C5)*V5 +(H6+L6+C6<H7+L7+C7)*(H6+L6+C6)*V6 + (H7+L7+C7<H8+L8+C8)*(H7+L7+C7)*V7 +(H8+L8+C8<H9+L9+C9)*(H8+L8+C8)*V8 + (H9+L9+C9<H10+L10+C10)*(H9+L9+C9)*V9-.00001)))

was checked against

PCF2:
(-100)*((H+L+C>H1+L1+C1)*(H+L+C)*V +(H1+L1+C1>H2+L2+C2)*(H1+L1+C1)*V1 + (H2+L2+C2>H3+L3+C3)*(H2+L2+C2)*V2 +(H3+L3+C3>H4+L4+C4)*(H3+L3+C3)*V3 + (H4+L4+C4>H5+L5+C5)*(H4+L4+C4)*V4 +(H5+L5+C5>H6+L6+C6)*(H5+L5+C5)*V5 + (H6+L6+C6>H7+L7+C7)*(H6+L6+C6)*V6 +(H7+L7+C7>H8+L8+C8)*(H7+L7+C7)*V7 + (H8+L8+C8>H9+L9+C9)*(H8+L8+C8)*V8 +(H9+L9+C9>H10+L10+C10)*(H9+L9+C9)*V9)/((H+L+C)*V + (H1+L1+C1)*V1 +(H2+L2+C2)*V2 +(H3+L3+C3)*V3 +(H4+L4+C4)*V4 +(H5+L5+C5)*V5 +(H6+L6+C6)*V6 + (H7+L7+C7)*V7 +(H8+L8+C8)*V8 +(H9+L9+C9)*V9)

They agreed where they should.

The PCF2 was, in turn, checked against

PCF3:
(-100)* ((C0>C1)*C0*V0+(C1>C2) *C1*V1+(C2>C3)*C2*V2+(C3>C4) *C3*V3+(C4>C5)*C4*V4+(C5>C6) *C5*V5+(C6>C7)*C6*V6+(C7>C8) *C7*V7+(C8>C9)*C8*V8+(C9>C10) *C9*V9)/ (C0*V0+C1*V1+C2*V2+C3*V3+C4*V4+C5*V5+C6*V6+C7*V7+C8*V8+C9*V9)

They were in close agreement where the should be.

Since I wrote PCF3 from scratch, it is unlikely that anything is wrong with your PCF other than the extra ")".

Thanks,
Jim Murphy
psrkn
Posted : Saturday, October 15, 2005 12:23:23 PM
Registered User
Joined: 12/1/2004
Posts: 56
Jim...Thanks again
You are very helpful.
Deion
Posted : Sunday, April 23, 2006 8:08:49 PM
Registered User
Joined: 2/19/2006
Posts: 89
QUOTE (bustermu)
psrkn,

You have an extra &quot;)&quot; at the end which TC2005 just ignores. Otherwise, the PCF is apears to me to be just fine.

Your PCF,

PCF1:
100*(1-1/(1+((H+L+C&gt;H1+L1+C1)*(H+L+C)*V+(H1+L1+C1&gt;H2+L2+C2)*(H1+L1+C1)*V1 + (H2+L2+C2&gt;H3+L3+C3)*(H2+L2+C2)*V2 +(H3+L3+C3&gt;H4+L4+C4)*(H3+L3+C3)*V3 + (H4+L4+C4&gt;H5+L5+C5)*(H4+L4+C4)*V4 +(H5+L5+C5&gt;H6+L6+C6)*(H5+L5+C5)*V5 + (H6+L6+C6&gt;H7+L7+C7)*(H6+L6+C6)*V6 +(H7+L7+C7&gt;H8+L8+C8)*(H7+L7+C7)*V7 + (H8+L8+C8&gt;H9+L9+C9)*(H8+L8+C8)*V8 + (H9+L9+C9&gt;H10+L10+C10)*(H9+L9+C9)*V9)/((H+L+C&lt;H1+L1+C1)*(H+L+C)*V + (H1+L1+C1&lt;H2+L2+C2)*(H1+L1+C1)*V1 +(H2+L2+C2&lt;H3+L3+C3)*(H2+L2+C2)*V2 + (H3+L3+C3&lt;H4+L4+C4)*(H3+L3+C3)*V3 +(H4+L4+C4&lt;H5+L5+C5)*(H4+L4+C4)*V4 + (H5+L5+C5&lt;H6+L6+C6)*(H5+L5+C5)*V5 +(H6+L6+C6&lt;H7+L7+C7)*(H6+L6+C6)*V6 + (H7+L7+C7&lt;H8+L8+C8)*(H7+L7+C7)*V7 +(H8+L8+C8&lt;H9+L9+C9)*(H8+L8+C8)*V8 + (H9+L9+C9&lt;H10+L10+C10)*(H9+L9+C9)*V9-.00001)))

was checked against

PCF2:
(-100)*((H+L+C&gt;H1+L1+C1)*(H+L+C)*V +(H1+L1+C1&gt;H2+L2+C2)*(H1+L1+C1)*V1 + (H2+L2+C2&gt;H3+L3+C3)*(H2+L2+C2)*V2 +(H3+L3+C3&gt;H4+L4+C4)*(H3+L3+C3)*V3 + (H4+L4+C4&gt;H5+L5+C5)*(H4+L4+C4)*V4 +(H5+L5+C5&gt;H6+L6+C6)*(H5+L5+C5)*V5 + (H6+L6+C6&gt;H7+L7+C7)*(H6+L6+C6)*V6 +(H7+L7+C7&gt;H8+L8+C8)*(H7+L7+C7)*V7 + (H8+L8+C8&gt;H9+L9+C9)*(H8+L8+C8)*V8 +(H9+L9+C9&gt;H10+L10+C10)*(H9+L9+C9)*V9)/((H+L+C)*V + (H1+L1+C1)*V1 +(H2+L2+C2)*V2 +(H3+L3+C3)*V3 +(H4+L4+C4)*V4 +(H5+L5+C5)*V5 +(H6+L6+C6)*V6 + (H7+L7+C7)*V7 +(H8+L8+C8)*V8 +(H9+L9+C9)*V9)

They agreed where they should.

The PCF2 was, in turn, checked against

PCF3:
(-100)* ((C0&gt;C1)*C0*V0+(C1&gt;C2) *C1*V1+(C2&gt;C3)*C2*V2+(C3&gt;C4) *C3*V3+(C4&gt;C5)*C4*V4+(C5&gt;C6) *C5*V5+(C6&gt;C7)*C6*V6+(C7&gt;C8) *C7*V7+(C8&gt;C9)*C8*V8+(C9&gt;C10) *C9*V9)/ (C0*V0+C1*V1+C2*V2+C3*V3+C4*V4+C5*V5+C6*V6+C7*V7+C8*V8+C9*V9)

They were in close agreement where the should be.

Since I wrote PCF3 from scratch, it is unlikely that anything is wrong with your PCF other than the extra &quot;)&quot;.

Thanks,
Jim Murphy


Is Money flow and Chaikin money flow the same? I have seen posts for both
Craig_S
Posted : Monday, April 24, 2006 8:04:02 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Usually when you see MF mentioned it is CMF. MFI is different than CMF.

- Craig
Here to Help!
gsn
Posted : Sunday, July 2, 2006 2:34:54 PM
Registered User
Joined: 11/13/2004
Posts: 121
OK, I admit to being confused by the various different ways MFI is calculated.

On p.l 148 of Bollinger on Bollinger Bands, the formula for MFI is listed as:

MFI = 100-100/(1+positive price*volume sum/negative price*volume sum)

Bollnger writes:

"MFI compares volume on up days to volume on down days in a manner similar to RSI. The typical price price (high + low + close)/3 is used to determine up from down. You may specify the number of days used in the calculation; 10 is the default."

Using the stock symbol CKCM for 6/30/2006, Bollinger's website gives a 10-day MFI reading of 52.15

-- Bruce's formula above gives a reading of 46.35
-- PCF1 in bustermu's message: 53.65
-- PCF2 in bustermu's message: 53.65
-- PCF3 in bustermu's message: 53.79
-- An MFI formula Bustermu created for MFI of Period 10 with Median Price, (H+L)/2, replacing Typical Price, (H+L+C)/3 in http://www.worden.com/training/default.aspx?g=posts&t=7721 gives a reading of 62.32

How would one go about writing a PCF for a 10-day MFI in the manner used by John Bollinger that would give the reading he gets using his definition? Any help much appreciated.
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.