Contents tagged with jForex

  • Complete description of arguments in jForex submitOrder

    Hello everybody,

    here I want to leave fragment of code related to submitOrder:

    public void onStart(IContext context) throws JFException {

    IEngine engine = context.getEngine();

    IHistory history = context.getHistory();

    Instrument instrument = Instrument.EURUSD;

    context.setSubscribedInstruments(java.util.Collections.singleton(instrument), true);

    ITick lastTick = history.getLastTick(instrument);

    double price = lastTick.getAsk() + instrument.getPipValue() * 5;

    double sl = lastTick.getAsk() - instrument.getPipValue() * 20;

    double tp = lastTick.getAsk() + instrument.getPipValue() * 10;

    long gtt = lastTick.getTime() + TimeUnit.SECONDS. … more

  • EMA in jForex. Full code

    Hello everybody,

    recently one of my readers asked me to show whole code of taking value of ema.

    Here it is:

    package jforex;

    import java.util.*;

    import com.dukascopy.api.*;

    public class CountSamples 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 = … more

  • Get values of indicators in jforex

    Hello everybody,

    today I want to write a few words about getting indicators values for testing strategy. 

    Recently I had need to get ema value. But for my surprise following code didn't give me values, which I've seen on the screen:

    double ema = indicators.ema(instrument, period, side, AppliedPrice.CLOSE, emaTimePeriod, 1);

    And in order for getting proper indicator value I've found another fragment of code which gave me proper result:

    double ema89 =, Period.TEN_MINS, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 89, maType, indFilter, 1, prevBar.getTime(), 0)[0];

    with following variables declared:

    private static final IIndicators.MaType maType = IIndicators. … more

  • JForex-Utilities sample and JFQuantisan.jar

    Greetings to everybody.

    Recently when I visited blog of Paul Lam, I've noticed JFUtil 2.0 alpha demonstration of usage of his library JForex-Utilities.

    It is nice example, but very unformatted. It looks like this:

    So I've made formatting corrections, and put his sample on my page with formatting:

    package jforex.yz;

    import java.util. * ;

    import com.dukascopy.api. * ;

    import com.quantisan.JFUtil. * ;



    public class JfutilDemo implements IStrategy {

    private int counter = new Random().nextInt(100); // notice the lack of fields to manage JForex objects

    @Override public void … more

  • How to compile JForex-Utilities in Intellij Idea to receive JFQuantisan.jar

    Hello everybody,

    I continue my experimenting with dukascopy platform, and next issue which I faced was the following: "How to compile JForex-Utilities in Intellij Idea to receive JFQuantisan.jar"

    This question may sound trivial to experienced java developers, but such as I'm mainly .Net dev for me it was pretty comlicated ( i.e. googling, meditating ) question. 

    With help of google and power of reason I've found solution, which I want to describe step by step.

    So, let's get started.

    Download source code

    As it often happened, I've downloaded source code from github. By habit of Microsoft .Net developer I thought that I can press compile, and immediately receive .jar file. But my … more

  • jForex non standard time frame ema value

    Hello everybody,

    Few days ago I had an order for automating forex strategy for 3 minutes time frame in jForex platform.

    I faced issue that by default jForex doesn't work with 3 minutes. In order to do this, the following parts were needed for addition:


    public void onStart(IContext context) throws JFException {

    period3Min = Period.createCustomPeriod(Unit.Minute, 3);

    edDescriptor myFeed = new TimePeriodAggregationFeedDescriptor(Instrument.EURUSD, period3Min, OfferSide.ASK);

    ontext.subscribeToFeed(myFeed, new IFeedListener() {@Override

    pan style="color: #008800; font-weight: bold;">public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData) {

    try {

    nsole. … more