Maybe this is really basic but I’m scratching my head. I’m trying to do things in map() with respect to the ongoing price-bar but it seems to be executing non-chronologically. Here is an example:
init()
this.currentIndex = -1;
map(d, i)
console.log ("Old current index: " + this.currentIndex);
if (i > this.currentIndex) { this.currentIndex = i; }
console.log ("New current index: " + this.currentIndex);
When this executes, I’ll get something like the following:
Old current index: -1
New current index: 300
Old current index: -1
New current index: 300
…
Old current index: 300
New current index: 301
Old current index: 300
New current index: 301
In other words, it’s updating current index, but then when it executes again, it’s reverted back to it’s previous value.
Here is another example:
init ()
this.flagOnce = false;
map(d, i)
if (!this.flagOnce) {
this.flagOnce = true;
Console.log (“should only log once”);
}
Yet this will print multiple lines to the console of “should only log once”.
Is map executing out of sequence? In parallel? Pardon me if these are newbie questions. Anything I can do about this?