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.

Setting indicator parameters from a strategy using JForex-API.
 Post subject: Setting indicator parameters from a strategy using JForex-API. Post rating: 0   New post Posted: Thu 10 Dec, 2020, 13:59 

User rating: 0
Joined: Mon 07 Dec, 2020, 21:36
Posts: 2
Location: Russian Federation,
In my strategy, I add the CCI indicator to the chart. The documentation describes well the methods on how the input and output parameters can be configured, but I could not find information on how you can configure the parameters presented on the "Levels" and "Advanced" tabs:

Image

Image

Please tell me how to do this using JForex-API.

Thanks in advance for your reply.


Attachments:
ВопросПоПараметрам2.png [40.14 KiB]
Downloaded 375 times
ВопросПоПараметрам1.png [48.86 KiB]
Downloaded 374 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: Setting indicator parameters from a strategy using JForex-API. Post rating: 0   New post Posted: Wed 30 Dec, 2020, 17:31 

User rating: 0
Joined: Mon 07 Dec, 2020, 21:36
Posts: 2
Location: Russian Federation,
Many thanks to Vadim Berezhnoj, who sent an example code in personal correspondence:
package jforex;

import java.awt.*;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.feed.*;
import com.dukascopy.api.feed.util.*;
import com.dukascopy.api.indicators.*;
import com.dukascopy.api.indicators.OutputParameterInfo.*;

public class AddIndicatorToChart implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
   
    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();
        this.userInterface = context.getUserInterface();
       
        IFeedDescriptor feedDescriptor = new TimePeriodAggregationFeedDescriptor(Instrument.EURUSD, Period.ONE_MIN, OfferSide.BID, Filter.WEEKENDS);
        IChart chart = context.openChart(feedDescriptor);
       
        IIndicator indicator = indicators.getIndicator("CCI");
        IndicatorInfo indicatorInfo = indicator.getIndicatorInfo();
       
        indicatorInfo.setRecalculateOnNewCandleOnly(true);
       
        indicatorInfo.setDefaultLevelsInfo(new LevelInfo[] {
            new LevelInfo("High level", 100, DrawingStyle.DASH_LINE, Color.GRAY, 1, 1),
            new LevelInfo("Middle level", 0, DrawingStyle.DASH_LINE, Color.GRAY, 1, 1),
            new LevelInfo("Low level", -100, DrawingStyle.DASH_LINE, Color.GRAY, 1, 1)
        });
       
        chart.add(indicator, new Object[] {14}, Instrument.EURUSD, Period.TEN_MINS, OfferSide.ASK);
       
        context.stop();
    }

    public void onStop() throws JFException {
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
}

as well as links to the source of information:
https://www.dukascopy.com/client/javado ... y-boolean-
https://www.dukascopy.com/client/javado ... velInfo:A-
https://www.dukascopy.com/client/javado ... OfferSide-


 

Jump to:  

  © 1998-2024 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