'Some operator expected' Compilation Error.

 
//+------------------------------------------------------------------+
//|                                        PivotHighLowIndicator.mq4 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 Blue

double highs[];  
double lows [];

double shighs[];

int fopht [1];
int fophp [1];
int arraysize = ArraySize(fophp);

bool isfoph;

int barnumber;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,highs);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0, 159);
   SetIndexBuffer(1,lows);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1, 159);   
   
   SetIndexBuffer(2, shighs);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, 159);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---
arraysize = ArraySize(fophp);

int limit = rates_total-prev_calculated;
for(int i=1;limit;i++)
   {
   isfoph = False;                      // Set the first order pivot bool to false.
   
if (High[i+1]>High[i]
   && High[i+1]>High[i+2])
   {
   highs[i+1]=High[i+1];                //Display a dot above all first order pivots.
   isfoph= True;
   }

if (isfoph = True
    && fophp[arraysize-1] != High[2])   // If the last candle is a first order pivot
   {                                    // and the high isn't equal to the last fophp.
   ArrayResize(fophp, arraysize+1);     // Add an index to the foph arrays.
   ArrayResize(fopht, arraysize+1);
   fophp[arraysize+1] = High[2];        // Assign first order pivot price to last array element.
   fopht[arraysize+1] = Time[2];        // Assign firstorderpivot open time to last array element.  
   }
   
if (fophp[arraysize]>fophp[arraysize+1]   //If the last element of the array is less than the penultimate,
   && fophp[arraysize]>fophp[arraysize-1]) // and the penultimate is more than the one before it.
   {
   barnumber = iBarShift(NULL,0,fopht[arraysize])  //set barnumber to based on the last time in the fopht array.
   shighs[barnumber] = High[barnumber]+0.0005;     //draw an arrow over the bar defined by bar number at the high
   }                                               // of that bar + 5 pips.
   
   
if (Low[i+1]<Low[i]
   &&Low[i+1]<Low[i+2])
   lows[i+1]=Low[i+1];
   
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+



I am trying to make an indicator that will:

1. plot a dot above all highs that are higher than the preceding and following high. A so called 'first order high'

2. Plot another dot above any 'first order high' that is higher than the preceding and following 'first order highs'. 


I have managed the first task, but I am struggling with the second. 

I am given 'shighs' - some operator expected. line 91 Error in compilation.


I cannot figure out what the problem is.


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. Indicator doesnt get displayed Hello...
 
barnumber = iBarShift(NULL,0,fopht[arraysize]) shighs[barnumber] = High[barnumber]+0.0005;
 
//+------------------------------------------------------------------+
//|                                        PivotHighLowIndicator.mq4 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 Blue

double highs[];  
double lows [];

double shighs[];

//int fopht [1];
//int fophp [1];
//int arraysize = ArraySize(fophp);
datetime fopht[1];
double fophp[1];
int arraysize;

bool isfoph;

int barnumber;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,highs);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0, 159);
   SetIndexBuffer(1,lows);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1, 159);   
   
   SetIndexBuffer(2, shighs);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, 159);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---
arraysize = ArraySize(fophp);

int limit = rates_total-prev_calculated;
for(int i=1;limit;i++)
   {
   isfoph = False;                      // Set the first order pivot bool to false.
   
if (High[i+1]>High[i]
   && High[i+1]>High[i+2])
   {
   highs[i+1]=High[i+1];                //Display a dot above all first order pivots.
   isfoph= True;
   }

if (isfoph = True
    && fophp[arraysize-1] != High[2])   // If the last candle is a first order pivot
   {                                    // and the high isn't equal to the last fophp.
   //ArrayResize(fophp, arraysize+1);     // Add an index to the foph arrays.
   //ArrayResize(fopht, arraysize+1);
   ArrayResize(fophp, arraysize+2); 
   ArrayResize(fopht, arraysize+2);

   fophp[arraysize+1] = High[2];        // Assign first order pivot price to last array element.
   fopht[arraysize+1] = Time[2];        // Assign firstorderpivot open time to last array element.  
   }
   
if (fophp[arraysize]>fophp[arraysize+1]   //If the last element of the array is less than the penultimate,
   && fophp[arraysize]>fophp[arraysize-1]) // and the penultimate is more than the one before it.
   {
   //barnumber = iBarShift(NULL,0,fopht[arraysize])  //set barnumber to based on the last time in the fopht array.
   barnumber = iBarShift(NULL,0,fopht[arraysize]);
   shighs[barnumber] = High[barnumber]+0.0005;     //draw an arrow over the bar defined by bar number at the high
   }                                               // of that bar + 5 pips.
   
   
if (Low[i+1]<Low[i]
   &&Low[i+1]<Low[i+2])
   lows[i+1]=Low[i+1];
   
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Naguisa Unada:

Hi, tried your code but still did not work unfortunately :(. Really stuck with this one. 


No compilation errors which is good, but the code isn't doing what I want it to do

 
Kila Akil :

Hi, tried your code but still did not work unfortunately :(. Really stuck with this one. 

No compilation errors which is good, but the code isn't doing what I want it to do

I just modified the program to work, because it did not work with errors.

I did not consider any actions which you wanted.

That's what you should do yourself.

 
Naguisa Unada:

I just modified the program to work, because it did not work with errors.

I did not consider any actions which you wanted.

That's what you should do yourself.

I appreciate your help! I'm stuck with the code now and I can't seem to figure out how to get it doing what I want, any ideas?
 
  1. for(int i=1;limit;i++)
    Not a valid condition.
              How to do your lookbacks correctly.

  2. Use the debugger or print out your variables, including _LastError and find out why.