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 fivesma price displayed by the platform is different from the strategy??
 Post subject: Why the fivesma price displayed by the platform is different from the strategy?? Post rating: 0   New post Posted: Mon 14 May, 2018, 14:19 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 26
Location: China,
 import java.util.TimeZone;
import com.dukascopy.api.*;
import com.dukascopy.api.IIndicators.AppliedPrice;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class GetBarsExample implements IStrategy {
     @Configurable("Instrument")
    public Instrument Curinstrument = Instrument.EURUSD;
   
    private IContext context;
    private IConsole console;
    private IHistory history;
     private IBar prevDailyBar;
      private IIndicators myIdicator;
      private SimpleDateFormat gmtSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public void onStart(IContext context) throws JFException {
        this.context = context;
        console = context.getConsole();
        history = context.getHistory();
        myIdicator = context.getIndicators();
       
        Set<Instrument> instruments = new HashSet<Instrument>();

        instruments.add(Curinstrument);
        context.setSubscribedInstruments(instruments, true);
            if (myIdicator != null) {

         double   Cur_FiveSMA = myIdicator.sma(Curinstrument, Period.DAILY, OfferSide.ASK, AppliedPrice.CLOSE, 5, 0);
            print(String.format("cur fivesma =%.5f\n ", Cur_FiveSMA));

         double   Pre_FiveSMA = myIdicator.sma(Curinstrument, Period.DAILY, OfferSide.ASK, AppliedPrice.CLOSE, 5, 1);

            print(String.format(" Pre_FiveSMA =%.5f\n ", Pre_FiveSMA));
        }


Image
Image


Attachments:
error2.jpg [253.33 KiB]
Downloaded 215 times
ERRORFiveSMA.jpg [319.57 KiB]
Downloaded 219 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 fivesma price displayed by the platform is different from the strategy?? Post rating: 0   New post Posted: Wed 16 May, 2018, 15:33 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This difference is due to Flats Filtration Settings.

By default charts filtrates all weekend flat bars, in your strategy you use sma calculation method without Filter parameter. To get value excluding weekend bars, you need to use another calculation method with Filter parameter. About all sma calculation methods you can read in javadoc: https://www.dukascopy.com/client/javadoc3/com/dukascopy/api/IIndicators.html#sma-com.dukascopy.api.Instrument-com.dukascopy.api.Period-com.dukascopy.api.OfferSide-com.dukascopy.api.IIndicators.AppliedPrice-int-com.dukascopy.api.Filter-int-long-int-

Flats filtration on chart also can be specified in platform settings:
Settings - Preferences - Chart - Flats Filtration


 

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