Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Alternating, different closes in different BarPeriods #463453
12/04/16 23:27
12/04/16 23:27
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
It seems that priceClose()s for the same date at the same time with the same history files (.t6) are alternating through the BarPeriods:

Code:
e.g. EUR/USD:

BarPeriod: 1440/120/30/10/1:
[..: Tue 06.01.09 00:00] (1.39578)priceClose: 1.36299
[..: Wed 07.01.09 00:00] (1.36299)priceClose: 1.34973

BarPeriod: 240/60/15/5
[..: Tue 06.01.09 00:00] (1.36020)priceClose: 1.36376
[..: Wed 07.01.09 00:00] (1.35201)priceClose: 1.35070


e.g. EUR/GBP:

BarPeriod: 1440/120/30/10/1:
[..: Tue 06.01.09 00:00] (0.96152)priceClose: 0.92680
[..: Wed 07.01.09 00:00] (0.92680)priceClose: 0.90537

BarPeriod: 240/60/15/5:
[..: Tue 06.01.09 00:00] (0.92382)priceClose: 0.92690
[..: Wed 07.01.09 00:00] (0.90520)priceClose: 0.90598



Are there rules which priceClose() is taken in which BarPeriod and how to convert them (deviation in this example between 1 and 10 PIPs)? Comparing strategies in different BarPeriods is just a bit hard this way.

Thanks, Sphin

P.S.: 1.52.0 without LEAN of course

Re: Alternating, different closes in different BarPeriods [Re: Sphin] #463456
12/05/16 08:18
12/05/16 08:18
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
The close price is the price of the last tick of the bar period. I can imagine that the close price can differ by 1 tick when that tick is exactly at the hour boundary. Can you check the price immediately before or afterwards?

Re: Alternating, different closes in different BarPeriods [Re: jcl] #463465
12/05/16 19:02
12/05/16 19:02
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I'm not quite sure what to check but I think the highest resolution in .t6 is 1 minute and a tick therefore is a 1-minute-bar.

If I let Zorro print the close price each bar in a bar period of 1 I get these prices:

Code:
EUR/USD:
[2386: Mon 05.01.09 23:59] (1.36487)priceClose: 1.36376
[2387: Tue 06.01.09 00:00] (1.36376)priceClose: 1.36299

[3817: Tue 06.01.09 23:59] (1.35087)priceClose: 1.35070
[3818: Wed 07.01.09 00:00] (1.35070)priceClose: 1.34973


EUR/GBP:
[2392: Mon 05.01.09 23:59] (0.92733)priceClose: 0.92690
[2393: Tue 06.01.09 00:00] (0.92690)priceClose: 0.92680

[3830: Tue 06.01.09 23:59] (0.90603)priceClose: 0.90598
[3831: Wed 07.01.09 00:00] (0.90598)priceClose: 0.90537


Here it is noticeable that in BarPeriods 240/60/15/5 the close price of 00:00 is set to a value that is regarded as the close price of 23:59 in a bar period of 1. But this is from the point of view of a bar period of 1 of course.

Re: Alternating, different closes in different BarPeriods [Re: Sphin] #463471
12/06/16 08:02
12/06/16 08:02
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Yes. Prices in history files are no bar periods, but single ticks, although with an open, close, high, and low. A tick is valid until the next tick.

If a tick has a time stamp at exactly a hour boundary, it can fall in either the previous or the next bar period, dependent on rounding. In the latter case the bar period ends with the previous tick. At least I would interpret it so.

But I'll let the developer check if it is really so, and modify it so that the same tick is always at the same side of the boundary. It's not relevant for backtests, but nicer.

Re: Alternating, different closes in different BarPeriods [Re: jcl] #463482
12/06/16 19:41
12/06/16 19:41
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I think it might be relevant for backtests because if I buy and sell at different prices I get different results, is this wrong? Another fact in this context: As shown above the bar periods 1440/120/30/10/1 seem to be in sync but if I buy at 00:00:00 I get different entry prices in all bar periods:
Code:
BP: 1440
[8: Thu 15.01.09 00:00] (0.90952)
EUR/GBP priceClose: 0.90367
[EUR/GBP::L0801] Long 1@0.90352  at 00:00:00

BP: 120
[99: Wed 14.01.09 22:00] (0.90226)
[100: Thu 15.01.09 00:00] (0.90288)
EUR/GBP priceClose: 0.90367
[EUR/GBP::L0001] Long 1@0.90372  at 00:00:00

BP: 30
[408: Wed 14.01.09 23:30] (0.90227)
[409: Thu 15.01.09 00:00] (0.90225)
EUR/GBP priceClose: 0.90367
[EUR/GBP::L0901] Long 1@0.90357  at 00:00:00

BP: 10
[1228: Wed 14.01.09 23:50] (0.90241)
[1229: Thu 15.01.09 00:00] (0.90388)
EUR/GBP priceClose: 0.90367
[EUR/GBP::L2901] Long 1@0.90364  at 00:00:00

BP: 1
[12218: Wed 14.01.09 23:59] (0.90410)
[12219: Thu 15.01.09 00:00] (0.90394)
EUR/GBP priceClose: 0.90367
[EUR/GBP::L1901] Long 1@0.90408  at 00:00:00


Is Slippage and Fill's extra Slippage dependant on the bar period? Is there a chance to sync them?

Re: Alternating, different closes in different BarPeriods [Re: Sphin] #463483
12/07/16 09:40
12/07/16 09:40
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Ok, let me reformulate this: If you really get noticeably different results this way, better do not trade that strategy live.

The purpose of a backtest is determining the robustness of a system. If tiny random effects are relevant for your backtest result, the system is no good. Same goes for slippage and fill modes: They should not produce totally different backtest results, and if they do, something's wrong with the system.

Re: Alternating, different closes in different BarPeriods [Re: jcl] #463494
12/07/16 23:14
12/07/16 23:14
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Maybe, but that's not my business. Trying to find the optimal bar period for a strategy that's profitable on daily bars. Decreasing the bar periods suddenly changed the result without having changed any other parameters yet and after searching intensively for an error in my script I found the 2 effects described before. A few PIPs per trade summed up over 500 trades influence the result of course and I'm not sure if I see any effect of optimization or of price fluctuations. This might be enhanced by the average trade duration of 1.5 bars (days) only.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1