PureBytes Links
Trading Reference Links
|
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
<*> 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/
|