Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

pivot indicator
 Post subject: pivot indicator Post rating: 0   Post Posted: Mon 14 Nov, 2011, 22:41 

User rating: 0
Joined: Mon 14 Nov, 2011, 22:30
Posts: 3
Location: CZ
Hello,
I have problem with implementing pivot indicator.
I have tried following declaration from API documentation:

double[] pivot(Instrument instrument,
Period period,
OfferSide side,
int timePeriod,
boolean showHistoricalLevels,
int shift)
If I use exact parameters

double [] pivotDaily = indicators.pivot(instrument, Period.DAILY, OfferSide.BID, 7, true, 0);

I get this error after compilation :
The method pivot(Instrument, Period, OfferSide, int, int) in the type IIndicators is not applicable for the arguments (Instrument, Period, OfferSide, int, boolean, int)

so I correct the code to this (leave showHistoricalLevels parameter):

double [] pivotDaily = indicators.pivot(instrument, Period.DAILY, OfferSide.BID, 7, 0);

Compilation was succesfull but if I run the test I get error :
Strategy tester: java.lang.ArrayIndexOutOfBoundsException: 1 @ jforex.strategies.indicators.Pivot2.onStart(Pivot2.java:24)

Can you please help me?

If I use fibPivot it works, but pivot points seems to be different from FIBPIVOT which I directly attached to the chart.


 
 Post subject: Re: pivot indicator Post rating: 0   Post Posted: Wed 16 Nov, 2011, 08:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See if the following strategy works:
package jforex.strategies.indicators;

import java.text.DecimalFormat;

import com.dukascopy.api.*;

/**
 * The startegy prints out daily, weekly and monthly pivot levels
 *
 */
public class Pivot2 implements IStrategy {
   private IConsole console;
   private IIndicators indicators;

   private Instrument instrument = Instrument.EURUSD;
   
   private static String[] pivotLevelNames = { "P", "R1", "S1", "R2", "S2", "R3", "S3" };

   public void onStart(IContext context) throws JFException {
      this.console = context.getConsole();
      this.indicators = context.getIndicators();
      
      boolean showHistoricalLevels = true;
      double [] pivotDaily = indicators.pivot(instrument, Period.DAILY, OfferSide.BID, 7, showHistoricalLevels, 0);
      double [] pivotWeekly = indicators.pivot(instrument, Period.WEEKLY, OfferSide.BID, 8, showHistoricalLevels, 0);
      double [] pivotMonthly = indicators.pivot(instrument, Period.MONTHLY, OfferSide.BID, 9, showHistoricalLevels, 0);

      print("pivotMonthly " +arrayToString(pivotMonthly));
      print("pivotWeekly " +arrayToString(pivotWeekly));
      print("pivotDaily " +arrayToString(pivotDaily));      
      
   }

   private void print(Object message) {
      console.getOut().println(message);
   }
   
   public static String arrayToString(double [] arr){
      String str = "";
      for (int r=0; r<arr.length; r++) {
          str += " " + pivotLevelNames[r] + ": "+ (new DecimalFormat("0.000000")).format(arr[r]) + "; ";
      }
      return str;
   }
   
   public void onAccount(IAccount account) throws JFException {}
   public void onMessage(IMessage message) throws JFException {}
   public void onStop() throws JFException {}
   public void onTick(Instrument instrument, ITick tick) throws JFException {}

   public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
}


Attachments:
Pivot2.java [1.8 KiB]
Downloaded 352 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: pivot indicator Post rating: 0   Post Posted: Wed 16 Nov, 2011, 12:51 

User rating: 0
Joined: Mon 14 Nov, 2011, 22:30
Posts: 3
Location: CZ
Thanks for tip.

But I still get the same error message :

11:42:42 The method pivot(Instrument, Period, OfferSide, int, int) in the type IIndicators is not applicable for the arguments (Instrument, Period, OfferSide, int, boolean, int)

I'm using Live JForex platform 2.12.21 with API 2.6.33.

On demo account which is 2.13.32 with API 2.6.38 it works..

How can I get higher version on live platform?


 
 Post subject: Re: pivot indicator Post rating: 0   Post Posted: Wed 16 Nov, 2011, 14:15 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
kkti wrote:
How can I get higher version on live platform?
JForex LIVE client works with JForex API version 2.6.33 and DEMO with JForex API version 2.6.38. Follow JForex client release information here:
viewforum.php?f=71


 
 Post subject: Re: pivot indicator Post rating: 0   Post Posted: Wed 16 Nov, 2011, 15:23 

User rating: 0
Joined: Mon 14 Nov, 2011, 22:30
Posts: 3
Location: CZ
I also try run the strategy using local run option. But if I do it Demo application freezes.

I just wanted to know if pivot gives me right information about levels...


 
 Post subject: Re: pivot indicator Post rating: 0   Post Posted: Wed 16 Nov, 2011, 15:38 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Could you please check what you receive on java console?
viewtopic.php?f=81&t=39073


 

Jump to:  

  © 1998-2025 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