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.

different data in JForex API application vs. graph
 Post subject: different data in JForex API application vs. graph Post rating: 0   New post Posted: Wed 28 Sep, 2011, 13:49 

User rating: -
Hi,

I created the simple application using JForex API which sends alerts based
on some technical indicators. I noticed, that application sends different
data bid/ask than data displayed in the graph. The application use method:

*public void onBar(Instrument instrument, Period actualPeriod, IBar
askBar, IBar bidBar) throws JFException { *

*IBar prevBar_1 = history.getBar(instrument, period, OfferSide.BID,
1);** //

Output from the application
instr: EURUSD, period: ONE_MIN,
bidBar time: Mon Sep 26 13:36:00 CEST 2011, bid: 1.34613,

Displayed on the graph: bid on close: 1.34571

I'd like to ask you why there are those differences and how to ensure to have the same data in the graph and application.
Thank you for the answer in advance.

lnchml


 
 Post subject: Re: different data in JForex API application vs. graph Post rating: 0   New post Posted: Thu 29 Sep, 2011, 11:55 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please see the following:
https://www.dukascopy.com/wiki/index.php ... _checklist
If the values still don't match, please provide code fragments that make indicator calls.


 
 Post subject: Re: different data in JForex API application vs. graph Post rating: 0   New post Posted: Thu 13 Oct, 2011, 09:28 

User rating: -
I checked and set the parameters from your indicator usage checklist, but the values still doesn't match in some cases. I am sending you some cases and fragment of the code:

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

 if (!periods.contains(period))

 return;



 log.info("instr: " + instrument.name() + ", period: " + period.name()
 + ", bidBar time: " + new Date(bidBar.getTime()) + ", bid: " +
 bidBar.getClose());

 }


-----

instr: EURUSD, period: ONE_MIN, bidBar time: Wed Oct 12 14:10:00 CEST
2011, bid: 1.37843 displayed in the graph bid: 1.37832

instr: EURUSD, period: ONE_MIN, bidBar time: Wed Oct 12 13:45:00 CEST
2011, bid: 1.37712 displayed in the graph bid: 1.3760

instr: EURAUD, period: FIVE_MIN, bidBar time: Wed Oct 12 13:45:00 CEST
2011, bid: 1.35963 displayed in the graph bid: 1.36050

instr: EURGBP, period: ONE_MIN, bidBar time: Wed Oct 12 13:49:00 CEST
2011, bid: 0.87559 displayed in the graph bid: 0.87507

I'd like to ask you, why there are so differences and how to ensure to have the same data in the graph and application.


 
 Post subject: Re: different data in JForex API application vs. graph Post rating: 0   New post Posted: Thu 13 Oct, 2011, 15:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We did not manage to reproduce the behavior with the following strategy:
package jforex.test;

import com.dukascopy.api.*;

public class BarPrinterUni implements IStrategy {

    public Instrument instrument = Instrument.EURUSD;
    private IConsole console;

    @Override
    public void onStart(IContext context) throws JFException {       
        console = context.getConsole();   
    }

    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if ( instrument != this.instrument)
            return;
       
        console.getOut().println(" bar: " + period  + " " + bidBar);
    }
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }
    public void onMessage(IMessage message) throws JFException {    }
    public void onAccount(IAccount account) throws JFException {    }
    public void onStop() throws JFException {    }
}
Please verify that you had selected Bid prices to both chart and strategy.


 

Jump to:  

  © 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