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.

Can't get weekly Fibionacci pivots from a strategy
 Post subject: Can't get weekly Fibionacci pivots from a strategy Post rating: 0   New post Posted: Tue 23 Aug, 2011, 01:40 

User rating: 0
Joined: Tue 23 Aug, 2011, 01:10
Posts: 7
Location: United States,
I've tried various methods to obtain weekly Fibionacci pivots (from onBar in my strategy).
The numbers returned don't match what I see in the user interface with the same settings.

So, this returns monthly pivots just fine (the numbers match completely):
double[] pivots = indicators.fibPivot(instrument, Period.DAILY, OfferSide.BID, 9, 1);

However, this does not return the correct weekly pivots:
double[] pivots = indicators.fibPivot(instrument, Period.DAILY, OfferSide.BID, 8, 1);

I've tried everything I can think of, including calling the overloaded indicators.fibPivot that returns double[][], in addition to indicators.calculateIndicator. I simply can't get the output to match correctly.

I even cloned the Fibionacci indicator and added some logging messages - oddly, the bar that it calculates the correct weekly pivot from seems to contain less volume than a single day should (the bar shows a volume of 274,420 for EURUSD w/ this weeks data, whereas actual daily values typically are > 500k). I don't even know if this is relevant to the problem.

I've also tried manually calculating the pivots, without using any indicators, but again, the numbers don't match. I've tried Monday - end of Friday, Sunday-Sunday, Sunday 2:00 - Friday 2:00, etc.. Nothing seems to return the same numbers as this damn indicator.

Any ideas?


 
 Post subject: Re: Can't get weekly Fibionacci pivots from a strategy Post rating: 0   New post Posted: Tue 23 Aug, 2011, 12:28 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We were not able to reproduce the behavior you described. Could you please check if this strategy returns the correct levels:
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 {}
   


}


 

Jump to:  

cron
  © 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