Can't draw buffer

 

I have looked around, but cannot find quite the same problem elsewhere. If it does exist, please point me there...

I am attempting to create a custom indicator which will return 3 possible values in a histogram:

1 - when I should be long

0 - when I should be out

-1 - when I should be short.

I have started this, but cannot get a value printed/painted to the indicator window...

But as soon as i write a Close[i] to buffer, then it works... I do not get this.

Here is my code. Comment out the //val = Close[i]; line to see it working

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver

double Buffer1[];

int init()
{
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
SetIndexDrawBegin(0,0);
IndicatorDigits(Digits+2);
SetIndexBuffer(0,Buffer1);
IndicatorShortName("Test Indicator");

return(0);
}


int start()
{
int i,counted_bars=IndicatorCounted();
double direction;

ArraySetAsSeries(Buffer1,true);

double val;

i=Bars-counted_bars-1;
while(i>=0)
{
val = 1.0; //this line causes the consternation
//val = Close[i]; //comment this out to see it working..

Buffer1[i]=val;
i--;
}

return(0);
}

Reason: