What have I missed...

To add comments, please log in or register
Donald Johnston
32
Donald Johnston  

Just as I thought I was getting a small grasp of MetaTrader. The 'stochsig' array is displayed in the indicator window and in the data window. The 'upbar' and 'dnbar' arrays are not displayed in either window. Data is being entered into the arrays as evidenced by the print statements as the data is processed. Thank you for your guidance.


#property indicator_separate_window

#property indicator_color1 Yellow
#property indicator_color2 Green
#property indicator_color3 Red

extern int StochPeriod1=14;
extern int DPeriod1=3;
extern int SlowingPeriod1=3;

double stochsig[];
double upbar[];
double dnbar[];

int init()
{
IndicatorBuffers(3);

SetIndexBuffer(0,stochsig);
SetIndexLabel(0,"StochSig");
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);

SetIndexBuffer(1,upbar);
SetIndexLabel(1,"UpBar");
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID); //upbar
SetIndexEmptyValue(1,EMPTY_VALUE);

SetIndexBuffer(2,dnbar);
SetIndexLabel(2,"DnBar");
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID); //dnbar
SetIndexEmptyValue(2,EMPTY_VALUE);

return(0);
}

int deinit()
{
return(0);
}

int start()
{
int counted_bars=IndicatorCounted();
int shift,limit;
limit=Bars-31;

IndicatorShortName("StochHist ("+StochPeriod1+","+DPeriod1+","+SlowingPeriod1+")");

if(counted_bars>=31) limit=Bars-counted_bars-1;
for (shift=limit;shift>=0;shift--)
{
stochsig[shift]=iStochastic(NULL,0,StochPeriod1,DPeriod1,SlowingPeriod1,MODE_SMA,0,MODE_MAIN,shift)-50;
if(stochsig[shift]>0)
{
upbar[shift]=stochsig[shift]; //green bars
Print("upbar..."+upbar[shift]);
}
else
if (stochsig[shift]<0)
{
dnbar[shift]=stochsig[shift]; //red bars
Print("dnbar..."+dnbar[shift]);
}
}
return(0);
}
Mykola Bilak
585
Mykola Bilak  
misses #property indicator_buffers 3 at the top of code
Donald Johnston
32
Donald Johnston  
nickbilak:
misses #property indicator_buffers 3 at the top of code

Thank you.

To add comments, please log in or register