Problem 'Low' - constant variable cannot be passed as reference

To add comments, please log in or register
Pierre
26
Pierre  

Hello,


I have find a good indicator, but it have a problem 'Low' - constant variable cannot be passed as reference

That is the global code :

//+------------------------------------------------------------------+
//|                                            sp market profile.mq4 |
//|                                      Copyright © 2008, sptrading | 
//+------------------------------------------------------------------+
#property copyright "sptrading"
#property indicator_chart_window

#include <mpxlib.mqh>

//+------------------------------------------------------------------+
//| mode: mode selection                                             |
//|     1: mp by day                                                 |
//|     2: mp by date from file                                      |
//| filename: datetime, comma separated;                             |
//|    (2008.12.28 11:00,2008.12.29 00:00)                           |
//|    if emtpy is assumed as <symbol>.mp                            |
//+------------------------------------------------------------------+

extern int mode = 1; 
extern string filename = "";
extern int days = 5;
extern double ticks = 10;
extern bool drawText = true;
extern bool drawBox = true;
extern bool drawPOC = true;
extern bool drawVolume = true;
extern bool std1Breakout = false;
extern bool unitBreakout = false;
extern bool AsiaSession = true;
extern bool EUSession = true;
extern bool USASession = true;

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
  mpxDrawErase();  
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;


//---- name for DataWindow and indicator subwindow label
   short_name="sp market profile";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{  
  double onetick = 1/(MathPow(10,Digits))*ticks;  

  // Erase old one
  mpxDrawErase();  
  double pocsPrices[];
  double mpxVolume[];

   // Sessions  
  int sessions = 0;
  if (AsiaSession)
     sessions |= mpxeAsiaSession;
  if (EUSession)
     sessions |= mpxeEUSession;
  if (USASession)
     sessions |= mpxeUSASession;

  // MP  
  if (mode==1)
  {
   mpxMarketProfileByDay(pocsPrices, mpxVolume, Low, High, days, onetick, sessions, drawText, drawBox, drawPOC, drawVolume);
  }
  else if (mode==2)
  {
   if (filename == "")
      filename = mpxNameFromPeriod() + ".mp";
   mpxMarketProfileByFile(pocsPrices, mpxVolume, Low, High, filename, onetick, sessions, drawText, drawBox, drawPOC, drawVolume);
   }
   
   // Alert
   if (std1Breakout || unitBreakout)
      mpxSendMailAlert(pocsPrices, std1Breakout, unitBreakout);
//----
   return(0);
  }
//+------------------------------------------------------------------+


And the line where is the errors :

  mpxMarketProfileByDay(pocsPrices, mpxVolume, Low, High, days, onetick, sessions, drawText, drawBox, drawPOC, drawVolume);

and

 mpxMarketProfileByFile(pocsPrices, mpxVolume, Low, High, filename, onetick, sessions, drawText, drawBox, drawPOC, drawVolume)

If you can help me, it's good for me

Thanks

William Roeder
20228
William Roeder  
It errors there because your arguments are incompatible with the function definition. A definition which you do NOT show.
function(pocsPrices, mpxVolume, Low, High, ...

TBD function(double& pocsPrices[], double& mpxVolume[], double& lows[], double& highs[], ...
Low[] and High[] are constant arrays. Always pass by constant reference unless you intend to modify the callers argument. You can't modify High[] or Low[]
function(pocsPrices, mpxVolume, Low, High, ...

TBD function(double& prices[], double& volume[], const double& lows[], const double& highs[], ...
Pierre
26
Pierre  

Sorry's but I don't understand that you say

I havie to do what ?

THX

Ex Ovo Omnia
2896
Ex Ovo Omnia  

Your function declaration must explicitly contain const keyword when passing constants, the same way the OnCalculate function does, i.e.

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[]
Stefano Piovesan
173
Stefano Piovesan  
Hi, I fixed it, now it builds with no errors. 
Microsoft OneDrive - Per accedere ai file dovunque ti trovi. Crea documenti con Office Online gratuito.
  • onedrive.live.com
Archivia foto e documenti online per potervi accedere da PC, Mac o cellulare. Crea documenti Word, Excel o PowerPoint e utilizzali per collaborare con altri utenti.
To add comments, please log in or register