I have the following lines in the top of my script:
var dailyClose;
var dailyCloseSym;
var delta;
Inside main, I init one of them:
dailyCloseSym = close(sym("INTC, D"));
Then inside my main routine, I have:
dailyClose = dailyCloseSym.getValue(-1);
delta = close(0) - dailyClose;
if (delta > 0)
setBar(Bar.FgColor, 0, 3, Color.green);
else if (delta < 0)
setBar(Bar.FgColor, 0, 3, Color.red);
else
setBar(Bar.FgColor, 0, 3, Color.blue);
And then main returns delta as the 4th item in the Array.
When I use -1 as the 2nd param to setBar, the cursor window looks fine with the right coloring for delta except everything is offset by one to the left, meaning it precolors the cursor item one bar ahead of where it should.
But then if I use 0 as the bar index, the color in the cursor window stays as blue. It never changes even though delta is positive and negative as shown in the cursor window.
Why is this happening? I think I should be using zero bar index but nothing happens if I use that.
My intention is to display whether the current bar's price value is greater or less than yesterdays close.
var dailyClose;
var dailyCloseSym;
var delta;
Inside main, I init one of them:
dailyCloseSym = close(sym("INTC, D"));
Then inside my main routine, I have:
dailyClose = dailyCloseSym.getValue(-1);
delta = close(0) - dailyClose;
if (delta > 0)
setBar(Bar.FgColor, 0, 3, Color.green);
else if (delta < 0)
setBar(Bar.FgColor, 0, 3, Color.red);
else
setBar(Bar.FgColor, 0, 3, Color.blue);
And then main returns delta as the 4th item in the Array.
When I use -1 as the 2nd param to setBar, the cursor window looks fine with the right coloring for delta except everything is offset by one to the left, meaning it precolors the cursor item one bar ahead of where it should.
But then if I use 0 as the bar index, the color in the cursor window stays as blue. It never changes even though delta is positive and negative as shown in the cursor window.
Why is this happening? I think I should be using zero bar index but nothing happens if I use that.
My intention is to display whether the current bar's price value is greater or less than yesterdays close.
Comment