Hi,
In writing an EA containing an implementation file and a separate class, I've developed a method (i.e. getBarLow) within the class designed to retrieve the lowest of the no. of bar lows to be used as a breakout entry. The parameters of the method is the no. of breakout days that is sourced from the main implementation file in the form of a user input (i.e. input in BreakoutDays) and the intention is for the method to pass the parameter to separate functions (i.e. iLow and iLowest days) to then work out the low breakout point. However, I am getting a compilation error message explaining that it the BreakoutDays parameter is an undeclared identifier - which I assume means a parameter I have yet to declare. I tried an alternative by declaring separate variables within the getBarLow method to pass the BreakoutDays from the main implementation file and then pass the values from the new variables to the iLowest function but did not yield a different result.
Is anyone able to provide an alternative way to solve this?
I have attached both the mq5 and mqh files together with the compilation error screenshot which should help explain the issue.
Thanks.
Peter
I've managed to solve the undeclared identifier issue by doing the following:
- Removed the count parameter from the iLowest parameter list and replaced it with pBreakoutDays such that it can receive pBreakoutDays value from the function call
- Declared a count variable in the main code and assigned pBreakoutDays to it such that it now fits with the remaining code.
See code below. However, now it gives me a "missing default value for parameter" error. Does the parameter need a default value if it is receiving a value from the function call??
int iLowest(string symbol, int tf, int type=MODE_LOW, int pBreakoutDays, int start=0) { int count; // <<------------ Declared count variable and replaced count from the parameter list with pBreakoutDays count = pBreakoutDays; // <<------------ Assigned pBreakoutDays to count if(start <0) return(-1); ENUM_TIMEFRAMES timeframe=TFMigrate(tf); if(count==0) count=Bars(symbol,timeframe); if(type==MODE_LOW) { double Arr[]; if(CopyLow(symbol,timeframe,start,count,Arr)>0) return((count-ArrayMinimum(Arr)-1)+start); else return(-1); } else if(type==MODE_HIGH) { double Arr[]; if(CopyHigh(symbol,timeframe,start,count,Arr)>0) return((count-ArrayMinimum(Arr)-1)+start); else return(-1); } if(type==MODE_OPEN) { double Arr[]; if(CopyOpen(symbol,timeframe,start,count,Arr)>0) return((count-ArrayMinimum(Arr)-1)+start); else return(-1); } else if(type==MODE_CLOSE) { double Arr[]; if(CopyClose(symbol,timeframe,start,count,Arr)>0) return((count-ArrayMinimum(Arr)-1)+start); else return(-1); } else if(type==MODE_VOLUME) { long Arr[]; if(CopyTickVolume(symbol,timeframe,start,count,Arr)>0) return((count-ArrayMinimum(Arr)-1)+start); else return(-1); } else if(type==MODE_REAL_VOLUME) { long Arr[]; if(CopyRealVolume(symbol,timeframe,start,count,Arr)>0) return((count-ArrayMinimum(Arr)-1)+start); else return(-1); } else return(-1); }
I've managed to solve the undeclared identifier issue by doing the following:
- Removed the count parameter from the iLowest parameter list and replaced it with pBreakoutDays such that it can receive pBreakoutDays value from the function call
- Declared a count variable in the main code and assigned pBreakoutDays to it such that it now fits with the remaining code.
See code below. However, now it gives me a "missing default value for parameter" error. Does the parameter need a default value if it is receiving a value from the function call??
Hi,
In writing an EA containing an implementation file and a separate class, I've developed a method (i.e. getBarLow) within the class designed to retrieve the lowest of the no. of bar lows to be used as a breakout entry. The parameters of the method is the no. of breakout days that is sourced from the main implementation file in the form of a user input (i.e. input in BreakoutDays) and the intention is for the method to pass the parameter to separate functions (i.e. iLow and iLowest days) to then work out the low breakout point. However, I am getting a compilation error message explaining that it the BreakoutDays parameter is an undeclared identifier - which I assume means a parameter I have yet to declare. I tried an alternative by declaring separate variables within the getBarLow method to pass the BreakoutDays from the main implementation file and then pass the values from the new variables to the iLowest function but did not yield a different result.
Is anyone able to provide an alternative way to solve this?
I have attached both the mq5 and mqh files together with the compilation error screenshot which should help explain the issue.
Thanks.
Peter
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
In writing an EA containing an implementation file and a separate class, I've developed a method (i.e. getBarLow) within the class designed to retrieve the lowest of the no. of bar lows to be used as a breakout entry. The parameters of the method is the no. of breakout days that is sourced from the main implementation file in the form of a user input (i.e. input in BreakoutDays) and the intention is for the method to pass the parameter to separate functions (i.e. iLow and iLowest days) to then work out the low breakout point. However, I am getting a compilation error message explaining that it the BreakoutDays parameter is an undeclared identifier - which I assume means a parameter I have yet to declare. I tried an alternative by declaring separate variables within the getBarLow method to pass the BreakoutDays from the main implementation file and then pass the values from the new variables to the iLowest function but did not yield a different result.
Is anyone able to provide an alternative way to solve this?
I have attached both the mq5 and mqh files together with the compilation error screenshot which should help explain the issue.
Thanks.
Peter