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; |