Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

HistoryBars GetBarsExample demo code returns no history
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=200&t=55408
Page 1 of 1

Author:  Nebilar [ Wed 09 Aug, 2017, 18:46 ]
Post subject:  HistoryBars GetBarsExample demo code returns no history

I wanted to try out GetBarsExample.java from https://www.dukascopy.com/wiki/en/devel ... story-bars . all I did was use a fresh Main.java, add my login details, and changed client.startStrategy(new MA_Play()); to client.startStrategy(new ReadBarsExample());.
After running Main.java, it logs in successfully, starts the demo strategy, but then returns "Exited readBars method, bars read - 0". I assume it should return bars from yesterdays 24 hours. I did not change anything else.

Why is there no no data? I'm using jforex api 2.13.37.

Any help really appreciated.

EDIT: I've tried jforex api 2.13.39, the problem was not resolved

Author:  Nebilar [ Thu 10 Aug, 2017, 09:50 ]
Post subject:  Re: HistoryBars GetBarsExample demo code returns no history

I found my error. I looked only at the printout of "Exited readBars method, bars read - " + numberOfBarsLoaded);.
But this is asynchronous loading and when this code is executed, the other thread retrieving the data has not yet finished.But then context.stop(); ends the strategy. Seems to me that its a matter of luck if the loadingFinished actually gets triggered before the strategy stops. In that case it looks like it loaded nothing, while all that happened was that the strategy stopped too soon, before the data could be loaded.

Maybe set a timer in the demo code so it is more easily understandable what it is doing (when looking at the printouts)? Or simply get rid of context.stop().

  Page 1 of 1