|
Precise AssetMarketStart/End
#485280
02/16/22 13:47
02/16/22 13:47
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
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
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
When using several assets: 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: [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]
#485302
02/19/22 17:44
02/19/22 17:44
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
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: 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: [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
Zheka
OP
User
|
OP
User
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
Support
|
Support
Joined: Apr 2008
Posts: 585
Austria
|
|
|
|
Re: Precise AssetMarketStart/End
[Re: Zheka]
#485522
03/19/22 11:07
03/19/22 11:07
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
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]
#485529
03/19/22 14:28
03/19/22 14:28
|
Joined: Sep 2003
Posts: 929
Spirit
Moderator
|
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: Spirit]
#485532
03/19/22 17:54
03/19/22 17:54
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
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: jcl]
#485638
04/05/22 14:25
04/05/22 14:25
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
"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). 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]
#485665
04/11/22 10:34
04/11/22 10:34
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
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. 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]
#485694
04/14/22 12:05
04/14/22 12:05
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
Both entry and expiry occur outside of market hrs (930-1601 WET). [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
Zheka
OP
User
|
OP
User
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): 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: [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]
#485710
04/16/22 12:25
04/16/22 12:25
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
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]
#485759
04/19/22 11:14
04/19/22 11:14
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
Maybe yes - maybe no...log knows [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]
#485771
04/20/22 16:28
04/20/22 16:28
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
I just tested the new version and found several problems, but let's take it one by one. 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: [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]
#485786
04/21/22 14:10
04/21/22 14:10
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
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: jcl]
#485792
04/21/22 15:42
04/21/22 15:42
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
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]
#485800
04/21/22 17:47
04/21/22 17:47
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
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 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
Chief Engineer
|
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
Zheka
OP
User
|
OP
User
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]
#485807
04/22/22 12:59
04/22/22 12:59
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
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]
#485813
04/23/22 11:44
04/23/22 11:44
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
|
|
|
Re: Precise AssetMarketStart/End
[Re: Zheka]
#486034
06/02/22 14:19
06/02/22 14:19
|
Joined: Jul 2017
Posts: 783
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 783
|
In 2.49.3 (and probably prior), BR_LOCAL+BR_LEISURE do no work in Train for closing trades: 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. 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: [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.
|
|
|
|