The start time must be earlier than the end time. You could work around the problem by selecting a different time zone where this is the case. Alternatively, set TimeFrame directly for skipping the hour at 17:00.
Re: Market hours for Globex
[Re: jcl]
#470358 01/09/1820:4301/09/1820:43
It is not clear what you want to do. Do you want to skip bars outside market hours, or do you want not to trade outside market hours?
If you want to skip bars, then do not change StartMarket and EndMarket, or else you will of course get strange results when you do that in the middle of a frame. If you just want not to trade, then do not set TimeFrame, since that skips bars.
All about skipping bars and using TimeFrame can be read here: http://manual.zorro-project.com/barperiod.htm. You can skip any time period on any market condition that you want when you understood the mechanism.
Re: Market hours for Globex
[Re: jcl]
#470371 01/10/1816:2701/10/1816:27
JCL, I want to correctly construct bars and higher "timeframe" bars - this feeds all system calculations.
For a portfolio of systems with different bar periods, I need to set the BarPeriod to the "largest common divisor" of all systems and simulate the needed ones with timeframes. All my systems also need a secondary time frame (daily) in their calculations.
Now, for FX (IB), there are M1 bars from 1715 to 1700 ET, but I only want to base my calculations on data from 1716 to 1645(-58) ET.
After 2.5 days of trying, I am still unable to achieve what I want:
1) TF>1 just counts *TF number of bars*. But because there are no M1 bars from 1700-1715 and because there is a bug with Weekend>2+ (it still creates a weekend bar) - all Frames get continuously shifted and are incorrect.
Also, there is still a bug with StartWeek: with Weekend=2-3, setting StartWeek<2200 does not work - week starts from 2200+ in any case
2) BarPeriod=5 - frameSync(4) almost works. But there is an unneeded frame ending 1716 which covers 1656-1716. Skipping bars to avoid is not helping - frameSync somehow behaves unpredictably..
3) AssetFrame requires setting BarPeriod=desired TF, but can be suitable. But AssetFrame doesnt work as expected. Start/EndMarket are just variables and changing them is ok and practically works. Please review my previous message.
4) "Skipping bars mechanism does not work as intended
- Skipping bars only works when TF=1(BarPeriod). Higher TF do not work in practice - see p1, nor using frameSync - see p2.
- there is a key bug with frame formation. Open/highs/lows of skipped bars are not really skipped, still counted in the veeery long TF. Please, answer my other post.
- most importantly and critically, setting a TF to a negative value after skipping bars technically creates a new frame (frame(0)=1). which has open= close of previous frame (current,incorrect) or open of 'TimeFrame' minutes ago (correct) close=current bar close; High/Low = within the period from Open to close;
What shall one do with this extra Frame which covers unneeded hours? How can it be skipped?
May I suggest that setting TimeFrame to a negative number just starts the Frame and at this moment frame(0) returns 0?
Daily TF. Assuming there are M1 data 24/5, what's the way to construct a series of *Daily* bars (as a secondary TF in a system with BarPeriod=5) which only cover Regular Trading Hours, say, from 8:30 to 15:30ET?
Your advise is highly appreciated.
Re: Market hours for Globex
[Re: Zheka]
#470387 01/11/1812:0101/11/1812:01
Ok. For avoiding a complete confusion with your multitude of issues in as many threads, let's systematically address your problems one after the other, starting here with the first one.
>>1) TF>1 just counts *TF number of bars*. <<
Right.
>>But because there are no M1 bars from 1700-1715 and because there is a bug with Weekend>2+ (it still creates a weekend bar) - all Frames get continuously shifted and are incorrect.<<
Can you explain that "bug with Weekend>2+", possibly with a reproducible example?
Re: Market hours for Globex
[Re: jcl]
#470400 01/11/1816:5001/11/1816:50
[1860: Sun 16-05-15 22:01] (122.87)n FrameOffset: 0, timeFrame=1 ET Time=1801, O= 122.82400, C= 122.87300
[1861: Sun 16-05-15 22:06] (122.85)n FrameOffset: 0, timeFrame=1 ET Time=1806, O= 122.84600, C= 122.84700
1) StartWeek with Weekend=2 keeps its default value of 2200.
2) There is indeed no extra weekend bar; must have been fixed in the new ver.
3) It will be very useful to have StartWeek/EndWeek precision down to a minute. Why not?
There needs to be an ability to "end the week" at the desired time: close all bars/timeframes at that time, not generate any bars nor timeframes during the weekend, and similarly start the week at StartWeek (start the first bar at StartWeek) Would it be possible to add such a mode to Weekend?
Together with StartMarket/EndMarket, this would help emulate the concept of "Sessions" commonly used in other software.
Re: Market hours for Globex
[Re: Zheka]
#470405 01/12/1810:1901/12/1810:19
The duration of a 5 minutes bar is 5 minutes. If it's weekend or if the history contains no prices, the bar ends at the next multiple of 5 minutes. I think for most users this is not very surprising. Nothing wrong with StartWeek. If you want a bar to start at a particular minute, use either 1 minutes bars, or a bar offset. For doing something exactly at market open, I would not tamper with bars anyway, but just compare the time.
Your next issue: >>BarPeriod=5 - frameSync(4) almost works.<<
This works not almost, it works not at all. frameSync() is for synchronizing to full hours. frameSync(4) is not a full hour. frameSync(12) would be a full hour. Again the manual is your friend: http://manual.zorro-project.com/frame.htm
Re: Market hours for Globex
[Re: jcl]
#470406 01/12/1812:0201/12/1812:02
The script sets StartWeek to 2000. The M1 bars are available from 2115 and Weekend=1 shows that. Why with Weekend=2 the first bar on Sunday is 2201? And not 2116 or 2121?
Re: Market hours for Globex
[Re: Zheka]
#470409 01/12/1813:1301/12/1813:13
I suppose because there are no prices before 2201. Check that with the history editor from the download page. If it has prices at 2115, you should normally be able to start the week at 2115. But if not, you can upload the historical data here and I'll look into the problem.
Re: Market hours for Globex
[Re: jcl]
#470414 01/12/1817:1801/12/1817:18
Thanks! If missing prices are not the reason, then it's possibly some limit to the earliest week start. I'll inquire. - Update: I learned the weekend has indeed a 2 days 'core' from Friday 22:00 til Sunday 22:00. It can be made longer, but not shorter than those 2 days. And yes, this limit can be probably removed in a future version. Setting up the weekend is the user's responsibility, so there's no real reason for a limit.
Re: Market hours for Globex
[Re: jcl]
#470471 01/16/1816:1201/16/1816:12
Skipping bars only works when TF=1(BarPeriod). Higher TF do not work in practice
If BarPeriod=5 and desired trading TF is 20min (i.e. TF=4), then outside of "market hours": - bars are skipped with TF=0, - TF set to -N at start of a new frame, and then.... -...TF is to be set to what value?
Or do you suggest to construct each and every frame manually by checking the time?
Quote:
Open/highs/lows of skipped bars are not really skipped, still counted in the veeery long TF. - That's the very purpose of a time frame
I want to trade during "market hours" and I want to use a series of bars/frames that will ONLY contain information from that period.
I do not want to include in such a 20-min series an irregular, oversized frame that covers the "overnight/overweekend" period.
Is that a fair paradigm and expectation?
Re: Market hours for Globex
[Re: Zheka]
#470489 01/17/1813:3901/17/1813:39
>>I want to trade during "market hours" and I want to use a series of bars/frames that will ONLY contain information from that period.<<
What are you then doing with timeframes? If you only want to completely ignore bars outside market hours, then simply do not use their prices for your indicators and do not trade at that time.
Maybe the problem is some misconception of bars and time frames. I do not know what you want to achieve, but when you explain in more detail when and under what conditions you want to enter which trades, I can probably help better.
Re: Market hours for Globex
[Re: jcl]
#470494 01/17/1815:0201/17/1815:02
..TF is to be set to what value? For skipping 4 bars, how about the value 4?
Setting TF=4 will not produce correct frames - because TF just counts bars and lands at each TFx bar , regardless if it has been skipped or not. So, for a Globex session ending 17:00 ET and starting 18:00 ET.
And no amount of tinkering will solve this with a current built-in mechanism.
Quote:
If you only want to completely ignore bars outside market hours, then simply do not use their prices for your indicators
Yes, I want to completely ignore prices outside market hours. How can I construct a series of 20min bars(or frames) that would ONLY contain prices within the defined "session"?
In general, ALL other software I worked with -TS,MC,NT,SC,WL,MT5- have "sessions" as a basic concept ( most- per day), and bar construction is governed by session start/end settings. Porting working, tested systems to Zorro, I would like to achieve 100% consistency.
Re: Market hours for Globex
[Re: Zheka]
#470498 01/17/1815:4601/17/1815:46
It just hit me that Skipped bars define the start of the frame! It is not at all necessary to set TF=Skipped bars after skipping bars - as one is conditioned by the manual. You can set it to the number of bars(negative) back you really need the frame to span and that would only merge that number of bars! Urahh!
This explanation should be added to the manual!
One more question re bar() function: - can you please give an example in the manual how Start and Time fields can be used? - is it possible to add a return option that would "not start a bar"
Thank you.
Re: Market hours for Globex
[Re: Zheka]
#470512 01/17/1818:1401/17/1818:14
I also think it would be better if a Frame had been calculated by Zorro internally by the number of minutes, not the number of bars. Bars can be absent for some reason in the historical data or in RT, but that should not be shifting frames..
Yes, one can code around this situation, but why would not Zorro take care of it by default?
Re: Market hours for Globex
[Re: Zheka]
#470523 01/18/1814:3801/18/1814:38
I have no example of special bars that use Start and Time. For not starting a bar, return 4. - It's the same as with most software libraries: What's often used is the default, what's rare or unusual must be explicitely coded.
Re: Market hours for Globex
[Re: jcl]
#470525 01/18/1815:1101/18/1815:11
Ensuring that the Timeframe always covers the intended period is on the side of "proofing" and "making the functionality more robust", rather than a "special request", I believe.
Re: Market hours for Globex
[Re: Zheka]
#470527 01/18/1816:1301/18/1816:13
It turns out, priceOpen will be equal to an open of the previously set TimeFrame bars ago. E.g. if the usual/previous TF=4 and currently we are skipping bars (TimeFrame=0), then priceOpen()=Open[4].