1 registered members (AndrewAMD),
684
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Keeping non-24h markets synchronized in live and backtest
[Re: boatman]
#463088
11/14/16 20:44
11/14/16 20:44
|
Joined: Jun 2016
Posts: 9 Germany, BW
MattY
OP
Newbie
|
OP
Newbie
Joined: Jun 2016
Posts: 9
Germany, BW
|
@dr_panther: the history doesn't have unwanted bars. It's the live data that have these additional wrong bars. That's because Zorro's quoting is running when the particular market is closed. And then it produces additional bars that are not in the history.
@boatman: when I put only the entry logic inside the if() statement I get no error that's right. But I can't skip these additional live bars. So, I tried to put the whole run() function inside an if statement to execute the system only during these times.
I am stuck, here. A function like StartWeek/EndWeek would be needed so that Zorro logs out at the end of the day and doesn't produce these surplus bars, something like StartDay/EndDay.
Doesn't anybody else have these live trading problem? It should occur with every non-24h market and on a lot of timeframes.
BTW: I tried it also with IB in demo-mode. It's the same behaviour.
Last edited by MattY; 11/14/16 20:45.
|
|
|
Re: Keeping non-24h markets synchronized in live and backtest
[Re: MattY]
#463092
11/14/16 22:39
11/14/16 22:39
|
Joined: Feb 2014
Posts: 73 Montreal, Qc Canada
Finstratech
Junior Member
|
Junior Member
Joined: Feb 2014
Posts: 73
Montreal, Qc Canada
|
Play with this:
// create a midnight-aligned daily price series
static int BarsPerDay = 0;
if(hour(0) < hour(1)) { // day change
TimeFrame = -BarsPerDay; // end the frame
BarsPerDay = 0;
} else {
TimeFrame = 0; // inside the frame
BarsPerDay++; // count number of bars per day
}
vars PriceD1 = series(price());
// alternative: a midnight-aligned price series using frameSync()
StartWeek = 10000;
TimeFrame = frameSync(H24);
vars PriceD1 = series(price());
Also enter "time zone" in the search bar of the HTML Help document located in the main Zorro folder.
|
|
|
Re: Keeping non-24h markets synchronized in live and backtest
[Re: boatman]
#463153
11/18/16 10:41
11/18/16 10:41
|
Joined: Jun 2016
Posts: 9 Germany, BW
MattY
OP
Newbie
|
OP
Newbie
Joined: Jun 2016
Posts: 9
Germany, BW
|
Hey, I figured it out finally. Actually the code here does the job.
// skipping bars for a certain time period
static int BarsMissing = 0;
if(hour() >= 19 and hour() < 20) // 0 when the current bar has no price quotes
{
TimeFrame = 0; // set to zero when not in frame
BarsMissing++;
}
else if (hour() == 20 and minute() == 0 )
{
TimeFrame = -BarsMissing; // set TimeFrame to the negative number of skipped bars for ending the frame
BarsMissing = 0;
}
else
TimeFrame = 1; // Normal operation
So, I had it but I didn't see it. Thanks for pushing me in the right direction, again. The reason is I thought Zorro would produce no log file, when skipping bars. But it does and freezes all indicator and other values when TimeFrame is 0. See here: [2408: Thu 17.11.16 18:55] +0 +205 64/3 4825/4826\4824/4824 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 1
[2409: Thu 17.11.16 19:00] +0 +187 64/3 4824/4825\4820/4821 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2410: Thu 17.11.16 19:05] +0 +167 64/3 4820/4821\4816/4817 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2411: Thu 17.11.16 19:10] +0 +167 64/3 4815/4818\4813/4817 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2412: Thu 17.11.16 19:15] +0 +170 64/3 4817/4819\4816/4818 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2413: Thu 17.11.16 19:20] +0 +187 64/3 4818/4821\4818/4821 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2414: Thu 17.11.16 19:25] +0 +167 64/3 4819/4821\4817/4817 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2415: Thu 17.11.16 19:30] +0 +150 64/3 4818/4818\4814/4815 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2416: Thu 17.11.16 19:35] +0 +141 64/3 4814/4815\4811/4813 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2417: Thu 17.11.16 19:40] +0 +160 64/3 4813/4817\4813/4816 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2418: Thu 17.11.16 19:45] +0 +153 64/3 4817/4819\4815/4815 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2419: Thu 17.11.16 19:50] +0 +157 64/3 4815/4818\4814/4816 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2420: Thu 17.11.16 19:55] +0 +149 64/3 4816/4817\4814/4814 Close: 4824.00, Ind: 4824.76, AssetFrame: 1, TimeFrame: 0
[2421: Thu 17.11.16 20:00] +0 +166 64/3 4816/4818\4814/4817 Close: 4817.25, Ind: 4823.35, AssetFrame: 1, TimeFrame: -12
[2422: Thu 17.11.16 20:05] +0 +178 64/3 4818/4820\4817/4819 Close: 4819.40, Ind: 4822.36, AssetFrame: 1, TimeFrame: 1
|
|
|
|