Download MetaTrader 5

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

To add comments, please log in or register
Pierre
25
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

whroeder1
14781
whroeder1  
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
25
Pierre  

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

I havie to do what ?

THX

Ex Ovo Omnia
3189
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[]
To add comments, please log in or register