Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, TipmyPip, degenerate_762, AndrewAMD, Nymphodora), 997 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 7 1 2 3 4 5 6 7
Precise AssetMarketStart/End #485280
02/16/22 13:47
02/16/22 13:47
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
It is a reality that the market in MT4/5 closes at 16:59 EST each day (at 16:55 on Fri); + spreads widen towards market close (in fx)- so I want to "close" the hour 3-5 min earlier.

Yet, using AssetMarketEnd=1657, Zorro "rounds" the time to the nearest BarPeriod and takes the tick of 17:00 as the close for the last candle.

I find value in using the bars ending at normal hour boundaries and don't want to use BarOffset.

So, it would be great if candle prices were limited precisely by the time specified as AssetMarketEnd - both in Test and in Live, and no trades were allowed past the time specified.

Thank you.


Last edited by Zheka; 02/16/22 14:24.
Re: Precise AssetMarketStart/End [Re: Zheka] #485285
02/16/22 23:09
02/16/22 23:09
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
When using several assets:
Code
function run() {
	
	set(LOGFILE);
	NumYears=1;
	
       BarPeriod=30;
	
BarMode = BR_ASSET;

	  asset("EUR/USD");	  
	
	  vars prcI= series(priceC(0));	
	   printf("# FXcls=%.5f,markend=%i",prcI[0],AssetMarketEnd);

			
	asset("WS30");	
	
	vars prc= series(priceC(0));	
	printf("# WScls=%.2f,markend=%i",prc[0],AssetMarketEnd);
	
	
	asset("XAUUSD");	
	
	vars prc= series(priceC(0)); vars Opn = series(priceO(0));
	
	printf("# XAU_cls =%.2f,opn=%.2f,markend=%i",prc[0],Opn[0],AssetMarketEnd);	
} 
i see the following output:
Quote
[189: Thu 22-01-06 21:00] (1788.20) FXcls=1.12912,markend=1656 WScls=36254.00,markend=1658 XAUcls =1788.20,opn=1789.34,markend=1657

[190: Thu 22-01-06 21:30] (1789.81) FXcls=1.12926,markend=1656 WScls=36279.00,markend=1658 XAUcls =1789.81,opn=1788.20,markend=1657

[191: Thu 22-01-06 22:00] (1790.81) FXcls=1.12985,markend=1656 WScls=36279.00,markend=1658 XAUcls =1789.81,opn=1788.20,markend=1657

[192: Thu 22-01-06 22:30] (1790.81) FXcls=1.12970,markend=1656 WScls=36279.00,markend=1658 XAUcls =1789.81,opn=1788.20,markend=1657

[193: Thu 22-01-06 23:00] (1790.81) FXcls=1.12963,markend=1656 WScls=36279.00,markend=1658 XAUcls =1789.81,opn=1788.20,markend=1657

[194: Thu 22-01-06 23:30] (1791.17) FXcls=1.12975,markend=1656 WScls=36313.00,markend=1658 XAUcls =1791.17,opn=1789.30,markend=1657


The last candle of the day on EUR/USD has a close price from the tick at 1700 EST (with AssetMarketEnd=1656), BUT on WS30 and XAU - it is from 1630EST (2130 UTC) - while AssetMarketEnd are 1658 and 1657.

Re: Precise AssetMarketStart/End [Re: Zheka] #485287
02/17/22 07:40
02/17/22 07:40
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
The market hours are not rounded, but evaluated at the end of any bar. That's why you got the 17:00 close price. I don't know the reason of 16:30 prices though - maybe that asset simply has no 17:00 prices. For closing a 17:00 candle with the 16:57 price, use a tick function and set the NOPRICE flag at the market end time. I don't want Zorro to do that automatically because it would cause incorrect candles behind the user's back.

Re: Precise AssetMarketStart/End [Re: Zheka] #485292
02/17/22 15:59
02/17/22 15:59
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Zorro is inconsistent in how it treats "times": with EndMarket=1700 (and BR_MARKET) the last bar of the day will have a timestamp of 1700 - as expected and which is THE convention for most "closing times" out there.

BUT with EndWeek=51700, - behind the unsuspecting user's back - the last bar on Friday will have a timestamp of 1600 - which is the behavior above with WS/XAU. I can bet most users are not aware of this "nuance".


Ideally, "what you set is what you get", i.e. setting AssetMarketEnd=1658, would indeed only use prices until that moment AND prevent trades opening past that time.

The situation is common and real. There has to be an in-built mechanism of how to deal with it. This can most efficiently be done at the "engine" level; switching to tick processing on the user side isn't.

I tried but could not think of a case where sticking to what's specified by AssetMarketEnd would "cause incorrect candles behind user's back" (pls give an example).

So, please consider.

Re: Precise AssetMarketStart/End [Re: Zheka] #485297
02/19/22 11:23
02/19/22 11:23
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
That would be indeed an inconsistency. - Update: Time periods usually go from start up to, but not including the end. So there is no such inconsistency, but if you think you found one, please contact Support with all details.

Re: Precise AssetMarketStart/End [Re: Zheka] #485300
02/19/22 15:04
02/19/22 15:04
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
EndWeek=1700 ends the week at 1600. Is that expected?

While the tick of 1700 - very technically - is indeed the start of the new hour, that's in conflict even with Zorro's convention on "time spans": 17:00(00!) is assumed to be the "end" time for the bar - "up to and including", not the beginning.

Then why would a bar spanning 11:00pm - 12:00 pm be considered part of the next day??


Is time treatment for AssetMarketEnd similar to EndWeek?

If yes, then "EST: 0930-1600" is a misleading example you give in the manual - this would skip a most crucial BarPeriod of a trading day.


Coming back to the OP: will there be a investigation/fix for how AssetMarket/ BR_ASSET functionality work with several assets?
Besides inconsistent "market closes"/series shifting, trades also trigger in "off-market" hours...

Re: Precise AssetMarketStart/End [Re: Zheka] #485301
02/19/22 15:15
02/19/22 15:15
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
I think I can answer that: Yes, AssetMarketEnd, EndMarket, and EndWeek are all treated the same and yes, BR_ASSET works with several assets. I'll forward that remark about the misleading example.

Re: Precise AssetMarketStart/End [Re: Zheka] #485302
02/19/22 17:44
02/19/22 17:44
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
What's the benefit or necessity of treating 00:00 as "inclusive of" for bars, but "exclusive of" for market hours/days, etc? Why would day(0) return "next day" for a bar spanning 2000-0000?

As for BR_ASSET:

1) can you pls explain the log in OP, specifically, the price series for EUR/USD.

2) this script:
Code
function run() {
	
	set(LOGFILE);
	NumYears=1;
		
        BarPeriod=15;
	
	BarZone=ET;
		
        BarMode = BR_ASSET;

        MaxLong=1; 

	asset("EUR/USD");	  
	  
	        AssetMarketZone=ET;	
		AssetMarketStart = 0930;
		AssetMarketEnd = 1601;
	 
	  vars prcI= series(priceC(0));
	
	   printf("# cls1=%.5f,mark1end=%i",prcI[0],AssetMarketEnd);

			
	asset("SPY");	
	
	AssetMarketZone=ET; 
	AssetMarketStart = 0930;
	AssetMarketEnd = 1601;	
	
	vars prc= series(priceC(0));
	
	printf("# cls2=%.2f,mark2end=%i",prc[0],AssetMarketEnd);
		
	LifeTime=10;
	if (ltod(ET,0)>AssetMarketEnd)
	  if (prc[0]>prc[1]) 
           enterLong();		
}
gives this output:
Quote
[565: Mon 22-01-10 21:00] (465.55) FXcls=1.13263,markend=1601 WScls=465.55,markend=1601

[566: Mon 22-01-10 21:15] (465.42) FXcls=1.13263,markend=1601 WScls=465.55,markend=1601
[SPY::L56606] Long 1@465.47 x at 21:15:00

[567: Mon 22-01-10 21:30] 0.0850 +0.0850 1/0 (465.61) FXcls=1.13263,markend=1601 WScls=465.55,markend=1601
The trades can also expire outside market hours.

Re: Precise AssetMarketStart/End [Re: Zheka] #485508
03/18/22 15:30
03/18/22 15:30
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
The log above shows a trade taken at 1615ET - past AssetMarketEnd=1601. The manual says that BR_ASSET prevents series shifting AND trade signals outside market hours.

BR_ASSET also does not prevent trade expiry (from LifeTime or TradeExitDate) outside market hours.

Can this pls be looked at?




Last edited by Zheka; 03/18/22 15:31.
Re: Precise AssetMarketStart/End [Re: Zheka] #485509
03/18/22 17:15
03/18/22 17:15
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Looked at what?

Re: Precise AssetMarketStart/End [Re: Zheka] #485514
03/18/22 18:06
03/18/22 18:06
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
At trades allowed outside market hours with BR_ASSET. They shouldn't be.

Re: Precise AssetMarketStart/End [Re: Zheka] #485521
03/19/22 11:00
03/19/22 11:00
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
The manual is your friend! wink

" BR_ASSET - Don't shift data series on intraday bars that end at or after AssetMarketEnd and before AssetMarketStart in the asset time zone (AssetMarketZone). This prevents updating indicators or generating trade signals outside market hours. Start and end time and zone can be individually set in the asset list. This flag must be set before calling asset. "

Maybe you meant BR_LEISURE?

https://zorro-project.com/manual/en/barmode.htm

Re: Precise AssetMarketStart/End [Re: Zheka] #485522
03/19/22 11:07
03/19/22 11:07
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Quote
This prevents updating indicators or generating trade signals
What's meant by "generating trade signals"?

If BR_LEISURE also works with AssetMarketStart/End then state this in the manual and provide explicit guidance.

Last edited by Zheka; 03/19/22 11:15.
Re: Precise AssetMarketStart/End [Re: Zheka] #485523
03/19/22 11:09
03/19/22 11:09
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
I suppose indicators cannot generate trade signals when they are not updated.

Re: Precise AssetMarketStart/End [Re: Zheka] #485524
03/19/22 11:24
03/19/22 11:24
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
It is perfectly possible if a 'signal' is generated from another asset with different/wider AssetMarketStart/End.

Re: Precise AssetMarketStart/End [Re: Zheka] #485527
03/19/22 12:04
03/19/22 12:04
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
I suppose that the not generating trade signals then happens with that different/wider AssetMarketStart/End.

Re: Precise AssetMarketStart/End [Re: Zheka] #485528
03/19/22 13:40
03/19/22 13:40
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
If BR_ASSET is not blocking trades - then just remove that misleading part of the sentence from the manual.

Is BR_LEISURE supposed to work with AssetMarketStart/End ?

Re: Precise AssetMarketStart/End [Re: Zheka] #485529
03/19/22 14:28
03/19/22 14:28
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
I dont write the manual but I think it is always updated when someone on the forum does not understand something in the manual. It also answers your question:

"BR_LEISURE Don't enter or manage trades between EndMarket and StartMarket, at holidays, and between EndWeek and StartWeek in the bar time zone (BarZone)."

https://zorro-project.com/manual/en/date.htm

EndMarket and Startmarket are predefined variables, you can set them in your script and can of course also set them to Assetmarketstart etc. Hope this answers your question.


Re: Precise AssetMarketStart/End [Re: Zheka] #485530
03/19/22 15:07
03/19/22 15:07
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
The problem with setting Start/EndMarket=AssetMarketStart/End is that - currently - StartMarket cannot be bigger than EndMarket, while AssetMarketStart can - which is THE setting for FX/futures on Globex (1800-1700ET).

May I suggest that EndMarket/StartMarket are deprecated altogether in favor of the more "modern" approach with AssetMarketStart/End??

Re: Precise AssetMarketStart/End [Re: Zheka] #485531
03/19/22 16:09
03/19/22 16:09
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
I don't think they are deprecated. They are global while assetmarket are asset-local. I also dont think that StartMarket cannot be bigger than EndMarket. I have just tested it and at least with my version I can set any time for startmarket and endmarket.

Re: Precise AssetMarketStart/End [Re: Spirit] #485532
03/19/22 17:54
03/19/22 17:54
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Originally Posted by Spirit
I don't think they are deprecated..
I suggested to deprecate them.

Actually, BR_LEISURE seems to work with AssetMarketStart/End.

Re: Precise AssetMarketStart/End [Re: Zheka] #485583
03/26/22 13:18
03/26/22 13:18
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
I was mistaken: BR_LEISURE does not work with AssetMarketStart/End out of the box.

The problem with setting StartMarket=AssetMarketStart is with BarZone -which is set once per script.

So, AssetMarketTimes need to be translated from AssetMarketZone to BarZone; doing this correctly in the general case isn't trivial.

Please make our lives simpler - make BR_LEISURE work with the new AssetMarketxxx variables.

Thank you.

Re: Precise AssetMarketStart/End [Re: Zheka] #485634
04/04/22 12:04
04/04/22 12:04
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
It would be very helpful if a snippet of code showing correct usage of AssetMarketXXX with BR_ASSET+BR_LEISURE with 2+ assets be added to the Tips+Tricks/ manual.

Re: Precise AssetMarketStart/End [Re: Zheka] #485636
04/05/22 13:45
04/05/22 13:45
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
"For using asset-dependent market hours with BR_MARKET or BR_LEISURE, copy the AssetMarket... variables to StartMarket, EndMarket, BarZone after selecting the asset." (from the BarMode description)

As to your suggestion to print local time to the log, instead of UTC, that raises the question which local time. When you set BarZone to different asset zones as above suggested, any bar could have a different local time. I think this would cause more confusion than help.

Re: Precise AssetMarketStart/End [Re: jcl] #485638
04/05/22 14:25
04/05/22 14:25
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Originally Posted by jcl
"For using asset-dependent market hours with BR_MARKET or BR_LEISURE, copy the AssetMarket... variables to StartMarket, EndMarket, BarZone after selecting the asset." (from the BarMode description)
Setting BarZone AFTER selecting asset generates Error 030 - check order of settings (as BarZone affects generation of bars).
Originally Posted by jcl
As to your suggestion to print local time to the log, instead of UTC, that raises the question which local time. When you set BarZone to different asset zones as above suggested, any bar could have a different local time.
The very first used BarZone - which is prior to asset() and which affects generation of bars - should be the time zone of the log....UTC times ARE causing confusion.

Re: Precise AssetMarketStart/End [Re: Zheka] #485661
04/10/22 16:20
04/10/22 16:20
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Variables that affect bar loading must be set before loading bars, setting them afterwars wont work obviously.

You can probably set BarZone when you only want to use BR_LEISURE because it has no effect on loading bars. But you must then set it back afterwards for avoiding error 030.

I think it is not really needed, because when BR_ASSET is set, you normally wont get trade signals anyway.

It would probably make sense when you explain what your strategy is doing and which flags or zones you need for which purpose, then it can be better understood what the problem is.

Re: Precise AssetMarketStart/End [Re: Zheka] #485665
04/11/22 10:34
04/11/22 10:34
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Setting BarZone back to the very first value (ET) at the end of the script fixes Error 030 but does not really change internal Zorro 'market hours' - they are still in the ET timezone, and therefore trades for GDAXI are allowed from 930 to 1600 ET, not WET.

Code
function run() {
	
	set(LOGFILE);
	NumYears=1;
		
   BarPeriod=15;
	
	BarZone=ET;
	
	Verbose=3;
	
	StartWeek=71800;
	EndWeek=51701;
		
BarMode = BR_WEEKEND+BR_ASSET+BR_LEISURE;

MaxLong=-1;

	asset("EUR/USD");	  
	  
	  AssetMarketZone=ET;
	
		AssetMarketStart = 1800;
		AssetMarketEnd = 1701;
		
		BarZone=AssetMarketZone;
	
		StartMarket=AssetMarketStart;
		EndMarket=AssetMarketEnd; 	
				
	  vars prcI= series(priceC(0));
	
	   printf("# cls1=%.5f,Assmark1end=%i, market=%i, susp=%i",prcI[0],AssetMarketEnd,market(ET,0),suspended());
             
           //tradeSys1();
	
	asset("GDAXI");	
		
	AssetMarketZone=WET;
	
	AssetMarketStart = 0930;
	AssetMarketEnd = 1601;	
	 
	BarZone=AssetMarketZone;
	
	StartMarket=AssetMarketStart;
	EndMarket=AssetMarketEnd; 
	
	vars prc= series(priceC(0));
	
	printf("# cls2=%.2f,mark2end=%i, market=%i, susp=%i",prc[0],AssetMarketEnd,market(WET,0),suspended());
	
		
	LifeTime=8;
	if (prc[0]>prc[1]) enterLong();
	
	BarZone=ET;
}

Re: Precise AssetMarketStart/End [Re: Zheka] #485676
04/13/22 11:35
04/13/22 11:35
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
That code looks ok. It should suppress enterLong outside AssetMarketStart/End in the AssetMarketZone.

Can you show the log?

Re: Precise AssetMarketStart/End [Re: Zheka] #485694
04/14/22 12:05
04/14/22 12:05
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Both entry and expiry occur outside of market hrs (930-1601 WET).
Code
[size:8pt][638: Tue 22-01-11 [u]16:30[/u]] -35.54 +2.60 1/9  cls1=1.13620,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)
[GDAXI::L63007][u] Expired[/u] 1@15939.90: +2.48 Bid 15939.28 at 16:45:00
Opn 15917.40 Cls 15939.90 Spr 0.63 Slp 0.00 Rol -0.00 Com 0.07 Lif 9 Net 1

[639: Tue 22-01-11 16:45] -35.66 0 1/9  cls1=1.13663,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
[GDAXI::L63907] Long 1@15969.90 x at 16:45:00
Com 0.0747  Mrg 1.12  Net 0

[640: Tue 22-01-11 17:00] -36.86 -1.20 1/10  cls1=1.13620,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)

[641: Tue 22-01-11 17:15] -35.16 +0.50 2/9  cls1=1.13569,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)

[642: Tue 22-01-11 17:30] -38.09 -2.43 1/10  cls1=1.13573,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)

[643: Tue 22-01-11 17:45] -36.21 -0.56 1/10  cls1=1.13536,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)

[644: Tue 22-01-11 18:00] -35.75 -0.0894 1/10  cls1=1.13542,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)

[645: Tue 22-01-11 18:15] -36.45 -0.79 1/10  cls1=1.13561,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)

[646: Tue 22-01-11 18:30] -35.75 -0.0894 1/10  cls1=1.13575,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)

[647: Tue 22-01-11 18:45] -35.39 +0.26 2/9  cls1=1.13644,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)
[GDAXI::L63907] Expired 1@15974.40: +0.38 Bid 15973.78 at 19:00:00
Opn 15969.90 Cls 15974.40 Spr 0.63 Slp 0.00 Rol -0.00 Com 0.07 Lif 9 Net 1

[648: Tue 22-01-11 19:00] -35.28 0 2/9  cls1=1.13666,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
[GDAXI::L64807] Long 1@15978.40 x at 19:00:00
Com 0.0748  Mrg 1.12  Net 0

[649: Tue 22-01-11 19:15] -36.60 -1.32 2/10  cls1=1.13727,MarkStart=1800,Assmark1end=1701, market=1, susp=0 cls2=15914.40,mark2end=1601, market=0, susp=0
(GDAXI::L) Skipped (Max = -1)[/size]

Re: Precise AssetMarketStart/End [Re: Zheka] #485695
04/14/22 12:49
04/14/22 12:49
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Hmm..There seem to be a problem with series shifting with BR_ASSET altogether (in v 2.47.0 and 2.47.4):
Code
function run() {
	
	set(LOGFILE);
	NumYears=1;
	
	 BarPeriod=15;
	
	BarZone=ET;
	
	Verbose=3;
		
	StartWeek=71800;
	EndWeek=51701;
		
        BarMode = BR_WEEKEND+BR_ASSET;

	   asset("SPY");
	  	
	   vars prcI= series(priceC(0));
	
	   printf("# cls1=%.5f,Mark1Start=%i,mark1end=%i, market=%i, susp=%i",prcI[0],AssetMarketStart,AssetMarketEnd,market(ET,0),suspended());
	
}
produces:
Quote
[87: Tue 22-01-04 20:30] 477.88/478.32\477.71/478.25 -0.03 cls1=478.25000,Mark1Start=730,mark1end=1601, market=1, susp=0
[88: Tue 22-01-04 20:45] 478.26/478.48\477.91/478.38 -0.03 cls1=478.38000,Mark1Start=730,mark1end=1601, market=1, susp=0
[89: Tue 22-01-04 21:00c] 478.38/478.96\477.44/477.51 -0.03 cls1=477.51001,Mark1Start=730,mark1end=1601, market=0, susp=8

[90: Tue 22-01-04 21:15c] 477.51/477.65\477.25/477.34 -0.03 cls1=477.34000,Mark1Start=730,mark1end=1601, market=0, susp=8

[91: Tue 22-01-04 21:30c] 477.35/477.58\477.25/477.41 -0.03 cls1=477.41000,Mark1Start=730,mark1end=1601, market=0, susp=8
[92: Tue 22-01-04 21:45c] 477.42/477.48\477.28/477.48 -0.03 cls1=477.48001,Mark1Start=730,mark1end=1601, market=0, susp=8
[93: Tue 22-01-04 22:00c] 477.48/477.48\477.35/477.42 -0.03 cls1=477.42001,Mark1Start=730,mark1end=1601, market=0, susp=8


Update: it works for FX and IND, but not for SPY

Last edited by Zheka; 04/14/22 13:26.
Re: Precise AssetMarketStart/End [Re: Zheka] #485698
04/15/22 09:28
04/15/22 09:28
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Thanks for the logs. Setting BarZone temporarily by script, as suggested, did not really work. BarZone is also internally used outside the script. So that was a bad advice in the manual.

We will think about a better solution for using local asset zones. Probably by automatically overriding BarZone when BR_ASSET is set. This will be implemented in the next beta version.

Re: Precise AssetMarketStart/End [Re: Zheka] #485700
04/15/22 12:49
04/15/22 12:49
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
It would be great if market hours were set to AssetMarketStart/End in AssetMarketZone automatically, without having to dance around with StartMarket=AssetMarketStart, etc..

Any hints/confirmation on BR_ASSET working for FX and SPX500, but not for SPY?

Re: Precise AssetMarketStart/End [Re: Zheka] #485708
04/16/22 11:12
04/16/22 11:12
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Maybe SPY had no market time in the asset list?

You can check with is(NOSHIFT) if series are shifted or not.


Re: Precise AssetMarketStart/End [Re: Zheka] #485710
04/16/22 12:25
04/16/22 12:25
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Have a (closer) look at the log I provided - it prints AssetMarketStart/End set for the asset.

Upd: ! even if you set AssetMarketStart/End/Zone directly in the script, NOSHIFT is NOT getting set for SPY, but IS set for SPX500 and FX.


Last edited by Zheka; 04/16/22 12:49.
Re: Precise AssetMarketStart/End [Re: Zheka] #485758
04/19/22 10:23
04/19/22 10:23
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Maybe SPY has no bars outside its market hours? Then none of its bars would get the NOSHIFT.

Re: Precise AssetMarketStart/End [Re: Zheka] #485759
04/19/22 11:14
04/19/22 11:14
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Maybe yes - maybe no...log knows
Quote
[87: Tue 22-01-04 20:30] 477.88/478.32\477.71/478.25 -0.03 cls1=478.25000,Mark1Start=730,mark1end=1601, market=1, susp=0
[88: Tue 22-01-04 20:45] 478.26/478.48\477.91/478.38 -0.03 cls1=478.38000,Mark1Start=730,mark1end=1601, market=1, susp=0
[89: Tue 22-01-04 21:00c] 478.38/478.96\477.44/477.51 -0.03 cls1=477.51001,Mark1Start=730,mark1end=1601, market=0, susp=8

[90: Tue 22-01-04 21:15c] 477.51/477.65\477.25/477.34 -0.03 cls1=477.34000,Mark1Start=730,mark1end=1601, market=0, susp=8
[91: Tue 22-01-04 21:30c] 477.35/477.58\477.25/477.41 -0.03 cls1=477.41000,Mark1Start=730,mark1end=1601, market=0, susp=8
[92: Tue 22-01-04 21:45c] 477.42/477.48\477.28/477.48 -0.03 cls1=477.48001,Mark1Start=730,mark1end=1601, market=0, susp=8
[93: Tue 22-01-04 22:00c] 477.48/477.48\477.35/477.42 -0.03 cls1=477.42001,Mark1Start=730,mark1end=1601, market=0, susp=8

Re: Precise AssetMarketStart/End [Re: Zheka] #485760
04/19/22 11:41
04/19/22 11:41
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
A new version will be uploaded in short with a change in handling asset zone and market hours. BarZone will then be automatically set.

This will probably not solve your SPY problem, but simplify the script. If it then still does not work, please contact support with the script and asset list. We'll look into that.

Re: Precise AssetMarketStart/End [Re: Zheka] #485771
04/20/22 16:28
04/20/22 16:28
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
I just tested the new version and found several problems, but let's take it one by one.
Code
function run() {
	
	set(LOGFILE);
	NumYears=1;
	Verbose=3;
   
      BarPeriod=15;
	
	BarZone=ET;		
	StartWeek=71800;
	EndWeek=51701;
		
BarMode = BR_WEEKEND+BR_NOSHIFT+BR_LOCAL+BR_LEISURE;

MaxLong=-1;

#ifndef first	
	asset("EUR/USD");	  
	
	       AssetMarketZone=ET;	
		AssetMarketStart = 1800;
		AssetMarketEnd = 1701;	
	 
	  vars prcI= series(priceC(0)); 
	  vars opnI= series(priceO(0));
	
	   printf("# opn1=%.5f,cls1=%.5f,Mark1Start=%i,mark1end=%i, market=%i,susp=%i,noshift=%i",opnI[0],prcI[0],AssetMarketStart,AssetMarketEnd,market(ET,0),suspended(), is(NOSHIFT));
#endif
	
#ifdef second	
	asset("SPY");	
	
	AssetMarketZone=ET;	
	AssetMarketStart = 0730;
	AssetMarketEnd = 1601;	
	
	vars prc= series(priceC(0));
	vars opn= series(priceO(0));
	printf("# opn2=%.2f,cls2=%.2f, mark2start=%i,mark2end=%i, market=%i,susp=%i,noshift=%i",opn[0],prc[0],AssetMarketStart,AssetMarketEnd,market(ET,0),suspended(), is(NOSHIFT));	
#endif	
/*	
	LifeTime=8;
	//if (ltod(ET,0)>AssetMarketEnd-1)
	if (prc[0]>prc[1]) enterLong();

*/	
}
doesn't work:
Code
[92: Mon 22-01-03 22:00] 1.12981/1.12993\1.12969/1.12974 -0.00004 opn1=1.12981,cls1=1.12974,Mark1Start=1800,mark1end=1701, market=1,susp=0,noshift=0
[93: Mon 22-01-03 22:30c] 1.12975/1.12977\1.12943/1.12943 -0.00004 opn1=1.12975,cls1=1.12943,Mark1Start=1800,mark1end=1701, market=0,susp=8,noshift=0
[94: Mon 22-01-03 22:45c] 1.12943/1.12962\1.12943/1.12954 -0.00004 opn1=1.12943,cls1=1.12954,Mark1Start=1800,mark1end=1701, market=0,susp=8,noshift=0
[95: Mon 22-01-03 23:00c] 1.12954/1.12965\1.12951/1.12955 -0.00004 opn1=1.12954,cls1=1.12955,Mark1Start=1800,mark1end=1701, market=0,susp=8,noshift=0
[96: Mon 22-01-03 23:15] 1.12955/1.12978\1.12955/1.12977 -0.00004 opn1=1.12955,cls1=1.12977,Mark1Start=1800,mark1end=1701, market=1,susp=0,noshift=0
1830(start)-1701(end) - works; 1900-1801 - works, but any AssetMarketEnd>1801 - doesn't work.
Other combinations like 1600(start)-1501(end) do not work either.

Last edited by Zheka; 04/20/22 16:39.
Re: Precise AssetMarketStart/End [Re: Zheka] #485784
04/21/22 11:12
04/21/22 11:12
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, this was indeed a bug. It is supposedly fixed in the latest beta - please check it out.

Re: Precise AssetMarketStart/End [Re: Zheka] #485786
04/21/22 14:10
04/21/22 14:10
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
One thing is fixed, but another appeared..

[99: Tue 22-01-04 00:00] 1.12994/1.13020\1.12982/1.13020 -0.00004 opn1=1.12994,cls1=1.13020,Mark1Start=2000,mark1end=1901, market=1,susp=0,noshift=0
[100: Tue 22-01-04 00:15c] 1.13020/1.13066\1.13014/1.13064 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=0 <--noshift should be set here
[101: Tue 22-01-04 00:30c] 1.13064/1.13069\1.13039/1.13041 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=1
[102: Tue 22-01-04 00:45c] 1.13041/1.13055\1.13040/1.13048 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=1
[103: Tue 22-01-04 01:00c] 1.13048/1.13064\1.13040/1.13057 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=1
[104: Tue 22-01-04 01:15] 1.13057/1.13089\1.13055/1.13085 -0.00004 opn1=1.13057,cls1=1.13085,Mark1Start=2000,mark1end=1901, market=1,susp=0,noshift=0


Aren't fixes tested at all??


It now works with SPY, but NOSHIFT "ends" 1 bar earlier than market opens:

[53: Tue 22-01-04 12:00c] 479.56/479.63\479.41/479.41 -0.03 opn2=477.76,cls2=477.60, mark2start=730,mark2end=1601, market=0,susp=9,noshift=1
[54: Tue 22-01-04 12:15c] 479.40/479.45\479.27/479.27 -0.03 opn2=477.76,cls2=477.60, mark2start=730,mark2end=1601, market=0,susp=9,noshift=1
[55: Tue 22-01-04 12:30] 479.27/479.33\478.65/478.75 -0.03 opn2=479.27,cls2=478.75, mark2start=730,mark2end=1601, market=1,susp=1,noshift=0 <-- this bar is outside of market hours, yet price series get shifted
[56: Tue 22-01-04 12:45] 478.72/479.05\478.72/478.95 -0.03 opn2=478.72,cls2=478.95, mark2start=730,mark2end=1601, market=1,susp=1,noshift=0


Last edited by Zheka; 04/21/22 14:22.
Re: Precise AssetMarketStart/End [Re: Zheka] #485787
04/21/22 14:56
04/21/22 14:56
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
When you let market hours begin at 7:30, the price at 7:30 is a valid price and the series get shifted. Won't you agree?

Re: Precise AssetMarketStart/End [Re: Zheka] #485789
04/21/22 15:14
04/21/22 15:14
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
The bar covering 715-729.59999 is outside of market hours - so series should not get shifted.
And changing AssetMarketStart forward to 745 is not a convenient solution - this then needs to be done explicitly in each script depending on BarPeriod (rather than be set once and for all in an Asset file).

Re: Precise AssetMarketStart/End [Re: Zheka] #485790
04/21/22 15:29
04/21/22 15:29
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Bars are explained here: https://zorro-project.com/manual/en/bars.htm

A 7:30 bar includes the 7:30 price. If you would not shift the series, the market opening price would be lost. Your series would then begin with the 7:45 price. That is probably not what most users want.


Re: Precise AssetMarketStart/End [Re: jcl] #485792
04/21/22 15:42
04/21/22 15:42
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Originally Posted by jcl
If you would not shift the series, the market opening price would be lost. The market would then begin with the 7:45 price.
If someone wants to trade at the open, then one can just check if(ltod()==AssetMarketStart)...The market will begin with the candle starting/opening exactly at MarketStart.... but it is unreasonable to shift series(=create/include a candle) prior to the market open in all the price/indicator calculations...Probably no big deal with 5-min bars, but is significant with 60+ min bars...

Trading with BarPeriod=60, why would you want to feed a 630-730 high/low in the ATR calculation?

Last edited by Zheka; 04/21/22 15:46.
Re: Precise AssetMarketStart/End [Re: Zheka] #485793
04/21/22 15:50
04/21/22 15:50
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
You're of course entitled to that opinion, but Zorro handled market times in this way all the time. They are always compared with the bar end timestamp. If you don't want to include the opening price, you can just set the market start at 7:31.

Re: Precise AssetMarketStart/End [Re: Zheka] #485794
04/21/22 15:57
04/21/22 15:57
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
If its just a matter of setting it to 731 - then so be it.

How about the issue demoed in first bit of the log?

Re: Precise AssetMarketStart/End [Re: Zheka] #485795
04/21/22 16:14
04/21/22 16:14
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Same thing. The 19:15 bar is still shifted because it had a valid 19:01 price. If any part of the bar falls in market hours, it is shifted.

If you don't want this, set the market end at 19:00 sharp, not at 19:01.



Re: Precise AssetMarketStart/End [Re: Zheka] #485800
04/21/22 17:47
04/21/22 17:47
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Brr...This is inconsistent with 1) how e.g. EndWeek works - you have to set it to 51701 to ensure the bar 1600-1700 gets created 2) how BR_ASSET used to work until now and
3) your own message at the beginning of this very thread on 19/02/22 11:23 AM
Quote
That would be indeed an inconsistency. - Update: Time periods usually go from start up to, but not including the end. So there is no such inconsistency,
https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=485280#Post485287
Following our argument, I changed AssetMarketEnd to +1min past market close time and used it like this in all examples/logs.

By the way, for EUR/USD, the series start shifting PAST AssetMarketStart time, unlike with SPY

[99: Tue 22-01-04 00:00] 1.12994/1.13020\1.12982/1.13020 -0.00004 opn1=1.12994,cls1=1.13020,Mark1Start=2000,mark1end=1901, market=1,susp=0,noshift=0
[100: Tue 22-01-04 00:15c] 1.13020/1.13066\1.13014/1.13064 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=0
[101: Tue 22-01-04 00:30c] 1.13064/1.13069\1.13039/1.13041 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=1
[102: Tue 22-01-04 00:45c] 1.13041/1.13055\1.13040/1.13048 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=1
[103: Tue 22-01-04 01:00c] 1.13048/1.13064\1.13040/1.13057 -0.00004 opn1=1.13020,cls1=1.13064,Mark1Start=2000,mark1end=1901, market=0,susp=8,noshift=1 < -noshift=1 here?

[104: Tue 22-01-04 01:15] 1.13057/1.13089\1.13055/1.13085 -0.00004 opn1=1.13057,cls1=1.13085,Mark1Start=2000,mark1end=1901, market=1,susp=0,noshift=0

Last edited by Zheka; 04/21/22 17:53.
Re: Precise AssetMarketStart/End [Re: Zheka] #485804
04/22/22 08:41
04/22/22 08:41
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Normally, time periods such as market hours include their begin, but not their end. Bars are a special case because their timestamp is at their end. So they include the end, but not the begin. And if time periods are negative, such as the EUR/USD in your example, their begin and end are swapped, so you got the noshift at 20:00.

I must agree that this last point is not what you would normally expect, so we will change that. As to the other issues, I'm open for suggestions as long as they only affect the new beta features and don't break existing code.

Re: Precise AssetMarketStart/End [Re: Zheka] #485805
04/22/22 10:27
04/22/22 10:27
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
So, AssetMarketEnd will follow the EndWeek convention, oder? both for BR_NOSHIFT and BR_LOCAL..?

Last edited by Zheka; 04/22/22 10:30.
Re: Precise AssetMarketStart/End [Re: Zheka] #485806
04/22/22 12:15
04/22/22 12:15
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, all time periods are treated in the same way. Only BR_NOSHIFT still shifts bars when not only the timestamp, but any part falls in market hours.

Re: Precise AssetMarketStart/End [Re: Zheka] #485807
04/22/22 12:59
04/22/22 12:59
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Sorry, this did not make it clearer.

If I want to use historical data for 930-1600 in strategy calculations AND trading be restricted to that period (i.e. BarMode=BR_NOSHIFT+BR_LOCAL+BR_LEISURE), what should AssetMarketStart/End be set to?


Last edited by Zheka; 04/22/22 13:00.
Re: Precise AssetMarketStart/End [Re: Zheka] #485808
04/22/22 15:34
04/22/22 15:34
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
If you want to exclude the 9:30 bar: 931-1600. Otherwise, 930-1600.

Re: Precise AssetMarketStart/End [Re: Zheka] #485809
04/22/22 16:06
04/22/22 16:06
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
So, bar 1600-1630 will be excluded and the last trade of the 'day' be allowed at (but not past) 1600, correct?

Re: Precise AssetMarketStart/End [Re: Zheka] #485810
04/23/22 07:55
04/23/22 07:55
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, the 16:30 bar will be excluded anyway. The 16:00 bar at the market end will be excluded from trading - remember, the market time period does not include its end - but will still shift because a part of that bar is inside market hours.

If you want to allow trading at the 16:00 market end, set AssetMarketEnd to 16:01.

I think all this is relatively easy to understand.

Re: Precise AssetMarketStart/End [Re: Zheka] #485811
04/23/22 11:09
04/23/22 11:09
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
But setting AssetMarketEnd to 1601 will then include the 1600-1630 bar (because open at 1600 will be within market hours)!?

BR_NOSHIFT and BR_LOCAL treating AssetMarketEnd differently makes them unusable together (+ BR_LEISURE) - which is the most common use case.

The market "ends" at 1600 - so i don't want to include the 1600-1630 bar into any calculations AND i would like to trade at market close, at 1600.

I understand the difference in treating time borders between bar timestamps and other 'time periods". Inconsistent, but changing might break prior code. Get that.

But BR_NOSHIFT is just a recently introduced functionality, just a flag; can be set/unset at will without any regard to legacy limitations.

PLEASE make BR_NOSHIFT AND BR_LOCAL interoperable. Or suggest a workable alternative.

Thank you!

Re: Precise AssetMarketStart/End [Re: Zheka] #485812
04/23/22 11:28
04/23/22 11:28
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
You have a point here. We will remove the special handling of BR_NOSHIFT for the next update. It will then behave like BR_LEISURE.

Re: Precise AssetMarketStart/End [Re: Zheka] #485813
04/23/22 11:44
04/23/22 11:44
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Thank you!

Re: Precise AssetMarketStart/End [Re: Zheka] #485826
04/26/22 11:49
04/26/22 11:49
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
I just tested v2.47.8 - all good.

Re: Precise AssetMarketStart/End [Re: Zheka] #486034
06/02/22 14:19
06/02/22 14:19
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
In 2.49.3 (and probably prior), BR_LOCAL+BR_LEISURE do no work in Train for closing trades:
Code
function run() {
	
	set(LOGFILE);
	NumYears=1;
	
        BarPeriod=15;
	
	BarZone=ET;
		
	StartWeek=71800;
	EndWeek=51701;
	
	set(PARAMETERS);
	
BarMode = BR_WEEKEND+BR_NOSHIFT+BR_LOCAL+BR_LEISURE;

MaxLong=-1;

	asset("EUR/USD");
		
	  AssetMarketZone=ET; 
	  AssetMarketStart = 1800;
	  AssetMarketEnd = 1701;

int i=optimize(5,5,6,1);
	
	int etTod = ltod(ET,0);
	
	if(etTod==1500) enterLong();
	
	if (etTod>AssetMarketEnd-1 and etTod<AssetMarketStart)
		exitLong();		
}
In Test, the script opens 1 trade and never closes it - as expected.

But in Train, it opens/closes 105 trades.
Quote
Parameter 1 step 1: 5.00 => 0.07 24/81
Parameter 1 step 2: 6.00 => 0.07 24/81
Selected p1[1] = +5.50 => 0.05


2) Also, the manual states for BR_LOCAL: " ...This also affects bar generation when set before the first asset call."
This doesn't seem to work:
Quote
[92: Mon 22-01-03 22:00] -0.0920 -0.0920 0/1 1.12981/1.12993\1.12969/1.12974 -0.00004
[93: Mon 22-01-03 22:30c] -0.40 -0.40 0/1 1.12975/1.12977\1.12943/1.12943 -0.00004
Can't exit [EUR/USD::L08401] outside market hours

[94: Mon 22-01-03 22:45c] -0.29 -0.29 0/1 1.12943/1.12962\1.12943/1.12954 -0.00004
Can't exit [EUR/USD::L08401] outside market hours

[95: Mon 22-01-03 23:00] -0.28 -0.28 0/1 1.12954/1.12965\1.12951/1.12955 -0.00004
[96: Mon 22-01-03 23:15] -0.0620 -0.0620 0/1 1.12955/1.12978\1.12955/1.12977 -0.00004


3) If trade closing happens to fall 'outside market hours' -what will happen in Live? Will a trade be closed at 'market open'?
If yes, it makes sense to make this consistent across Train-Test-Live. OR mention this nuance explicitly in the manual.


Please also check if BR_NOSHIFT works in Train.




Last edited by Zheka; 06/02/22 15:41.
Re: Precise AssetMarketStart/End [Re: Zheka] #486036
06/03/22 06:02
06/03/22 06:02
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
It is not very likely that BR flags do not work in training. Look in the log, there you can see why and when trades are opened.

https://zorro-project.com/manual/en/opt.htm

- BR_LOCAL does indeed not affect bar creation. The manual was wrong. And yes, in live trading the trades would be closed after the market opens.

Re: Precise AssetMarketStart/End [Re: Zheka] #486041
06/03/22 12:18
06/03/22 12:18
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Indeed, the trades are not closed 'outside market hours'; rather many are opened because MaxLong is ignored in Train.

I understand this was done on purpose to enforce good development practices; but IMHO would be better to have MaxLong work consistently by default and leave modifications for Train to the user.

Page 1 of 7 1 2 3 4 5 6 7

Moderated by  Petra 

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