Assume two indicators, A and B.
A is like: OnBarUpdate() {Value[0] = B()[0];}
B is like: OnBarUpdate()
{
if ((CurrentBar == 8) && (InterestingBar == 5))
{
Value[2] = -1; // Here I do "back to the future" !!!
Value[0] = Value[1];
InterestingBar = 0;
}
else
{
Value[0] = 1;
}
}
InterestingBar is private int at B.
At a first glance, it is easy to think that indicator A always will generate the same result as indicator B. But it doesn’t (and I understand why). See attached image.
It is no problem to find out what is wrong in my example, but if you have a whole chain of indicators, ”errors” like this might be very difficult to find.
The conclusion is that an NT object, will have a different state (values of local variables) depending on when the object is executed, but with the same value of CurrentBar. Is this the design, or is it a bug?
If not a bug!
What are the NT-recommendations if it is absolutely necessary to something like Values[2]; (this will occur if you are doing statistic analyses of bar-data, rather than a future prediction)?
Thank you, AndBro
P.S: Of course, you should never “look back” (ie Value[2]) in an indicator, because that is the same as “looking” in to the future and telling the result today.
Comment