Help a newbie - Day and Time functions - page 2

 

Why do i get all these error when i compile the code?

Compiling 'GAPeaOnlySunday.mq4'...
'bool' - semicolon expected Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (86, 3)
'(' - initialization expected Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (86, 22)
'TimeDayofWeek' - comma or semicolon expected Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (86, 23)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (86, 54)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (86, 70)
'(' - initialization expected Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (87, 22)
'TimeDayofWeek' - comma or semicolon expected Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (87, 23)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (87, 50)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (87, 54)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (87, 65)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (87, 70)
'sunday_cond' - expression on global scope not allowed Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (88, 6)
'sunday_cond' - variable not defined Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (88, 6)
'monday_cond' - expression on global scope not allowed Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (88, 22)
'monday_cond' - variable not defined Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (88, 22)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (88, 34)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (89, 20)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (89, 24)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (92, 35)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (92, 43)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (94, 38)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (94, 42)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (94, 57)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (96, 39)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (96, 45)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (98, 20)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (98, 29)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (100, 32)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (100, 53)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (102, 30)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (102, 55)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (104, 40)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (104, 57)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (104, 99)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (104, 107)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (108, 20)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (108, 30)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (110, 28)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (110, 55)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (112, 30)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (112, 57)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (114, 40)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (114, 57)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (114, 99)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (114, 107)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (122, 43)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (123, 27)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (123, 36)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (123, 46)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (123, 69)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (123, 81)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (123, 94)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (124, 66)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (125, 49)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (126, 31)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (127, 44)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (128, 58)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (134, 44)
')' - unbalanced right parenthesis Z:\ForexTrading\GabEA_From Mike\GAPeaOnlySunday.mq4 (136, 12)
57 error(s), 2 warning(s)

 

LOL -because your code is buggy.

debug it.

start looking for a missing semicolon, as reported, than a missing parenthesis.

coding is not just writing some words in an editor, the main work is to debug one owns code.

 

Or you could cut your losses and contact the Guinness Book Of Records?


CB

 

There is no errors on my EA code, just tested it to be sure. All these errors came after i inserted this four lines of code:


bool sunday_cond = (TimeDayofWeek(TimeCurrent())==0) && (Hour()>=23);
bool monday_cond = (TimeDayofWeek(TimeCurrent())==1) && (Hour()<=15);
if(sunday_cond || monday_cond )
if(OrdersTotal()==0)

 
EagleEye:

There is no errors on my EA code, just tested it to be sure. All these errors came after i inserted this four lines of code:


if(OrdersTotal()==0) //shouldnt here follow this -> {

if thats all you have inserted, you just not coded what have to be done when if is true

how can you say that "your" (is it not Mikes EA?) ea is errorfree after you changed the code ? are you kidding ?

 

Instead of "TimeDayofWeek" it is "TimeDayOfWeek". The correct code is:

bool sunday_cond = (TimeDayOfWeek(TimeCurrent())==0) && (Hour()>=23);
bool monday_cond = (TimeDayOfWeek(TimeCurrent())==1) && (Hour()<=15);
if(OrdersTotal()==0)
if(sunday_cond || monday_cond )
go_trading();

I've verified this part, so the "unbalanced right parenthesis" error is another issue of remaining code.

 
abstract_mind:

Instead of "TimeDayofWeek" it is "TimeDayOfWeek". The correct code is:

bool sunday_cond = (TimeDayOfWeek(TimeCurrent())==0) && (Hour()>=23);
bool monday_cond = (TimeDayOfWeek(TimeCurrent())==1) && (Hour()<=15);
if(OrdersTotal()==0)
if(sunday_cond || monday_cond )
go_trading();

I've verified this part, so the "unbalanced right parenthesis" error is another issue of remaining code.

if(OrdersTotal()==0)
if(sunday_cond || monday_cond )
go_trading();

this above is at least bad style code. no wonder that errors like missing parenthis are usual

if(
    (OrdersTotal()==0)
    &&
    (sunday_cond || monday_cond )
  ) 
   {
    go_trading();
   }

in this way its clear to see that parenthesis are correct, and this kind of code works in nearly every language.

{ } are essential for code which should be easy to debug.

sometimes neccessary if the code is not only in one line.

 
meikel:

if thats all you have inserted, you just not coded what have to be done when if is true

how can you say that "your" (is it not Mikes EA?) ea is errorfree after you changed the code ? are you kidding ?

No i'm not kidding. And if you really want to know Mike, my friend, has sent it to me long time ago because he want me to try it out.


When i compile the EA without the 4 lines of code there is no error at all.

When i insert the 4 lines of code from here it make all the errors.

 
EagleEye:

No i'm not kidding. And if you really want to know Mike, my friend, has sent it to me long time ago because he want me to try it out.


When i compile the EA without the 4 lines of code there is no error at all.

When i insert the 4 lines of code from here it make all the errors.

follow abstracts_mind's hint.

you have written of, not Of

bool sunday_cond = (TimeDayofWeek(TimeCurrent())==0) && (Hour()>=23);

all after the equal sign is wrong because of this, therefore the compiler expects a semicolon after sunday_cond.

 
meikel:

follow abstracts_mind's hint.

you have written of, not Of

bool sunday_cond = (TimeDayofWeek(TimeCurrent())==0) && (Hour()>=23);

all after the equal sign is wrong because of this, therefore the compiler expects a semicolon after sunday_cond.


So how should the code look like?


Right now it looks like this:

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()

bool sunday_cond = (TimeDayOfWeek(TimeCurrent())==0) && (Hour()>=23);
bool monday_cond = (TimeDayOfWeek(TimeCurrent())==1) && (Hour()<=15);

if(
(OrdersTotal()==0)
&&
(sunday_cond || monday_cond )
)

{
if (Bars<100 || IsTradeAllowed()==false) return;

if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();

Reason: