Gamestudio Links
Zorro Links
Newest Posts
Can't plot daily high & low
by Zheka. 10/14/19 18:39
TWS "Market closed" fix
by jcl. 10/14/19 15:09
2xCapital slider to increase size
by jcl. 10/14/19 14:03
Imgui Lite-c Development
by txesmi. 10/13/19 09:40
A9
by Dooley. 10/11/19 18:53
Need Help Finding Cause of Crash
by Dooley. 10/11/19 18:51
What algorithm is used for BALANCED?
by JamesHH. 10/11/19 17:32
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
7 registered members (exile, Dooley, Dalla, kvm, sdh309795gaas, jibanes, Zheka), 661 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
FrankW, TedMar, raimucuk, vivaldi2, filip
18304 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Time restrictions #478337
10/06/19 01:08
10/06/19 01:08
Joined: Jun 2019
Posts: 14
B
bondo1 Offline OP
Newbie
bondo1  Offline OP
Newbie
B

Joined: Jun 2019
Posts: 14
Hi,

Below is the code that I'm working with:

Code
function run()
{
//Initial settings
set(LOGFILE + PLOTNOW);
//Bar generation settings
BarMode = BR_WEEKEND + BR_MARKET;

//Time settings 
StartDate = 2019;
BarPeriod = 1;  //1 Minute 
BarZone = -8; //PST 

StartWeek = 10630;
EndWeek = 51400;

StartMarket = 0630;  
EndMarket = 1301;

//Define assets 
asset("USO");
var USO = priceClose();

//Plots
plot("USO", USO, NEW, PURPLE);
}


From the above, I'm expecting Zorro to plot me the 1 minute, closing prices of USO. Because of the BarMode flags, I'm also expecting the plot to include only data from Monday through Friday, with data beginning at 0630 PST and ending at 1301 PST everyday during the week. (For some reason, when I set EndWeek to 51300 and EndMarket to 1300, Zorro won't plot the closing price at 1300, I'm assuming this has something to do with how Zorro takes in DST? If anyone has an explanation for this, please let me know).

However, when I check the log, I'm finding my code is plotting data at 0630 (regardless of the BarMode flags) even if there is no data at 0630. Instead, it seems like Zorro is grabbing the last recorded closing price before 0630, and labeling it 0630.

See picture of that here:

https://imgur.com/a/CFze3wf

Highlighted in green is what I expect to happen, and highlighted in orange is what is being output to the Excel file. Notice that it's taking the most recent value before 0630 (at 1327 UTC) and recording it as 0630.

My question then is, if there is no data at 0630, how can I ensure that my code won't print data at 0630 like the above? I thought with the BarMode flags I wouldn't get any data prints where there aren't any.

Thanks!

Re: Time restrictions [Re: bondo1] #478339
10/06/19 10:44
10/06/19 10:44
Joined: Sep 2003
Posts: 861
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 861
Any bar has an open, close, high, and low price so there is no bar with "no data".

https://manual.zorro-project.com/bars.htm

Re: Time restrictions [Re: bondo1] #478343
10/06/19 19:37
10/06/19 19:37
Joined: Jun 2019
Posts: 14
B
bondo1 Offline OP
Newbie
bondo1  Offline OP
Newbie
B

Joined: Jun 2019
Posts: 14
I re-read the bars link but I'm not understanding. I also rechecked these in the manual: https://zorro-project.com/manual/en/barmode.htm and this: https://zorro-project.com/manual/en/asset.htm

"By default, any bar must contain at least one price quote. When no price quotes arrive due to market inactivity, no new bars are created."

From the above, my understanding is that if there is no trade activity at a specified interval, Zorro won't generate a bar there. Since the asset I'm using has some gaps, I checked the same day from my first post and found this:

https://imgur.com/a/bVE0nag

Zorro is generating a bar at 17:58 & 18:00 since there is trade activity (indicated by the history on the right side). Since there is no trade activity at 17:59, and I didn't set BR_FLAT, I expect there to be no bar generated at 17:59 (and there
isn't, so this is good).

However, why then is Zorro generating a bar at 0630 (1330 UTC as shown in the first post's picture)? It doesn't generate bars in between the times I specified in Start&EndMarket if there was no trade activity, but it's consistently generating a bar at Start Market (0630) when there is no trade activity at 0630.

The only thing I could find that might be related to what I'm trying to fix is this: https://zorro-project.com/manual/en/asset.htm

"When a subsequent asset has a gap where the first asset has none, the gap is filled with price data from the previous bar... For avoiding this, use the BR_FLAT flag or don't combine assets with different market hours."

From the code I posted above though, I've only called a single asset. Also, I'm not sure how using the BR_FLAT flag would avoid filling price data gaps. From my understanding, setting BR_FLAT would result in gap fills. In the picture below, I used the code I posted above but added BR_FLAT.

https://imgur.com/a/OEBwovj

Zorro generates a bar at 17:59, from data at 17:58, which makes sense since the manual said this would be the result. However, I wanted to avoid that, which is why I didn't have it set in the first place.







Last edited by bondo1; 10/06/19 19:41.
Re: Time restrictions [Re: bondo1] #478346
10/07/19 08:01
10/07/19 08:01
Joined: Jul 2000
Posts: 27,029
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,029
Frankfurt
Maybe it's a misunderstanding of "bar". A bar is simply an amount of time. Since the time is divided into bars, there is no time period with "no bar". And since a bar must normally cover at least one price quote, there is also no bar with "no price".

When a market opens at 6:30, then there's normally also a new price at 6:30, and you get a new bar at 6:30. When you set BR_FLAT, you'll get a new bar even without a new price.

Re: Time restrictions [Re: jcl] #478349
10/08/19 09:40
10/08/19 09:40
Joined: Jun 2019
Posts: 14
B
bondo1 Offline OP
Newbie
bondo1  Offline OP
Newbie
B

Joined: Jun 2019
Posts: 14
Hey jcl,

Thanks for taking the time to look at this (also Spirit).

I re-re-read the bar-related manual pages and checked the forums regarding anything related to skipped bars. For anyone also trying to figure out bar construction, these were threads that I think were semi-relevant:

https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=469227
https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=468677
https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=465646
https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=463088

The biggest problem I'm having is that this statement from the manual: "When no price quotes arrive due to market inactivity, no new bars are created." looks conflicting with the results I'm getting in Excel.
There is no market activity at 0630 as shown by the history in this picture: https://imgur.com/a/CFze3wf. There is only activity at 0627 [before StartMarket] and at 0631 and onward. Since there is no activity at 0630, why then is there a new bar created at 0630?

Originally Posted by jcl
When a market opens at 6:30, then there's also a new price at 6:30, and you get a new bar at 6:30. When you set BR_FLAT, you'll get a new bar even without a new price.


That's the thing though, there is no price at 0630 in the above example (again, no market activity activity at 0630 from the history).

In this thread (I know, this was a while ago) https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=463088&page=1, you stated:

Originally Posted by jcl
Bars are skipped when the asset is not traded and there are no price quotes. This depends on the asset, not on your script.


Like in the above picture, the asset was not traded at 0630, therefore why is the bar at 0630 not skipped? Here, https://imgur.com/a/bVE0nag, there is market activity at only 1758 & 1800. There is no market activity at 1759 as indicated by the history on the right, so the bar is skipped. Great, this is what I expected from the manual and what I've been reading. Why then is this behavior not happening at the time I defined as StartMarket (0630)? Instead, Zorro is grabbing the most recently updated price before StartMarket (0630), which is what I want to avoid.

Last edited by bondo1; 10/08/19 10:07.
Re: Time restrictions [Re: bondo1] #478350
10/08/19 10:09
10/08/19 10:09
Joined: Jul 2000
Posts: 27,029
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,029
Frankfurt
Yes. If the asset is not traded, then there is no new bar. Thus, when you got a new bar at 6:30, at least one price quote must have been received in the previous bar that ended at 6:30. That's the close price of that bar. It has nothing to do with market activity after 6:30 - that has no effect on the bar that just ended, only on the next bar.

Re: Time restrictions [Re: bondo1] #478358
10/09/19 08:13
10/09/19 08:13
Joined: Jun 2019
Posts: 14
B
bondo1 Offline OP
Newbie
bondo1  Offline OP
Newbie
B

Joined: Jun 2019
Posts: 14
Ah! Now that makes sense, thanks a bunch jcl (haha, I was so excited after reading the above that I couldn't sleep last night)!


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1