I have two problems with indicators now:
1. MFI negative values.
I test the strategy using Tick on open, FIVE_MINUTES/M5. In strategy I use in indicators Periods larger than M5, mostly M15 and
H1. For the Money Flow Index I get negative values returned. It is supposed MFI to have range 0 .. 100.
Below is what strategy outputs when it detects incorrect values for indicators. MfiL is MFI on 8 periods on a M15 time frame,
ticking on open M5. Also, on the chart you can see the indicator plots a -0.0001 value; although it is 'near zero', it should not be
negative but positive >= 0. I noted this happen when price goes in extreme oversold/bought or when there are gaps at the begining
of the week. And more, you see MfiL is quite negative, ~ -4.
06:46:11 3 Mar 2010 14:40:00 GMT: Div. LP: StochL: 16.50153466398712, MfiL: -4.476131444415936E-14, ForceL:
-1.5170924999997417
Here chart capture example:
Here how I get MFI result:
public double mfi(Period aTimeFrame, int aTimePeriod, int aShift) throws JFException
{
IBar aBar = getIBar(aTimeFrame,aShift);
double aArr[] =
iStrategy.iIndicators.mfi(iInstr,aTimeFrame,OfferSide.BID,aTimePeriod,Filter.ALL_FLATS,1,aBar.getTime(),0);
if(aArr == null || aArr.length <= 0)
throw new JFException("MFI indicator not ready.");
return aArr[0];
}
2. Indicator patterns with hardcoded values ?
I noted the pattern recognition indicators returns some hardcoded values:
Eg. for Marubozu indicator, it returns -100 if bar is bear and + 100 if bar is bull, and 0 if bar is not marubozu.
This is somehow ok, but I dislike checking results using hardcoded values.
Is anywhere defined somekind of Enums/Defines ? eg,
Enum(MARUBOZU_BULL,MARUBOZU_BEAR, etc ..}
Currently I check using these hard coded values which for any (professional?) programmer this is not quite accepted.
If in future the core of JForex changes the return of such indicators, instead -100, return eg. +300 then the strategy
based on patterns goes blown up. Below is how I currently check pattern indicators, which I dont like, of course.
// Spinning Top
aArr =
iStrategy.iIndicators.cdlSpinningTop(iInstr,aTimeFrame,OfferSide.BID,Filter.ALL_FLATS,1,aBar.getTime(),0);
if(aArr != null && aArr.length > 0 && Math.abs(aArr[0]) == 100) // 100 bull, -100 bear spin
aBar.addCandlePattern(CandlePattern.SPINNING_TOP);
// Marubozu
aArr =
iStrategy.iIndicators.cdlMarubozu(iInstr,aTimeFrame,OfferSide.BID,Filter.ALL_FLATS,1,aBar.getTime(),0);
if(aArr != null && aArr.length > 0 && Math.abs(aArr[0]) == 100) // 100 bull marubozu, -100 bear marubozu
aBar.addCandlePattern(CandlePattern.MARUBOZU);