Download MetaTrader 5
To add comments, please log in or register
Publish your article. We will translate it into other languages!
Sherif Hasan
7222
Sherif Hasan 2015.02.03 11:10 
extern double MaPeriod = 14;
extern double MaShift = 0;
//extern string MAMethodHelp="SMA=MODE_SMA;EMA=MODE_EMA;SMMA=MODE_SMMA;LWMA=MODE_LWMA";
extern double MaMethod = MODE_SMA;
//extern string MAAppliedHelp="PRICE_CLOSE;PRICE_OPEN;PRICE_HIGH;PRICE_LOW;PRICE_MEDIAN,PRICE_TYPICAL;PRICE_WEIGHTED";
extern double MaApplied = PRICE_CLOSE;

No Error while compiling. but in settings it took Value as "0.0" instead of "MODE_SMA"

what will be the issue?

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.02.03 11:23  
Try SMA?
honest_knave
951
honest_knave 2015.02.03 11:25  

MODE_SMA has a value of 0.

By the way, you will get on better declaring these as integers not doubles.

Keith Watford
Moderator
7875
Keith Watford 2015.02.03 11:37  

Try

extern ENUM_MA_METHOD MaMethod=MODE_SMA;
Sherif Hasan
7222
Sherif Hasan 2015.02.03 11:48  
GumRai:

Try

 

 

Yes. Thanks
whroeder1
13596
whroeder1 2015.02.03 14:53  
honest_knave: By the way, you will get on better declaring these as integers not doubles.
Don't use doubles. Don't use integers.
extern double MaMethod = MODE_SMA;
extern double MaApplied = PRICE_CLOSE;
Use the proper enumerations.
extern ENUM_MA_METHOD     MaMethod = MODE_SMA;
extern ENUM_APPLIED_PRICE MaApplied = PRICE_CLOSE;
honest_knave
951
honest_knave 2015.02.03 15:12  

I was equally referring to the erroneous declaration of MaPeriod and MaShift as doubles. Enumerations are effectively 4 byte integers

whroeder1
13596
whroeder1 2015.02.03 17:03  
honest_knave: Enumerations are effectively 4 byte integers
Not in the GUI
sheriffonline: Value as "0.0" instead of "MODE_SMA"
Sherif Hasan
7222
Sherif Hasan 2015.02.03 18:03  
WHRoeder:
Don't use doubles. Don't use integers.
Use the proper enumerations.

I am Newbie and learning MQL4. ofcourse i learnt lot, but still confused with Enumerations!

can you send me sample code for Enumearion?

Definetely i can get idea what mistake i have done?

I tested following example code! but says error message "Variable not Defined"?

enum months  // enumeration of named constants
   {
    January,
    February,
    March,
    April,
    May,
    June,
    July,
    August,
    September,
    October,
    November,
    December
   };
Carl Schreiber
5932
Carl Schreiber 2015.02.04 07:57  

January will have 0 but 1! , Feb.=1,... Dec=11

So you have to add 1!

whroeder1
13596
whroeder1 2015.02.04 14:20  

sheriffonline: I tested following example code! but says error message "Variable not Defined"?
enum months  // enumeration of named constants
   {
    January,
    February,
    March,
    April,
    May,
    June,
    July,
    August,
    September,
    October,
    November,
    December
   };
That is the definition. same as int or double. Define a variable.
months aMonth = February;
gooly: January will have 0 but 1! , Feb.=1,... Dec=11

So you have to add 1!

No you don't. Set the value you want.
enum months  // enumeration of named constants
   {
    January = 1,
    February,  // Value will default to 2
    March, ...
/
To add comments, please log in or register