Coding error

Anthony Stephen Ajduk  

Hi,

Can anyone help with the code below. I keep getting the error messages below and cannot work out the solution.


Regards,

Anthony

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

//inputs
extern int MA_Period = 30;

//indicator buffers
double BUY[];
double SELL[];

//indicator initialization function
int init()
{
    //indicator buffers mapping
    SetIndexBuffer(0, BUY);
    SetIndexBuffer(1, SELL);
    
    //indicator line settings
    IndicatorSetString(INDICATOR_SHORTNAME,"Buy/Sell Signals");
    SetIndexStyle(0, DRAW_ARROW, EMPTY, 1);
    SetIndexArrow(0, 233);
    SetIndexStyle(1, DRAW_ARROW, EMPTY, 1);
    SetIndexArrow(1, 234);

    //name for DataWindow and indicator subwindow
    IndicatorSetString(INDICATOR_SHORTNAME,"Buy/Sell Signals");
    //initialization done
    return(0);
}

int deinit()
{
    //deinitialization done
    return(0);
}

int start()
{
    int i, counted_bars = IndicatorCounted();
    if(counted_bars < 0) return(-1);
    if(counted_bars > 0) counted_bars--;
    double prev_low, prev_close, prev_low_2, prev_close_2;
    ArrayInitialize(BUY, 0);
    ArrayInitialize(SELL, 0);
    double MA[];
    ArrayInitialize(MA, 0);
    for(i = 0; i < MA_Period; i++)
    {
        MA[i] = iMA(NULL, 0, MA_Period, 0, MODE_EMA, PRICE_CLOSE, i);
    }
    for(i = counted_bars; i >= 0; i--)
    
        prev_low = iLow(NULL, 0, i);
        prev_close = iClose(NULL, 0, i);
        prev_low_2 = iLow(NULL, 0, i+1);
        prev_close_2 = iClose(NULL, 0, i+1);
        if(prev_low > MA[i] && prev_close > MA[i] && prev_low_2 > MA[i+1] && prev_close_2 > MA[i+1] && prev_close_2 > prev_close)
            BUY[i] = prev_close;
       
        if(prev_low < MA[i] && prev_close < MA[i] && prev_low_2 < MA[i+1] && prev_close_2 < MA[i+1] && prev_close_2 < prev_close_2)
           SELL[i] = prev_close; 

Anton Ohurtsov  
Hi!
I think that you have forgotten to write closing parenthesis } in the end. Also start() should return value.
Carl Schreiber  
The error message tells you exactly which { misses its closing counterpart. Check your code where is surplus } and delete it.
Anton Ohurtsov  
Anthony Stephen Ajduk #:

Thank you,

It is now showing the following.


This is not mistake.
You can add return 0 in the end of start()