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.

Problem with MACD signals - urgent help needed
 Post subject: Problem with MACD signals - urgent help needed Post rating: 0   New post Posted: Thu 23 Jun, 2011, 00:39 

User rating: 0
Joined: Thu 23 Jun, 2011, 00:33
Posts: 2
Location: NZ
Hi

Can someone please help me. I was using the following code to retrieve the MACD signals and i was receiving them fine till this morning.

double[][] res1 = indicators.macd(instrument, perTrigger, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 12, 26, 9, Filter.NO_FILTER, 2, tick.getTime(), 0);

Now I am not getting any ticks back at all.

Can some one please help me with this. I am 100% sure my code is working and No code has been changed for last few days. I have been running this code for the past three weeks and was working up until this morning.

Thanks in advance.


 
 Post subject: Re: Problem with MACD signals - urgent help needed Post rating: 0   New post Posted: Thu 23 Jun, 2011, 11:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Did you notice if the ticks updating in the JForex client while this occured? Does the problem persist? If it does, could you please check if the following strategy prints the ticks?
package jforex.strategies.indicators;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

import com.dukascopy.api.*;

public class MACDSignals implements IStrategy {
   private IConsole console;
   private IIndicators indicators;
   private SimpleDateFormat sdf;

   @Configurable("Instrument")
   public Instrument instrument = Instrument.EURUSD;
   @Configurable("perTrigger period step")
   private Period perTrigger  = Period.ONE_MIN;


   @SuppressWarnings("serial")
   public void onStart(IContext context) throws JFException {
      this.console = context.getConsole();
      this.indicators = context.getIndicators();

      sdf = new SimpleDateFormat("HH:mm:ss") {{setTimeZone(TimeZone.getTimeZone("GMT"));}};
      
      print("start");
   }

   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 {
      
      if (!instrument.equals(this.instrument) )
         return;
      
      double[][] res1 = indicators.macd(instrument, perTrigger, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 12, 26, 9, Filter.NO_FILTER, 2, tick.getTime(), 0);
      
      //print the whole array
      print(sdf.format(tick.getTime()) + ": (MACD; MACD signal; MACD hist) " +arrayToString(res1) + "");
   }

   public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
   }
   
   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++) {
          for (int c=0; c<arr[r].length; c++) {
             str += " " + (new DecimalFormat("0.000000")).format(arr[r][c]);
          }
          str += "; ";
      }
      return str;
   }

}


 

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