Coding HELP!! Please
You have not explained what "does not work" means for you! Just saying "does not work" has no meaning as we don't know what you are trying to achieve.
However, assuming you are trying to find out the current period, then just know that PERIOD_CURRENT is only a macro constant, just like PERIOD_M5 or the others. It is not a function or variable.
To get the current period use either the function Period() or the predefined variable _Period like so:
int Y; if(_Period==PERIOD_M3) { Y = 2380; Print(Y); } else if(_Period==PERIOD_M5) { Y=1428; Print(Y); } else if(_Period==PERIOD_M10) { Y=714; Print(Y); }
I would suggest, however, you use a "switch" statement instead of multiple "if". Something like this:
int Y; switch( _Period ) { case PERIOD_M3: Y = 2380; break; case PERIOD_M5: Y = 1428; break; case PERIOD_M10: Y = 714; break; default: Y = WRONG_VALUE; }; Print(Y);
You have not explained what "does not work" means for you! Just saying "does not work" has no meaning as we don't know what you are trying to achieve.
However, assuming you are trying to find out the current period, then just know that PERIOD_CURRENT is only a macro constant, just like PERIOD_M5 or the others. It is not a function or variable.
To get the current period use either the function Period() or the predefined variable _Period like so:
I would suggest, however, you use a "switch" statement instead of multiple "if". Something like this:
Thank You, i tested it and It was just what i was looking for,

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Why does this not work?