Dukascopy
 
 
Wiki JStore Search Login

JFOREX-3368 No actual IBar for Custom Periods in API
 Post subject: JFOREX-3368 No actual IBar for Custom Periods in API Post rating: 0   New post Posted: Mon 05 Dec, 2011, 13:26 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
"actual IBar" is the current bar, which is displayed in the chart. But the API returns no value for this IBar!
You can proof this with the following program:

1. Open only one chart EURUSD in JForex
2. Set a custom period to 2 Minutes (via preferences)
3. Set the opened chart to 2 Minutes period
4. Compile and start the strategy CustomPeriodBarBug
5. View the messages, e.g.
12:22:13 EUR/USD, 2 Mins bar1 close = 1.34474
12:22:13 EUR/USD, 2 Mins bar0 close = null !
12:22:13 checking 2 Mins

bar1 has a value, bar0 (the actual) not!

Tested with
Dukascopy ver. 2.13.34
JForex API ver. 2.6.38.1
Java 6, 32 bit, Update 26
Win 7, 64 bit

/*     
 * This is a test program only, do not use for trading!
 * It checks the JForex bar algorithm for the current Period of the first opened chart in JForex
 * which is found by the getChart() function of the JForex API
 *
 * (c) 2011 Stash GmbH München
 *     www.stash.de
 *     Author: Bernhard Schicht
 *     [email protected]
 */
 
package jforex;
import java.util.*;
import com.dukascopy.api.*;

public class CustomPeriodBarBug 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();
   }

   public void onAccount(IAccount account) throws JFException {
   }

   public void onMessage(IMessage message) throws JFException {
   }

   public void onStop() throws JFException {
   }
    public IChart currentChart = null;
   public void onTick(Instrument instrument, ITick tick) throws JFException {       
        if (instrument != Instrument.EURUSD) return;
        String bar0Close = null;
        String bar1Close = null;
        if (context.getChart(instrument) != null)  currentChart = context.getChart(instrument);
        if (currentChart == null){
             console.getOut().println("currentChart == null!");
             return;   
        }
        console.getOut().println("checking "+currentChart.getSelectedPeriod().toString());
        IBar bar0 = getBar(instrument, currentChart.getSelectedPeriod(), 0);
        if (bar0 == null) bar0Close = "null !";
        else bar0Close = String.valueOf(bar0.getClose());
        console.getOut().println(currentChart.toString()+" bar0 close = "+bar0Close);

        IBar bar1 = getBar(instrument, currentChart.getSelectedPeriod(), 1);
        if (bar1 == null) bar1Close = "null !";
        else bar1Close = String.valueOf(bar1.getClose());
        console.getOut().println(currentChart.toString()+" bar1 close = "+bar1Close);
   }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {

    }
   
    public IBar getBar(Instrument instr, Period period, int barsBack){
        try{           
            return history.getBar(instr, period, OfferSide.BID, barsBack);
        }
        catch (Exception e){
            e.printStackTrace(console.getErr());
            return null;
        }
    }   
}


 
 Post subject: Re: JFOREX-3368 No actual IBar for Custom Periods in API Post rating: 0   New post Posted: Tue 06 Dec, 2011, 10:23 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Fixed in the latest API version.


 
 Post subject: Re: JFOREX-3368 No actual IBar for Custom Periods in API Post rating: 0   New post Posted: Tue 06 Dec, 2011, 17:10 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
The bug is still there in Historical Tester.
1. Close all charts.
2. start Historical Tester
3. Download EUR/USD ticks and switch on Visual Mode and Messages
4. Run with CustomPeriodBarBug strategy
5. Switch Period to 2 Minutes in Periodcombobox of the just opened chart.

You see
2011-12-06 16:06:28 EUR/USD, 2 Mins bar1 close = 1.33132
2011-12-06 16:06:28 EUR/USD, 2 Mins bar0 close = null !
2011-12-06 16:06:28 checking 2 Mins


Tested with
Dukascopy ver. 2.13.34
JForex API ver. 2.6.38.1
Java 6, 32 bit, Update 26
Win 7, 64 bit


 
 Post subject: Re: JFOREX-3368 No actual IBar for Custom Periods in API Post rating: 0   New post Posted: Wed 07 Dec, 2011, 14:09 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Hello Bernhard,

this bug is fixed in API 2.6.50, which at this moment is only available as standalone.
I've asked numerous times but haven't gotten an answer yet to the question when the desktop client will be updated with a newer API release.
It's frustrating to be left completely in the dark about the release roadmaps and I've gotten tired of asking, but you could go ahead and ask again. May you be successful... ;)

Best,
RR.


 

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