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.

Can't find H4 candle High/Low in any sub M5 candle
 Post subject: Can't find H4 candle High/Low in any sub M5 candle Post rating: 0   New post Posted: Mon 29 Jun, 2015, 17:15 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
When I have a bid high/low in a H4 candle (for example), my strategy tries to find in which M5 bid candle was this high/Low.
It happens quite often that the H4 bid High/Low is not in any M5. Although, there is one which is not too far, there can be 0.5pip to 1pip difference.
- Is there a logical explanation for this behaviour?
- Is there any other way (besides comparing OHLC value) to find in which M5 bar is the H4 High/Low?
- If not, what is the maximum difference between H4 H/L and the matching M5 H/L?

Example with H4 USD/CAD Low 1.23037
{time=2015-06-29 04:00:00, C=1.23248, O=1.23305, L=1.23037, H=1.23396}

The closest M5 low I can find is 1.23032 (0.5 pip difference)
M5 bars:
2015-06-29 16:00:13,675|  INFO |       SwingPoints:178 | 1435550400000[2015-06-29 04:00:00.000+0000] O: 1.23305 C: 1.23337 H: 1.23337 L: 1.23291 V: 114.91
2015-06-29 16:00:13,676|  INFO |       SwingPoints:178 | 1435550700000[2015-06-29 04:05:00.000+0000] O: 1.23338 C: 1.23335 H: 1.23343 L: 1.23333 V: 72.72
2015-06-29 16:00:13,677|  INFO |       SwingPoints:178 | 1435551000000[2015-06-29 04:10:00.000+0000] O: 1.23338 C: 1.23355 H: 1.2336 L: 1.23338 V: 67.7
2015-06-29 16:00:13,677|  INFO |       SwingPoints:178 | 1435551300000[2015-06-29 04:15:00.000+0000] O: 1.23355 C: 1.23343 H: 1.23356 L: 1.23334 V: 96.9
2015-06-29 16:00:13,678|  INFO |       SwingPoints:178 | 1435551600000[2015-06-29 04:20:00.000+0000] O: 1.23342 C: 1.23343 H: 1.23358 L: 1.23336 V: 47.91
2015-06-29 16:00:13,678|  INFO |       SwingPoints:178 | 1435551900000[2015-06-29 04:25:00.000+0000] O: 1.23342 C: 1.2334 H: 1.23373 L: 1.23338 V: 70.65
2015-06-29 16:00:13,679|  INFO |       SwingPoints:178 | 1435552200000[2015-06-29 04:30:00.000+0000] O: 1.23342 C: 1.23329 H: 1.23355 L: 1.233 V: 226.96
2015-06-29 16:00:13,680|  INFO |       SwingPoints:178 | 1435552500000[2015-06-29 04:35:00.000+0000] O: 1.23328 C: 1.23324 H: 1.2334 L: 1.2332 V: 72.18
2015-06-29 16:00:13,681|  INFO |       SwingPoints:178 | 1435552800000[2015-06-29 04:40:00.000+0000] O: 1.23324 C: 1.23322 H: 1.2333 L: 1.23305 V: 78.44
2015-06-29 16:00:13,681|  INFO |       SwingPoints:178 | 1435553100000[2015-06-29 04:45:00.000+0000] O: 1.2332 C: 1.23308 H: 1.23328 L: 1.23307 V: 181.29
2015-06-29 16:00:13,682|  INFO |       SwingPoints:178 | 1435553400000[2015-06-29 04:50:00.000+0000] O: 1.23308 C: 1.23312 H: 1.23337 L: 1.23308 V: 163.48
2015-06-29 16:00:13,683|  INFO |       SwingPoints:178 | 1435553700000[2015-06-29 04:55:00.000+0000] O: 1.23314 C: 1.23336 H: 1.2334 L: 1.23306 V: 184.98
2015-06-29 16:00:13,683|  INFO |       SwingPoints:178 | 1435554000000[2015-06-29 05:00:00.000+0000] O: 1.23336 C: 1.23305 H: 1.23336 L: 1.23304 V: 198.38
2015-06-29 16:00:13,684|  INFO |       SwingPoints:178 | 1435554300000[2015-06-29 05:05:00.000+0000] O: 1.23305 C: 1.23309 H: 1.23313 L: 1.23293 V: 114.86
2015-06-29 16:00:13,685|  INFO |       SwingPoints:178 | 1435554600000[2015-06-29 05:10:00.000+0000] O: 1.23309 C: 1.23382 H: 1.23396 L: 1.23296 V: 273.42
2015-06-29 16:00:13,686|  INFO |       SwingPoints:178 | 1435554900000[2015-06-29 05:15:00.000+0000] O: 1.23381 C: 1.23321 H: 1.23381 L: 1.23321 V: 144.62
2015-06-29 16:00:13,686|  INFO |       SwingPoints:178 | 1435555200000[2015-06-29 05:20:00.000+0000] O: 1.23322 C: 1.23367 H: 1.2338 L: 1.23322 V: 133.9
2015-06-29 16:00:13,687|  INFO |       SwingPoints:178 | 1435555500000[2015-06-29 05:25:00.000+0000] O: 1.23368 C: 1.23367 H: 1.2338 L: 1.23354 V: 128.9
2015-06-29 16:00:13,687|  INFO |       SwingPoints:178 | 1435555800000[2015-06-29 05:30:00.000+0000] O: 1.23366 C: 1.23337 H: 1.23373 L: 1.23321 V: 102.62
2015-06-29 16:00:13,688|  INFO |       SwingPoints:178 | 1435556100000[2015-06-29 05:35:00.000+0000] O: 1.23337 C: 1.23319 H: 1.23339 L: 1.23307 V: 187.45
2015-06-29 16:00:13,689|  INFO |       SwingPoints:178 | 1435556400000[2015-06-29 05:40:00.000+0000] O: 1.23318 C: 1.23308 H: 1.23319 L: 1.23301 V: 127.47
2015-06-29 16:00:13,689|  INFO |       SwingPoints:178 | 1435556700000[2015-06-29 05:45:00.000+0000] O: 1.23307 C: 1.23347 H: 1.23349 L: 1.23302 V: 119.74
2015-06-29 16:00:13,690|  INFO |       SwingPoints:178 | 1435557000000[2015-06-29 05:50:00.000+0000] O: 1.23345 C: 1.23339 H: 1.23349 L: 1.23321 V: 155.38
2015-06-29 16:00:13,691|  INFO |       SwingPoints:178 | 1435557300000[2015-06-29 05:55:00.000+0000] O: 1.23341 C: 1.23276 H: 1.23349 L: 1.23272 V: 189.15
2015-06-29 16:00:13,691|  INFO |       SwingPoints:178 | 1435557600000[2015-06-29 06:00:00.000+0000] O: 1.23276 C: 1.23341 H: 1.23347 L: 1.23256 V: 538.63
2015-06-29 16:00:13,692|  INFO |       SwingPoints:178 | 1435557900000[2015-06-29 06:05:00.000+0000] O: 1.23341 C: 1.23278 H: 1.23341 L: 1.23248 V: 439.57
2015-06-29 16:00:13,692|  INFO |       SwingPoints:178 | 1435558200000[2015-06-29 06:10:00.000+0000] O: 1.23278 C: 1.23293 H: 1.23311 L: 1.23261 V: 440.32
2015-06-29 16:00:13,693|  INFO |       SwingPoints:178 | 1435558500000[2015-06-29 06:15:00.000+0000] O: 1.23291 C: 1.2327 H: 1.23293 L: 1.2326 V: 515.79
2015-06-29 16:00:13,694|  INFO |       SwingPoints:178 | 1435558800000[2015-06-29 06:20:00.000+0000] O: 1.23273 C: 1.23319 H: 1.23335 L: 1.23273 V: 536.01
2015-06-29 16:00:13,694|  INFO |       SwingPoints:178 | 1435559100000[2015-06-29 06:25:00.000+0000] O: 1.23318 C: 1.23224 H: 1.2332 L: 1.2322 V: 531.82
2015-06-29 16:00:13,695|  INFO |       SwingPoints:178 | 1435559400000[2015-06-29 06:30:00.000+0000] O: 1.23226 C: 1.2326 H: 1.23266 L: 1.23195 V: 766.41
2015-06-29 16:00:13,695|  INFO |       SwingPoints:178 | 1435559700000[2015-06-29 06:35:00.000+0000] O: 1.2326 C: 1.23121 H: 1.23262 L: 1.23092 V: 727.72
2015-06-29 16:00:13,696|  INFO |       SwingPoints:178 | 1435560000000[2015-06-29 06:40:00.000+0000] O: 1.23119 C: 1.2323 H: 1.23237 L: 1.23118 V: 693.67
2015-06-29 16:00:13,697|  INFO |       SwingPoints:178 | 1435560300000[2015-06-29 06:45:00.000+0000] O: 1.23231 C: 1.23249 H: 1.23277 L: 1.23189 V: 584.69
2015-06-29 16:00:13,697|  INFO |       SwingPoints:178 | 1435560600000[2015-06-29 06:50:00.000+0000] O: 1.23249 C: 1.23182 H: 1.23253 L: 1.23176 V: 574.1
2015-06-29 16:00:13,698|  INFO |       SwingPoints:178 | 1435560900000[2015-06-29 06:55:00.000+0000] O: 1.23184 C: 1.23139 H: 1.23196 L: 1.23124 V: 603.31
2015-06-29 16:00:13,699|  INFO |       SwingPoints:178 | 1435561200000[2015-06-29 07:00:00.000+0000] O: 1.23137 C: 1.23111 H: 1.2317 L: 1.23095 V: 543.84
2015-06-29 16:00:13,699|  INFO |       SwingPoints:178 | 1435561500000[2015-06-29 07:05:00.000+0000] O: 1.23111 C: 1.23109 H: 1.23188 L: 1.23097 V: 672.92
2015-06-29 16:00:13,700|  INFO |       SwingPoints:178 | 1435561800000[2015-06-29 07:10:00.000+0000] O: 1.23109 C: 1.2316 H: 1.2316 L: 1.23032 V: 559.27
2015-06-29 16:00:13,700|  INFO |       SwingPoints:178 | 1435562100000[2015-06-29 07:15:00.000+0000] O: 1.23159 C: 1.23215 H: 1.23216 L: 1.23142 V: 419.84
2015-06-29 16:00:13,701|  INFO |       SwingPoints:178 | 1435562400000[2015-06-29 07:20:00.000+0000] O: 1.23214 C: 1.23188 H: 1.23231 L: 1.23134 V: 619.93
2015-06-29 16:00:13,702|  INFO |       SwingPoints:178 | 1435562700000[2015-06-29 07:25:00.000+0000] O: 1.23188 C: 1.23207 H: 1.23209 L: 1.23169 V: 443.82
2015-06-29 16:00:13,702|  INFO |       SwingPoints:178 | 1435563000000[2015-06-29 07:30:00.000+0000] O: 1.23208 C: 1.23223 H: 1.23239 L: 1.23168 V: 377.57
2015-06-29 16:00:13,703|  INFO |       SwingPoints:178 | 1435563300000[2015-06-29 07:35:00.000+0000] O: 1.23227 C: 1.2322 H: 1.23271 L: 1.23212 V: 389.99
2015-06-29 16:00:13,703|  INFO |       SwingPoints:178 | 1435563600000[2015-06-29 07:40:00.000+0000] O: 1.23219 C: 1.23203 H: 1.23221 L: 1.23183 V: 461.24
2015-06-29 16:00:13,704|  INFO |       SwingPoints:178 | 1435563900000[2015-06-29 07:45:00.000+0000] O: 1.23203 C: 1.23232 H: 1.23252 L: 1.23203 V: 505.81
2015-06-29 16:00:13,705|  INFO |       SwingPoints:178 | 1435564200000[2015-06-29 07:50:00.000+0000] O: 1.23232 C: 1.23232 H: 1.23262 L: 1.23211 V: 440.9
2015-06-29 16:00:13,705|  INFO |       SwingPoints:178 | 1435564500000[2015-06-29 07:55:00.000+0000] O: 1.23231 C: 1.23248 H: 1.23261 L: 1.23214 V: 405.65
2015-06-29 16:00:13,706|  INFO |       SwingPoints:178 | 1435564800000[2015-06-29 08:00:00.000+0000] O: 1.23249 C: 1.23308 H: 1.23328 L: 1.23249 V: 403.03

Thank for you help in understanding / finding a workaround to find the correct M5 candle.
Kind Regards

PS: Version 2.43.2 (I can't use a more recent version due to what seems to be a bug in history.getBars, see https://www.dukascopy.com/swiss/english ... 16&t=52703)


 
 Post subject: Re: Can't find H4 candle High/Low in any sub M5 candle Post rating: 0   New post Posted: Tue 30 Jun, 2015, 09:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
For us both 4 hour bars and 5 min bars show 1.23032 as lowest value in this interval.


Attachments:
Strategy.java [3.8 KiB]
Downloaded 117 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: Re: Can't find H4 candle High/Low in any sub M5 candle Post rating: 0   New post Posted: Tue 30 Jun, 2015, 14:01 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
Thank you for the quick answer and test strategy.
Indeed when getting both from history, the values are the same. However, I got the H4 bid bar from the strategy onBar arguments and the M5 bars from history.
Doing further tests, I realized that the bars in History and onBar() can be different. Is there a reason for that?

There is another example with EURUSD Low this morning (there was also one in EURAUD). There is only 0.1pip for this one; It's not a big difference, but it explains why I don't find the matching M5 bar., and sometimes there is a larger difference. Only the low value is different in that example: High, Close, Open have the same value.
From onBar H1 EURUSD
1435654800000[2015-06-30 09:00:00.000+0000] O: 1.1142 C: 1.11862 H: 1.11937 L: 1.11342

From History H1 EURUSD:
1435654800000[2015-06-30 09:00:00.000+0000] O: 1.1142 C: 1.11862 H: 1.11937 L: 1.11341 V: 14561.23

The "onBar" value in that case is also the one I see on JForex
Thank you


 
 Post subject: Re: Can't find H4 candle High/Low in any sub M5 candle Post rating: 0   New post Posted: Wed 08 Jul, 2015, 08:29 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
I did more tests. It appears that one H4 candle can change over time!
Example with EURGBP at 2015-07-07 16:00:00 GMT

When loading the bar with onBar, I get:
1436284800000[2015-07-07 16:00:00.000+0000] O: 0.70893 C: 0.71234 H: 0.71399 L: 0.70886 V: 17862.31
This doesn't march with the M5 values (wrong Opening for example)

When getting that same bar from history 8 hours later on 2015-07-08 at 04:00:07,33 GMT, I get the same values:
1436284800000[2015-07-07 16:00:00.000+0000] O: 0.70893 C: 0.71234 H: 0.71399 L: 0.70886 V: 17862.31
I used
history.getBars(Instrument.EURGBP, Period.FOUR_HOURS, OfferSide.BID, Filter.NO_FILTER, 1, periodBar.getTime(), 0).get(0);
I can imagine it comes from cache which could explain why the values are the same.

However, if loading that same bar from history now (2015-07-08 07:08:16,256) with the same
history.getBars(Instrument.EURGBP, Period.FOUR_HOURS, OfferSide.BID, Filter.NO_FILTER, 1, periodBar.getTime(), 0).get(0);
I get different values:
1436284800000[2015-07-07 16:00:00.000+0000] O: 0.70891 C: 0.71232 H: 0.71402 L: 0.70884 V: 24310.29
This last one seems to be the correct one as it matches the M5 bars.

This is a big problem for my strategy when this happens. Is there a workaround I can use to get the correct values?

I am using version 2.43.2

Thank you


 
 Post subject: Re: Can't find H4 candle High/Low in any sub M5 candle Post rating: 0   New post Posted: Wed 15 Jul, 2015, 07:00 

User rating: 6
Joined: Tue 02 Jul, 2013, 16:52
Posts: 38
I have done more tests, and it seems that both bars change, which seems more logical. My understanding is that M5 bars are downloaded from the server (because there were not in local cache), but I get the H4 or H1 from the local cache, which would explain why I don't see the updated values. And I haven't found any workaround yet, and I am really confused by this problem!

It doesn't seem normal to me that the bars values change over time! but my question is:
How can I force getting the history bars from the server and not from cache to avoid that problem?

It seems that the following code will get me the value from cache if already loaded earlier:
IBar refreshedBar = history.getBars(instrument, Period.FOUR_HOURS, OfferSide.BID, filtering, 1, periodBar.getTime(), 0).get(0);
Latest example with the Low in EURCAD H4:
Searching 1.39924 in bid Bar 1436875200000[2015-07-14 12:00:00.000+0000] O: 1.40858 C: 1.404 H: 1.4112 L: 1.39924 V: 40522.14
M5 candle:
1436885700000[2015-07-14 14:55:00.000+0000] O: 1.40051 C: 1.40027 H: 1.40061 L: 1.39923 V: 1147.01


 
 Post subject: Re: Can't find H4 candle High/Low in any sub M5 candle Post rating: 0   New post Posted: Fri 16 Oct, 2015, 13:33 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The only timeframes that are downloaded are ticks, 1M, 1M, and 1D(UTC). All the other bars are generated locally.
One option could be to empty cache so that data is downloaded from the beginning.
That can be done by setting a new cache folder in Tools > Preferences > Advanced > Local cache path.


 

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