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.

Bug in DEMA indicator
 Post subject: Bug in DEMA indicator Post rating: 0   New post Posted: Wed 01 Jun, 2011, 16:55 

User rating: -
Other values ​​are plotted on the chart, and other value returns indicators.dema (...)
Below is a simple strategy which prints the value of DEMA (200) for the last 50 candles (which can be compared with the graph)
When can I expect to improve it?

package jforex;

import java.util.*;
import java.text.SimpleDateFormat;
import com.dukascopy.api.*;

public class DEMAtest implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IContext context;
   private IIndicators indicators;
   
    @Configurable("Instrument:") public Instrument instrumentThis = Instrument.EURUSD;
    @Configurable(value="Period:") public Period periodThis = Period.FIVE_MINS;
    @Configurable(value="DEMAperiod:") public int DEMAperiod = 200;
    @Configurable(value="numberOfCandels:") public int numberOfCandels = 50;
   
   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();
   }

   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 {
        if(instrument == instrumentThis){
            if(period == periodThis){
              SimpleDateFormat formatter = new SimpleDateFormat("HH:mm,ss");
                 
              List<IBar> BarListDT = history.getBars(instrument, period, OfferSide.BID, Filter.WEEKENDS, numberOfCandels, bidBar.getTime(), 0);
                     
              double[] DTdema = indicators.dema(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, DEMAperiod, Filter.WEEKENDS, numberOfCandels, bidBar.getTime(), 0);
              for(int i=0;i<DTdema.length;i++){
                  console.getOut().println(instrument.name()+" "+i+" time: "+formatter.format( new Date(BarListDT.get(i).getTime()-3600000*2))+": dema: "+DTdema[i]+ " high: "+BarListDT.get(i).getHigh()+" low: "+BarListDT.get(i).getLow());
                }
           }
        }       
    }
}


 
 Post subject: Re: DDSJFX-453 Bug in DEMA indicator Post rating: 0   New post Posted: Thu 02 Jun, 2011, 09:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
DEMA indicator gets recalculated for the entire chart data (like OBV and AD indicators), have a look at the following:
https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?p=30712#p30712


 
 Post subject: Re: DDSJFX-453 Bug in DEMA indicator Post rating: 0   New post Posted: Fri 03 Jun, 2011, 18:31 

User rating: -
Thank you very much.
The same is true of the SMMA and the HMA?


 
 Post subject: Re: DDSJFX-453 Bug in DEMA indicator Post rating: 0   New post Posted: Fri 03 Jun, 2011, 19:02 

User rating: -
How do I get the results DEMA indicator that they are equal to those which I see in the chart at the moment?


 
 Post subject: Re: DDSJFX-453 Bug in DEMA indicator Post rating: 0   New post Posted: Tue 07 Jun, 2011, 14:28 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
janjjj wrote:
The same is true of the SMMA and the HMA?

For HMA - yes, for SMMA - no.
janjjj wrote:
How do I get the results DEMA indicator that they are equal to those which I see in the chart at the moment?

Try calculating DEMA for the last 4000 bars.


 

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