while(pos>=0) { pos--; } return(0); } // ******** SLmin Function ********** double Func_SLmin (iCxu) { j=0; SLmin=3000; while(iLow(Symbol(),PERIOD_H1,j)<iCxu) { if (iLow(Symbol(),PERIOD_H1,j)<SLmin ) SLmin=iLow(Symbol(),PERIOD_H1,j); //Print (Symbol()+"SLmin = "+SLmin); j++; } return (SLmin); } // ******** SLmin Function ********** // ******** SLmax Function ********** double Func_SLmax (iCxd) { j=0; SLmax=0; while(iHigh(Symbol(),PERIOD_H1,j)>iCxd) { if (iHigh(Symbol(),PERIOD_H1,j)>SLmax) SLmax=iHigh(Symbol(),PERIOD_H1,j); //Print (Symbol()+"SLmax = "+SLmax); j++; } return (SLmax); } // ******** SLmax Function **********
hi,
I put outdie the while loop but still have the following 3 errors:
expressions are not allowed on a global scope
'double' - comma expected
'Func_SLmax' - function not defined
Kindly help, thanks
int start() { int counted_bars=IndicatorCounted(); //---- check for possible errors if (counted_bars<0) return(-1); //---- last counted bar will be recounted if (counted_bars>0) counted_bars--; int pos=Bars-counted_bars; //---- main calculation loop while(pos>=0) { if (iTime(Symbol(),PERIOD_H4,0)!=PH40308U0) { if (X=1 ) { iCxu=iCH40; SLmin= Func_SLmin (iCxu); PH40308U0=iTime(Symbol(),PERIOD_H4,0); } } if (iTime(Symbol(),PERIOD_H4,0)!=PH40308D0) { if (X=2 ) { iCxd=iCH40; SLmax= Func_SLmax (iCxd); // Line 188 PH40308D0=iTime(Symbol(),PERIOD_H4,0); } } pos--; } return(0); } // ******** SLmin Function ********** double Func_SLmin (iCxu) //(Line 247) { j=0; SLmin=3000; while(iLow(Symbol(),PERIOD_H1,j)<iCxu) { if (iLow(Symbol(),PERIOD_H1,j)<SLmin ) SLmin=iLow(Symbol(),PERIOD_H1,j); //Print (Symbol()+"SLmin = "+SLmin); j++; } return (SLmin); } // ******** SLmin Function ********** // ******** SLmax Function ********** double Func_SLmax (iCxd) // Line 263 { j=0; SLmax=0; while(iHigh(Symbol(),PERIOD_H1,j)>iCxd) { if (iHigh(Symbol(),PERIOD_H1,j)>SLmax) SLmax=iHigh(Symbol(),PERIOD_H1,j); //Print (Symbol()+"SLmax = "+SLmax); j++; } return (SLmax); } // ******** SLmax Function **********
hi,
I include the part of the codes to make it clearer.
It has 3 errors as indicated. Is it the right way to put the user defined function outside the while loop as above?
expressions are not allowed on a global scope (Line 247)
'double' - comma expected at line (Line 263)
'Func_SLmax' - function not defined (Line 188)
Kindly help, many thanks

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
- www.mql5.com
//| Expert initialization function | //| Expert deinitialization function | //| Expert tick function | //| test1 |...
ok I managed to resolve the issue as I forget to provide int and double in front of variables. Thanks

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I insert the user defined function in the main loop (while(pos>=0)and has the following 3 errors:
'Func_SLmin' - function declarations are allowed on global, namespace or class scope only
expressions are not allowed on a global scope
'double' - comma expected.
Kindly help