I want to accumulated a static variable but only once per bar. My problem is that it gets re-added on every tick when I only want to run the calculation once per bar on the very first tick.
A user on another forum posted this solution:
if(myTime != Time[0])
{
//do what you want to be done once after openning new bar
myTime = Time[0];
}
But I'm finding it works is some situations but not all and I can't find the reason for the discrepancy. Anyone know of a better way of doing this?
A user on another forum posted this solution:
if(myTime != Time[0])
{
//do what you want to be done once after openning new bar
myTime = Time[0];
}
But I'm finding it works is some situations but not all and I can't find the reason for the discrepancy. Anyone know of a better way of doing this?