SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus -- Ignore unavailable to you. Want to Upgrade?


To: Bob Jagow who wrote (7284)10/20/1998 4:39:00 PM
From: Craig DeHaan  Read Replies (3) | Respond to of 11149
 
Bob, (I'm in the dawn's early light)

What would you suggest as:
1) a more elegant way to avoid divide by zero errors caused by NegMF summation in MRatio other than my rig-o-rama?
2) insight for setting a two day differential output of MFI values for day0 and day-1, or do I just back off the for...do loop a notch and declare a pre-pavp variable?
3) an alternative to using an 'if - then - else' setup in NegMF and PosMF summation loop? I don't like it for its 2-way inflexibility and I'll bet there's another way.

Economy is the watch word here and you're our resident maestro.

Thanks for anything.
Craig

//--MoneyFlow Index--

input = "250vol.lst";
output = "mfixx.lst";

issuetype common;
Daystoload = 50; //needed ?
DaysRequired = 50; //needed ?

integer i, S;
float avp, pavp, PosMF, NegMF, MRatio, MFI;
S:= 14; // MFI set periods
i:=0;
PosMF:=0;
NegMF:=0;
MRatio:=0;
MFI:=0;

for i = 1 - S to 0 do
avp:=range(i)/2+Low(i);
pavp:=range(i-1)/2+Low(i-1);
if avp > pavp then
PosMF:= PosMF + vol(i)*avp;
else
if avp < pavp then
NegMF:= NegMF + vol(i)*avp;
endif;endif;

next i;

if NegMF=0 then // <<< this seems a bogus fudge
NegMF:=1; // <<<
endif; // <<<
MRatio:=PosMF/NegMF;
MFI:=100-(100/(1+MRatio));

println symbol,",",close(0):8:2,",",MFI:8:4; //PosMF:8:4,",",NegMF:8:4;