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

[amibroker] Detecting New Bar



PureBytes Links

Trading Reference Links

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