My indicator won't show on my charts I tried everything. I also don't know if "return false; is correct at the end

 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime    // Swing High color
#property indicator_color2 Red     // Swing Low color

extern int lookbackBars = 10;  // Number of bars to look back for swing high/low identification

double swingHighBuffer[];
double swingLowBuffer[];

int CustomIndicatorCounted()
{
    return Bars - lookbackBars;
}

int OnCalculate(
   const int           rates_total, 
   const int           prev_calculated, 
   const datetime      &time[],
   const double        &open[], 
   const double        &high[], 
   const double        &low[], 
   const double        &close[],
   const long          &tick_volume[], 
   const long          &volume[],
   const int           &spread[]
   )
{
    int limit = rates_total - lookbackBars;

    if (prev_calculated > 0)
        limit--;

    for (int i = limit; i >= 0; i--)
    {
        double highPrice = high[i];
        double lowPrice = low[i];

        bool isSwingHigh = true;
        bool isSwingLow = true;

        for (int j = 1; j <= lookbackBars; j++)
        {
            if (high[i + j] >= highPrice || low[i + j] <= lowPrice)
            {
                isSwingHigh = false;
                isSwingLow = false;
                break;
            }
        }

        if (isSwingHigh)
        {
            for (int k = 1; k <= lookbackBars; k++)
            {
                if (high[i - k] >= highPrice || high[i + k] >= highPrice)
                {
                    isSwingHigh = false;
                    break;
                }
            }

            if (isSwingHigh)
            {
                swingHighBuffer[i] = highPrice;
                swingLowBuffer[i] = EMPTY_VALUE;
            }
            else
            {
                swingHighBuffer[i] = EMPTY_VALUE;
                swingLowBuffer[i] = EMPTY_VALUE;
            }
        }
            else if (isSwingLow)
        {
            for (int l = 1; l <= lookbackBars; l++)
            {
                if (low[i - l] <= lowPrice || low[i + l] <= lowPrice)
                {
                    isSwingLow = false;
                    break;
                }
            }

            if (isSwingLow)
            {
                swingHighBuffer[i] = EMPTY_VALUE;
                swingLowBuffer[i] = lowPrice;
            }
            else
            {
                swingHighBuffer[i] = EMPTY_VALUE;
                swingLowBuffer[i] = EMPTY_VALUE;
            }
        }
        else
        {
            swingHighBuffer[i] = EMPTY_VALUE;
            swingLowBuffer[i] = EMPTY_VALUE;
        }
    }
    return false;
}


 
  1. Zee Al:

    You posted no question. Title does not count.

  2. int OnCalculate(…   )
    {
        ⋮
                swingHighBuffer[i] = EMPTY_VALUE;
                swingLowBuffer[i] = EMPTY_VALUE;
            }
        }
        return false;
    }

    The function returns an int, not a bool.
              How to do your lookbacks correctly #9#14 & #19 (2016)

  3.         double highPrice = high[i];
            double lowPrice = low[i]

    In MT4, buffers and MT4 predefined arrays are all ordered AsSeries. There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the MT4 predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.

    To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

Reason: