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.

Support please
 Post subject: Support please Post rating: 0   New post Posted: Fri 04 Nov, 2011, 15:05 
User avatar

User rating: 0
Joined: Sun 09 Oct, 2011, 15:43
Posts: 7
Location: ChinaChina
Hello,

I am quite a beginner to Java. Please help me!

I tried to write a strategy by using fibPivot. I want to buy or sell if the price pierces fibPivots. However, it does not work as I imagine. It's not sensitive. The piercing triggers were so few, actually there should be much more as I saw in the OHLC index. Therefore I write the following codes to check what's wrong, but it does not work neither. It didnot print. Could you please help me on this issue? Do we already have such a existing strategy like this? Or may I have one from you?

Thank you very much! Have a nice weekend!

package jforex;

import com.dukascopy.api.*;

public class Test implements IStrategy {

    private IConsole console;
    private IHistory history;
    private IIndicators indicators;

    public Instrument instrument = Instrument.EURUSD;
    public Period period = Period.FIFTEEN_MINS;

   public void onStart(IContext context) throws JFException {
      this.console = context.getConsole();
      this.history = context.getHistory();
      this.indicators = context.getIndicators();
     
      if (!instrument.equals(this.instrument) || !period.equals(this.period))
         return;
      IBar prevBar1 = history.getBar(instrument, period, OfferSide.BID, 1);
      IBar prevBar2 = history.getBar(instrument, period, OfferSide.BID, 2);
      double [] FP = indicators.fibPivot(instrument, Period.DAILY, OfferSide.BID, 7, 0);
        for (int r=0; r<FP.length; r++) {
        if (((prevBar2.getClose()>=FP[r] && prevBar1.getClose()<FP[r]) || (prevBar2.getClose()<=FP[r] && prevBar1.getClose()>FP[r]))){
            print ("piercing");
        }
        }
   }
   
   private void print(Object message) {
      console.getOut().println(message);
   }

   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 {   }
}


 
 Post subject: Re: Support please Post rating: 0   New post Posted: Mon 07 Nov, 2011, 08:38 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You are retrieving values by shift, meaning that the resulting array consists of the current days P, R1, S1, R2, S2, R3, S3. Consider logging both bar values and indicator values to see what is going on:
https://www.dukascopy.com/wiki/index.php ... ing_values


 

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