[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Detecting New Bar



PureBytes Links

Trading Reference Links

Thanks Herman

I was trying to eliminate use of LastValue(), but the structure you provided
should allow me to do that.
Putting it in a function is an extra bonus.

I beleive this modification should work.

> function NewBar()
> {
LastDateTimeValue = DateTime();

> PrevDateTimeNum   = StaticVarGet("DateTimeNum");
> LastDateTimeNum   = LastDateTimeValue[BarCount-1];
> StaticVarSet("DateTimeNum",LastDateTimeNum );
> return PrevDateTimeNum != LastDateTimeNum;
> }

----- Original Message ----- 
From: "Herman van den Bergen" <psytek@xxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, April 01, 2006 2:13 AM
Subject: RE: [amibroker] Detecting New Bar


> function NewBar()
> {
> PrevDateTimeNum = StaticVarGet("DateTimeNum");
> LastDateTimeNum = LastValue(DateTime());
> StaticVarSet("DateTimeNum",LastDateTimeNum );
> return PrevDateTimeNum != LastDateTimeNum;
> }
>
> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
Behalf
> Of Ara Kaloustian
> Sent: Friday, March 31, 2006 11:45 PM
> To: AB-Main
> Subject: [amibroker] Detecting New Bar
>
>
> I use the code below to detect when a new bar is started, so that I
process
> some indicators only once per bar in order to decrease CPU load.
>
> The code below uses LastValue() function (which is slow). I would like to
> replace it with Close[BarCount-1] ..., but can not quite figure out how
....
>
> My concern is that Quick AFL keeps changing the number of bars loaded as
> time goes on, so I am not sure what the impact is.
>
> Anyone see a way out?
>
> Thanks
>
> Ara
>
> //Detect New Bar
> //Variables: NewBar
> //
>
> if (IsNull(StaticVarGet("Lastbar")))
> {
> StaticVarSet("Lastbar",0);
> }
>
> //Detect New bar
> //Use to start routines at start of new bar
> //
> NewBar = False;
> if (StaticVarGet("Lastbar")!=LastValue(BarIndex()))
> {
> NewBar = True;
> StaticVarSet("Lastbar",LastValue(BarIndex()));
> }
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
>
>
>
>
> YAHOO! GROUPS LINKS
>
>  Visit your group "amibroker" on the web.
>
>  To unsubscribe from this group, send an email to:
>  amibroker-unsubscribe@xxxxxxxxxxxxxxx
>
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/