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 call indicators using method
 Post subject: Can't call indicators using method Post rating: 0   New post Posted: Thu 30 Sep, 2010, 12:57 

User rating: -
Hi, I've been trying to call some indicators using method but can't seem to get it to work. Any idea?

package jforex;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;

public class test implements IStrategy {
   public double amount = 0.1;
   public int ema_duration = 5;
   public int rsi_duration = 9;
   public int bar_shift = 1;
   public Instrument instrument = Instrument.EURUSD;
   public Period period = Period.FIFTEEN_MINS;
   public IEngine engine;
   public IHistory history;
   public IIndicators indicators;
   
   public void onStart(IContext context) throws JFException {
      this.engine = context.getEngine();
      this.history = context.getHistory();
      this.indicators = context.getIndicators();
   }
   
   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 ask_bar, IBar bid_bar) throws JFException {   
      double ema_value = GetEMA(ema_duration, period, bar_shift);
      double rsi_value = GetRSI(rsi_duration, period, bar_shift);
   }
   
   private double GetEMA(int duration, Period period, int shift) {
      return ema_value = indicators.ema(this.instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, duration, shift);
   }
   
   private double GetRSI(int duration, Period period, int shift) {
      return indicators.rsi(this.instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, duration, shift);   
   }
}


 
 Post subject: Re: Can't call indicators using method Post rating: 0   New post Posted: Thu 30 Sep, 2010, 15:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please take a look here https://www.dukascopy.com/wiki/index.php/Indicators


 

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