Dukascopy
 
 
Wiki JStore Search Login

JFOREX-3631 IHistory::getBar() return null
 Post subject: JFOREX-3631 IHistory::getBar() return null Post rating: 0   New post Posted: Thu 15 Mar, 2012, 16:42 
User avatar

User rating: 1
Joined: Thu 15 Mar, 2012, 16:30
Posts: 20
Hello, sometimes it happens that IHistory::getBar() / getBars() Function returns null, like you described in Wiki: "If there is no bar loaded at that position, then function returns null."

Its a little bit confusing since i can already see this bar on the chart but when i try to accsess it via getBar() the Function returns null anyway.

How can i force JForex to load this bar?


 
 Post subject: Re: IHistory::getBar() return null Post rating: 0   New post Posted: Fri 16 Mar, 2012, 10:10 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please provide an example strategy that replicates the issue.


 
 Post subject: Re: IHistory::getBar() return null Post rating: 0   New post Posted: Tue 20 Mar, 2012, 02:20 
User avatar

User rating: 1
Joined: Thu 15 Mar, 2012, 16:30
Posts: 20
Ok, first of all this Problem happens only in Live-Mode(Demo-Acc) in the HistoricalTester everything went well.

It seems like the Problem occurres only if i want to access the Bar thats currently forming (Shift: 0) on an M5 and/or M15 Chart,
on higher Timeframes such as H4, D1 & W1 it works just fine.


attached Example-Strategy:

-In the onStart() Function i load the last 200 Bars (including currently forming Bar) for each of my used Periods.
Bars get loaded fine except for M5 Period.

-current Bar loading in onTick()-Function fails on M5 & on M15 Timeframe, the higher Timeframes work just fine.
If I open a Chart and select Period M15 in it, the M15-Bar loading in onTick() works just fine too.. (same with M5)


Do i have to open a Chart window for each and every Timeframe i want to load current Bar for?


Attachments:
File comment: Example-Strategy
BarLoading.java [3.51 KiB]
Downloaded 398 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: 2 bugs Post rating: 0   New post Posted: Sat 31 Mar, 2012, 16:20 
User avatar

User rating: 0
Joined: Tue 17 Jan, 2012, 15:15
Posts: 20
Location: Russian FederationRussian Federation
Hello,

I think that I found 2 bugs in the latest version of JForex (Historical tester).

Test code:
public void onBar(Instrument instrument, Period period, IBar askbar,
            IBar bidbar) throws JFException {
                 IBar prevBarAsk1 = history.getBar(instrument, period,
                        OfferSide.ASK, 2);
}


It throws exception:
Strategy tester: com.dukascopy.api.JFException: Could not load bar for instrument [EUR/USD], period [Hourly], side [Ask], start time [2011.03.01 08:00:00 000], current bar start time [2011.03.01 10:00:00 000]


The other problem is indicator values with Filter.ALL_FLATS
private final Filter indFilter = Filter.ALL_FLATS;

    public static String arrayToString(double [][] arr){
      String str = "";
      for (int r=0; r<arr.length; r++) {
          for (int c=0; c<arr[r].length; c++) {
             str += " " + (new DecimalFormat("0.000000")).format(arr[r][c]);
          }
          str += "; ";
      }
      return str;
   }

    void printMsg(String text)
    {
        console.getOut().println(text);
    }


public void onBar(Instrument instrument, Period period, IBar askbar,
            IBar bidbar) throws JFException {

                double macdNoFlat[][] = indicators.macd(instrument,period,OfferSide.BID,AppliedPrice.CLOSE,12,26,9,indFilter,0,askbar.getTime(),4);
                printMsg(arrayToString(macdNoFlat));

}


I'm testing this code on EUR/USD, Last year. Values of macd in array are not equal to indicator on chart and values can change at next bar:
2012-03-31 15:08:43   0.000708 0.000635 0.000696 0.000649;  0.000843 0.000802 0.000780 0.000754;  -0.000135 -0.000167 -0.000085 -0.000106;
2012-03-31 15:08:43   0.000790 0.000708 0.000635 0.000703;  0.000877 0.000843 0.000802 0.000782;  -0.000087 -0.000135 -0.000167 -0.000079;
2012-03-31 15:06:28   0.000852 0.000790 0.000708 0.000626;  0.000899 0.000877 0.000843 0.000800;  -0.000047 -0.000087 -0.000135 -0.000174;
2012-03-31 15:06:27   0.000855 0.000852 0.000790 0.000708;  0.000911 0.000899 0.000877 0.000843;  -0.000055 -0.000047 -0.000087 -0.000135;
2012-03-31 15:06:27   0.000971 0.000855 0.000852 0.000788;  0.000924 0.000911 0.000899 0.000877;  0.000047 -0.000055 -0.000047 -0.000089;
2012-03-31 15:06:27   0.000886 0.000971 0.000855 0.000854;  0.000913 0.000924 0.000911 0.000899;  -0.000027 0.000047 -0.000055 -0.000045;
2012-03-31 15:06:27   0.000804 0.000886 0.000971 0.000851;  0.000920 0.000913 0.000924 0.000910;  -0.000116 -0.000027 0.000047 -0.000058;
2012-03-31 15:06:27   0.000806 0.000804 0.000886 0.000970;  0.000948 0.000920 0.000913 0.000924;  -0.000143 -0.000116 -0.000027 0.000046;


 
 Post subject: Re: 2 bugs Post rating: 0   New post Posted: Mon 02 Apr, 2012, 10:49 
User avatar

User rating: 0
Joined: Tue 17 Jan, 2012, 15:15
Posts: 20
Location: Russian FederationRussian Federation
I've found this topic: viewtopic.php?f=65&t=36131&p=46827
I tried to reproduce it and no luck. Macd on chart is always differs from logged values no matter if filter all flats or not.


 

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