Menu

#76 MFI logic bug when no price movement

closed-fixed
Bug (61)
7
2008-01-07
2007-05-29
No

cut&Paste from the forum:

Hi,

Firstly, I'd like to say what a great library this is. It is saving me hours and hours of work and is very easy to use Very Happy

I implemented a trading system using your MFI but I found a small error logic in it that is creating incorrect signals on very short time frames like 5 minute periods. I have however corrected it and now it works just fine.

problem code:

Code:

if( tempValue2 < 0 )
{
CIRCBUF_REF(mflow[mflow_Idx])negative = tempValue1;
negSumMF += tempValue1;
CIRCBUF_REF(mflow[mflow_Idx])positive = 0.0;
}
else
{
CIRCBUF_REF(mflow[mflow_Idx])positive = tempValue1;
posSumMF += tempValue1;
CIRCBUF_REF(mflow[mflow_Idx])negative = 0.0;
}

And the corrected code:

Code:

if( tempValue2 < 0 )
{
CIRCBUF_REF(mflow[mflow_Idx])negative = tempValue1;
negSumMF += tempValue1;
CIRCBUF_REF(mflow[mflow_Idx])positive = 0.0;
}
if( tempValue2 > 0 )
{
CIRCBUF_REF(mflow[mflow_Idx])positive = tempValue1;
posSumMF += tempValue1;
CIRCBUF_REF(mflow[mflow_Idx])negative = 0.0;
}

if( tempValue2 == 0 )
{
CIRCBUF_REF(mflow[mflow_Idx])positive = 0.0;
CIRCBUF_REF(mflow[mflow_Idx])negative = 0.0;
}

What was happening is it was not accounting for a no-change value which happens quite often on short time frames like 5 minute and 10 minute charts.

Kind regards,
Bob

Discussion

  • Mario Fortier

    Mario Fortier - 2007-05-29

    Logged In: YES
    user_id=1123
    Originator: YES

    Thanks Bob for reporting this.

    Fix will be part of release 0.4

    Thanks,

    \Mario

     
  • Mario Fortier

    Mario Fortier - 2007-05-29
    • summary: MFI logic when no price movement --> MFI logic bug when no price movement
     
  • Mario Fortier

    Mario Fortier - 2007-06-10

    Logged In: YES
    user_id=1123
    Originator: YES

    Fix is now in SVN.

    \Mario

     
  • Mario Fortier

    Mario Fortier - 2008-01-07
    • status: open --> closed-fixed
     

Log in to post a comment.