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.

Why the indicator value from code is different with chart?
 Post subject: Why the indicator value from code is different with chart? Post rating: 0   New post Posted: Tue 21 Sep, 2010, 13:45 

User rating: 0
Joined: Tue 21 Sep, 2010, 12:52
Posts: 6
I tried to use the following code to get values of SMA200 and ATR200. But I found the values I got are different with the values shows on the chart (screenshot attached). Did I do something wrong? Appreciate if someone can help.
---------------------
package jforex;

import java.util.*;

import com.dukascopy.api.*;

public class Strategy_Test implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IContext context;
   private IIndicators indicators;

   private Instrument instrument = Instrument.EURUSD;
   private Period timeFrame = Period.THIRTY_MINS;
   private int timePeriod = 200;
   
   public void onStart(IContext context) throws JFException {
      this.engine = context.getEngine();
      this.console = context.getConsole();
      this.history = context.getHistory();
      this.context = context;
      this.indicators = context.getIndicators();

      double SMA = indicators.sma(this.instrument, this.timeFrame, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, this.timePeriod, 0);
      double ATR = indicators.atr(this.instrument, this.timeFrame, OfferSide.BID, this.timePeriod, 0);
       
      console.getOut().println("Instrument= "+this.instrument+", Time Frame= "+timeFrame);
      console.getOut().println("SMA"+timePeriod+"= "+SMA+", ATR"+timePeriod+"= "+ATR);
       
      this.context.stop();
   }
}


Attachments:
File comment: Screenshot of chart
Problem.jpg [285.89 KiB]
Downloaded 404 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: Why the indicator value from code is different with char Post rating: 0   New post Posted: Fri 24 Sep, 2010, 09:09 

User rating: 0
Joined: Tue 21 Sep, 2010, 12:52
Posts: 6
:D ok, the problem is solved. just add a weekend filter :lol: :lol: :lol:


 

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