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
Logged In: YES
user_id=1123
Originator: YES
Thanks Bob for reporting this.
Fix will be part of release 0.4
Thanks,
\Mario
Logged In: YES
user_id=1123
Originator: YES
Fix is now in SVN.
\Mario