When I reference the previous bar in an if statement my plot stops displaying. I reduced my problem to the simplest possible example. If the current close is greater than last bar, plot the close as a green bar in a separate indicator window. If not, plot a red bar.
if(Close[0]<500) This works
if(Close[1]<500) This doesn't work
if(Close[0] > Close[1]) This doesn't work
{
UpBar.Set(Close[0]);
DwnBar.Set(0);
}
else
{
UpBar.Set(0);
DwnBar.Set(Close[0]);
}
What I am really trying to do is color the volume bars in accord with Bill Williams' Profitunity Windows. I set up a dataseries bwMFI. There are four conditions based on whether bwMFI and volume are lower or higher than previous bar and thus four colors.
If I use dummy variables in my if statements everything works fine. When I use bwMFi[1] or Volume[1] in the if statements the plots stop displaying.
I would appreciate it if someone could give me a clue as to the problem.
Comment