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()));
}