Dukascopy
 
 
Wiki JStore Search Login

JFOREX-2464 Indicators errors & problems
 Post subject: JFOREX-2464 Indicators errors & problems Post rating: 0   New post Posted: Fri 26 Nov, 2010, 08:22 

User rating: 0
Joined: Thu 19 Aug, 2010, 13:53
Posts: 62
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:
Image

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


 
 Post subject: Re: JFOREX-2464 Indicators errors & problems Post rating: 0   New post Posted: Wed 01 Dec, 2010, 09:05 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Marubozu and MFI are both Ta-lib indicators. You can find their source code here: https://www.ta-lib.org/index.html
As for MARUBOZU_BULL, MARUBOZU_BEAR you might want to define configurable parameters with default values in your strategy and then compare indicator results with the values of these parameters.


 
 Post subject: Re: JFOREX-2464 Indicators errors & problems Post rating: 0   New post Posted: Sun 12 Dec, 2010, 07:52 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Hi darlu72,

I agree with you. Checking for constant values is not quite a good way.
In cases where you only can have 3 distinct values like BULL, BEAR, NO_VALUE you can safely check for BULL >0, BEAR <0.
If you want to normalize the values to +1/-1 then you also could simply test against aArr[0]/Math.abs(aArr[0]).
It's both workarounds, but very safe ones.

Best, RR.


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com