Yes, using the method presented below, new bar needs to be started (i.e. trade 
tick belonging to next bar needs to arrive)


Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Barry Scarborough" <[email protected]>
To: <[email protected]>
Sent: Wednesday, March 18, 2009 2:40 PM
Subject: [amibroker] Re: Testing for new bar using string manipulation and 
quotation time


> Isn't it true that the new bar does not officially start until the first tick 
> comes in? That makes sense since the open is the 
> value of the first tick that arrives and there is no guarantee it will arrive 
> exactly on the second. This can be right on, a few 
> seconds into the bar or 20 or not at all.  I am not sure what happens if no 
> tick arrives during a bar. Does AB simply create a new 
> bar with the close of the previous bar carried forward as the OHLC?
>
> I traced TimeNum and the bar time does not change until the tick comes in. It 
> did not seem to matter what the Time stamp in 
> preferences is set to. So in that sense it is in sync with the market. 
> Whenever the first tick arrives the bar opens, you get the 
> open price and it is in sync with the market.
>
> Barry
>
> --- In [email protected], "Tomasz Janeczko" <gro...@...> wrote:
>>
>> Hello,
>>
>> 0. Change the refresh interval to zero
>> 1. Yes
>> 2. Thats because of 3 second refresh interval you had, (see 0.)
>>
>> Best regards,
>> Tomasz Janeczko
>> amibroker.com
>> ----- Original Message ----- 
>> From: "ozzyapeman" <zoopf...@...>
>> To: <[email protected]>
>> Sent: Wednesday, March 18, 2009 12:16 AM
>> Subject: [amibroker] Re: Testing for new bar using string manipulation and 
>> quotation time
>>
>>
>> >I should add that I have Realtime chart refresh interval(sec) set to 3.
>> >
>> >
>> > --- In [email protected], "ozzyapeman" <zoopfree@> wrote:
>> >>
>> >> A couple of more questions, as I am still running into some issues:
>> >>
>> >> 1. In Tools --> Preferences --> Intraday,   I used to have "time of last 
>> >> tick inside bar" checked off. I have now unchecked 
>> >> that
>> >> and instead checked "START time of interval". Question is: will this 
>> >> retroactively correct all past bars in the database to
>> >> reflect the new settings? Or will only new bars coming into the database 
>> >> reflect the new time stamp settings?
>> >>
>> >>
>> >> 2. I have my System Time properly calibrated so that it matches Market 
>> >> Time in TWS to within a fraction of a second. Yet my AB
>> >> chart sometimes shows a new bar starting within 2-5 seconds after 
>> >> HH:MM:00 Market Time, and yet other times it shows a new bar
>> >> starting as late as 20-30 seconds after HH:MM:00 Market Time. It's a 
>> >> mixed bag, and alternates every now and then without
>> >> apparent cause. And this affects trade timing as well.
>> >>    So how do I get the chart (and trades) to properly synch up with 
>> >> Market Time? What am I still missing?
>> >>
>> >>
>> >>
>> >>
>> >> --- In [email protected], "ozzyapeman" <zoopfree@> wrote:
>> >> >
>> >> > Thanks for all the feedback, guys. It's been very helpful!
>> >> >
>> >> >
>> >> > --- In [email protected], "Barry Scarborough" <razzbarry@> 
>> >> > wrote:
>> >> > >
>> >> > > This is a little simpler than the similar approach I mentioned a few 
>> >> > > posts earlier. In my trading program I have an
>> >> > > initialization function and I set the lastValue of timeNum in the 
>> >> > > static var to the current bar on the first pass through 
>> >> > > the
>> >> > > code. That way NewBar will not be true on the first scan through the 
>> >> > > code and that prevents it from being true mid bar, 
>> >> > > which
>> >> > > it will in the way Tomasz and I proposed. It will wait until the next 
>> >> > > bar after AB starts. That may or may not matter to 
>> >> > > you.
>> >> > >
>> >> > > Barry
>> >> > >
>> >> > >  --- In [email protected], "Tomasz Janeczko" <groups@> wrote:
>> >> > > >
>> >> > > > There is much easier and reliable method:
>> >> > > >
>> >> > > > dt = LastValue( DateTime() );
>> >> > > >
>> >> > > > if( StaticVarGet( "lastdt" ) != dt )
>> >> > > > {
>> >> > > >   _TRACE("New bar");
>> >> > > >   StaticVarSet("lastdt", dt );
>> >> > > > }
>> >> > > >
>> >> > > > (Note that it works only if Tools->Preferences->Intraday is set
>> >> > > > to show START or END time of interval).
>> >> > > >
>> >> > > > Best regards,
>> >> > > > Tomasz Janeczko
>> >> > > > amibroker.com
>> >> > > > ----- Original Message ----- 
>> >> > > > From: "Yofa" <jtoth100@>
>> >> > > > To: <[email protected]>
>> >> > > > Sent: Tuesday, March 17, 2009 1:03 PM
>> >> > > > Subject: Re: [amibroker] Re: Testing for new bar using string 
>> >> > > > manipulation and quotation time
>> >> > > >
>> >> > > >
>> >> > > > > Hi,
>> >> > > > >
>> >> > > > > barTime % 100 == 0 will not work reliably! If there is no new 
>> >> > > > > tick or no CPU
>> >> > > > > time to do refresh it will skipp new bars a few times!
>> >> > > > > This is a common problem. Look for similar posts here. You will 
>> >> > > > > fined code
>> >> > > > > samples.
>> >> > > > >
>> >> > > > > Y
>> >> > > > > --------------------------------------------------
>> >> > > > > From: "Mike" <sfclimbers@>
>> >> > > > > Sent: Tuesday, March 17, 2009 4:04 AM
>> >> > > > > To: <[email protected]>
>> >> > > > > Subject: [amibroker] Re: Testing for new bar using string 
>> >> > > > > manipulation and
>> >> > > > > quotation time
>> >> > > > >
>> >> > > > >> If you have any concerns about rounding, you could use 
>> >> > > > >> AlmostEqual instead
>> >> > > > >> of "==".
>> >> > > > >>
>> >> > > > >> http://www.amibroker.com/guide/afl/afl_view.php?id=301
>> >> > > > >>
>> >> > > > >> Mike
>> >> > > > >>
>> >> > > > >> --- In [email protected], "ozzyapeman" <zoopfree@> wrote:
>> >> > > > >>>
>> >> > > > >>> Thanks a bunch, Mike. Modulo's so much simpler!
>> >> > > > >>>
>> >> > > > >>>
>> >> > > > >>> --- In [email protected], "Mike" <sfclimbers@> wrote:
>> >> > > > >>> >
>> >> > > > >>> > Again, assuming that your approach is sound, better still 
>> >> > > > >>> > would be to
>> >> > > > >>> > use the modulo operator.
>> >> > > > >>> >
>> >> > > > >>> > barTime = 103731;
>> >> > > > >>> >
>> >> > > > >>> > if (barTime % 100 == 0)
>> >> > > > >>> >   _TRACE( "New bar found" );
>> >> > > > >>> >
>> >> > > > >>> > Mike
>> >> > > > >>> >
>> >> > > > >>> > --- In [email protected], "Mike" <sfclimbers@> wrote:
>> >> > > > >>> > >
>> >> > > > >>> > > Without commenting on the validity of the approach (I am 
>> >> > > > >>> > > not a real
>> >> > > > >>> > > time trader), I can suggest that your problem is coming 
>> >> > > > >>> > > from a
>> >> > > > >>> > > formatting incompatibility.
>> >> > > > >>> > >
>> >> > > > >>> > > Add a format clause indicating zero decimal places and it 
>> >> > > > >>> > > will work
>> >> > > > >>> > > fine.
>> >> > > > >>> > >
>> >> > > > >>> > > Note too that your switching back to a number again is 
>> >> > > > >>> > > redundant and
>> >> > > > >>> > > even error prone since "==" is not necessarily exact when 
>> >> > > > >>> > > dealing
>> >> > > > >>> > > with floats. Just use the string manipulation directly.
>> >> > > > >>> > >
>> >> > > > >>> > > barTime       = 103731;
>> >> > > > >>> > > barTimeStr    = NumToStr( barTime, 6.0 );
>> >> > > > >>> > >
>> >> > > > >>> > > if ( StrRight( barTimeStr, 2 ) == "00" )
>> >> > > > >>> > >     _TRACE ( "New bar found" );
>> >> > > > >>> > >
>> >> > > > >>> > > Mike
>> >> > > > >>> > >
>> >> > > > >>> > > --- In [email protected], "ozzyapeman" <zoopfree@> 
>> >> > > > >>> > > wrote:
>> >> > > > >>> > > >
>> >> > > > >>> > > > Hello, hoping someone can help out with this string 
>> >> > > > >>> > > > conversion
>> >> > > > >>> > > > problem.
>> >> > > > >>> > > >
>> >> > > > >>> > > > In live trading, I am pulling quotation time using 
>> >> > > > >>> > > > TimeNum(), and
>> >> > > > >>> > > > want
>> >> > > > >>> > > > to test for the start of a new bar. So my thinking is to 
>> >> > > > >>> > > > simply
>> >> > > > >>> > > > convert
>> >> > > > >>> > > > the time to a number, extract the last two characters, 
>> >> > > > >>> > > > convert back
>> >> > > > >>> > > > to a
>> >> > > > >>> > > > number and see if it equals 0. If so, that means the last 
>> >> > > > >>> > > > two
>> >> > > > >>> > > > digits in
>> >> > > > >>> > > > the quotation time are "00" and hence we are at the start 
>> >> > > > >>> > > > of a new
>> >> > > > >>> > > > bar.
>> >> > > > >>> > > >
>> >> > > > >>> > > > However, the sample code below is always thinking we have 
>> >> > > > >>> > > > a new bar
>> >> > > > >>> > > > whether the time is, for e.g.  :
>> >> > > > >>> > > >
>> >> > > > >>> > > > 10:37:31   or
>> >> > > > >>> > > > 10:37:00
>> >> > > > >>> > > >
>> >> > > > >>> > > >   Obviously, only the second time should trip the 'new 
>> >> > > > >>> > > > bar' print.
>> >> > > > >>> > > > But
>> >> > > > >>> > > > instead, both do:
>> >> > > > >>> > > >
>> >> > > > >>> > > >
>> >> > > > >>> > > > barTime       = 103731;  // we would normally use 
>> >> > > > >>> > > > TimeNum() here,
>> >> > > > >>> > > > but
>> >> > > > >>> > > > using a number for example
>> >> > > > >>> > > >
>> >> > > > >>> > > > barTimeStr    = NumToStr(barTime);
>> >> > > > >>> > > >
>> >> > > > >>> > > > NewBarSeconds = StrToNum ( StrRight(barTimeStr, 2) );
>> >> > > > >>> > > >
>> >> > > > >>> > > > printf("NewBarSeconds = " + NewBarSeconds);
>> >> > > > >>> > > >
>> >> > > > >>> > > > if (NewBarSeconds == 0)
>> >> > > > >>> > > >
>> >> > > > >>> > > > printf("    We have a new bar");
>> >> > > > >>> > > >
>> >> > > > >>> > >
>> >> > > > >>> >
>> >> > > > >>>
>> >> > > > >>
>> >> > > > >>
>> >> > > > >>
>> >> > > > >>
>> >> > > > >> ------------------------------------
>> >> > > > >>
>> >> > > > >> **** IMPORTANT PLEASE READ ****
>> >> > > > >> This group is for the discussion between users only.
>> >> > > > >> This is *NOT* technical support channel.
>> >> > > > >>
>> >> > > > >> TO GET TECHNICAL SUPPORT send an e-mail directly to
>> >> > > > >> SUPPORT {at} amibroker.com
>> >> > > > >>
>> >> > > > >> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> >> > > > >> http://www.amibroker.com/feedback/
>> >> > > > >> (submissions sent via other channels won't be considered)
>> >> > > > >>
>> >> > > > >> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> >> > > > >> http://www.amibroker.com/devlog/
>> >> > > > >>
>> >> > > > >> Yahoo! Groups Links
>> >> > > > >>
>> >> > > > >>
>> >> > > > >>
>> >> > > > >>
>> >> > > > >
>> >> > > > >
>> >> > > > > ------------------------------------
>> >> > > > >
>> >> > > > > **** IMPORTANT PLEASE READ ****
>> >> > > > > This group is for the discussion between users only.
>> >> > > > > This is *NOT* technical support channel.
>> >> > > > >
>> >> > > > > TO GET TECHNICAL SUPPORT send an e-mail directly to
>> >> > > > > SUPPORT {at} amibroker.com
>> >> > > > >
>> >> > > > > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> >> > > > > http://www.amibroker.com/feedback/
>> >> > > > > (submissions sent via other channels won't be considered)
>> >> > > > >
>> >> > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> >> > > > > http://www.amibroker.com/devlog/
>> >> > > > >
>> >> > > > > Yahoo! Groups Links
>> >> > > > >
>> >> > > > >
>> >> > > > >
>> >> > > >
>> >> > >
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > **** IMPORTANT PLEASE READ ****
>> > This group is for the discussion between users only.
>> > This is *NOT* technical support channel.
>> >
>> > TO GET TECHNICAL SUPPORT send an e-mail directly to
>> > SUPPORT {at} amibroker.com
>> >
>> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> > http://www.amibroker.com/feedback/
>> > (submissions sent via other channels won't be considered)
>> >
>> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> > http://www.amibroker.com/devlog/
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>>
>
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>

Reply via email to