Is this correct declaration?

Back to topics list To post a new topic, please log in or register
avatar
273
sheriffonline 2015.02.03 12: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?

avatar
1211
deysmacro 2015.02.03 12:23 #
 
Try SMA?
avatar
735
honest_knave 2015.02.03 12:25 #
 

MODE_SMA has a value of 0.

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

 

avatar
Moderator
3404
GumRai 2015.02.03 12:37 #
 

Try

extern ENUM_MA_METHOD MaMethod=MODE_SMA;

 

 

avatar
273
sheriffonline 2015.02.03 12:48 #
 
GumRai:

Try

 

 

Yes. Thanks
avatar
12983
WHRoeder 2015.02.03 15: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;

avatar
735
honest_knave 2015.02.03 16:12 #
 

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

avatar
12983
WHRoeder 2015.02.03 18:03 #
 
honest_knave: Enumerations are effectively 4 byte integers
Not in the GUI
sheriffonline: Value as "0.0" instead of "MODE_SMA"
avatar
273
sheriffonline 2015.02.03 19: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
   };
avatar
2017
gooly 2015.02.04 08:57 #
 

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

So you have to add 1!


avatar
12983
WHRoeder 2015.02.04 15: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, ...
Back to topics list  

To add comments, please log in or register