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

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: Craig DeHaan who wrote (7311)10/21/1998 11:45:00 AM
From: Bob Jagow  Read Replies (1) of 11149
 
Craig,
You've probably noticed this AM that the equation for MFI is
MFI:= 100 -100/(1+PosMF/NegMF) ; this is what reduces to
100 -100*NegMF/(NegMF+PosMF); :-(
Re your hesitance to switch to eMFI, I can send a snippet to
[slowly] do the SMA version if you must.
Go with typ rather than avg; don't know how they got that messed up.

Bob
The final code I sent runs into an old Q+ precompile bug -- it
thinks Denom must be zero. Can fix by dividing by Denom + 0.0001 but
I adamantly refused to do that. The fix shown below is just as dumb.
[Excise it when Gary posts the new build.]
-------------
//--MoneyFlow Index--
// change to EMA to enable stepping thru a back test
input = "250vol.lst";
output = "mfixx.lst";
issuetype common;
integer i, lenMFI, bar, first, last; //add backtest vars
float typPr, ptypPr, PosMF, NegMF, eMFI, peMFI, Denom;
lenMFI:= 14; // Length of MFI EMA Set this ******
first:= 0; last:= 0; // Set these neg for BT ******
Daystoload = 1 +3*lenMFI -first; // should settle EMA down enough
DaysRequired = 1 +3*lenMFI -first;
// Now calc starting MFI
PosMF:=0; NegMF:=0; Denom:= 0.0;
for i = first - 3*lenMFI to first -1 do // could reduce 3 to 1.5
typPr:= high(i)+low(i)+close(i);
ptypPr:= high(i-1)+low(i-1)+close(i-1);
if typPr < ptypPr then
NegMF:= NegMF + (typPr*vol(i)/3 -NegMF)*2/(lenMFI+1);
endif;
if typPr != ptypPr then
Denom:= Denom + (typPr*vol(i)/3 -Denom)*2/(lenMFI+1);
endif;
next i;
peMFI:= 0; if Denom > 0 then // to handle Q+ precompile bug
peMFI:= 100 -100*NegMF/Denom;
endif;
// Now into "Backtesting loop
for bar = first to last do // now
typPr:= high(bar)+low(bar)+close(bar);
ptypPr:= high(bar-1)+low(bar-1)+close(bar-1);
if typPr < ptypPr then
NegMF:= NegMF + (typPr*vol(bar)/3 -NegMF)*2/(lenMFI+1);
endif;
if typPr != ptypPr then
Denom:= Denom + (typPr*vol(bar)/3 -Denom)*2/(lenMFI+1);
endif;
eMFI:= 0; if Denom > 0 then // to handle Q+ precompile bug
eMFI:= 100 -100*NegMF/Denom;
endif;
if eMFI > peMFI then
println symbol,",",date(bar),",",close(Bar):8:2,",",
peMFI:8:4,",",eMFI:8:4;
endif;
peMFI:= eMFI; // for next bar
next bar;

Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext