RSI of average (Open+Close)/2

 

Hi,
Who is going to find the little bug in this code ?
Compiler says unexpected square bracket... beats me....
Thanks in advance..for helping this peanut brain
Dan

//+---------------------------------------------------------------------+
//| |
//| RSI of average (Open+Close)/2 . mq4 |
//| |
//+---------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 LimeGreen
#property indicator_level1 70
#property indicator_level2 30
//----
extern int MAperiod=3;
extern int RSIperiod=14;
//----
double BufPRICE[];
double BufMA[];
double BufRSI[];
//----
int init()
{
//---- indicator line
SetIndexBuffer(0,BufPRICE);
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(1,BufMA);
SetIndexStyle(1,DRAW_NONE);
SetIndexBuffer(2,BufRSI);
SetIndexStyle(2,DRAW_LINE);
return(0);
}
//----
int start()
{
ArraySetAsSeries(BufPRICE,true);
ArraySetAsSeries(BufMA,true);
int i;
for(i=0; i<Bars; i++) BufPRICE[i]= (Open[i]+ Close[i)/2;
for(i=0; i<Bars; i++) BufMA[i]=iMA(NULL,0,MAperiod,0, MODE_SMA, BufPRICE, i);
for(i=0; i<Bars; i++) BufRSI[i]=iRSIOnArray(BufMA,Bars,RSIperiod,i);
return(0);
}
//-------------------------------------------------------------------------------+

 
Daniel77 wrote >>

Hi,
Who is going to find the little bug in this code ?
Compiler says unexpected square bracket... beats me....
Thanks in advance..for helping this peanut brain
Dan

//+---------------------------------------------------------------------+
//| |
//| RSI of average (Open+Close)/2 . mq4 |
//| |
//+---------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 LimeGreen
#property indicator_level1 70
#property indicator_level2 30
//----
extern int MAperiod=3;
extern int RSIperiod=14;
//----
double BufPRICE[];
double BufMA[];
double BufRSI[];
//----
int init()
{
//---- indicator line
SetIndexBuffer(0,BufPRICE);
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(1,BufMA);
SetIndexStyle(1,DRAW_NONE);
SetIndexBuffer(2,BufRSI);
SetIndexStyle(2,DRAW_LINE);
return(0);
}
//----
int start()
{
ArraySetAsSeries(BufPRICE,true);
ArraySetAsSeries(BufMA,true);
int i;
for(i=0; i<Bars; i++) BufPRICE[i]= (Open[i]+ Close[i)/2;
for(i=0; i<Bars; i++) BufMA[i]=iMA(NULL,0,MAperiod,0, MODE_SMA, BufPRICE, i);
for(i=0; i<Bars; i++) BufRSI[i]=iRSIOnArray(BufMA,Bars,RSIperiod,i);
return(0);
}
//-------------------------------------------------------------------------------+


(Open[i]+ Close[i)/2; --> (Open[i]+ Close[i])/2;
 

Thank you, it had to be obvious.
However, the code compiles but does not draw anything.

There must be something wrong in the array section.
I would appreciate if you could have a look.
thanks again
Dan

Reason: