Download MetaTrader 5

Communications Script Debugging

To add comments, please log in or register
GK0135
12
GK0135  

Hello All,

 Just wanted to ask if there is any one willing to help me solve the following issue(I'm still a novice coder). When I compile my code, the following snipbit of code throws out 3 errors as indicated. 


void Comms()
{
while(IsTradeAllowed() == true)
   {                                                                                                                                   
   if(InitiateComms == true)(Sleep(CommsTime*100*PeriodSeconds()))
   {                                                                                                                                       -> Some operator expected
   SendMail("Looper_BA1",                                                                                                    -> Constant expression required
          "n/Balance =" + DoubleToString(AccountBalance(),8) + 
          "n/Total Balance Growth" + DoubleToString((AccountBalance() - StartBalance),8) +
          "n/Equity" + DoubleToString(AccountEquity()) +
          "n/Total Balance Growth" + DoubleToString((AccountEquity() - StartEquity),8)) ;               ->  Unexpected token  
   }
   }

}

Please help me sort out these issues,

Regards. 

honest_knave
Moderator
2296
honest_knave  

This is the line that is causing you problems:

if(InitiateComms == true)(Sleep(CommsTime*100*PeriodSeconds()))

I *think* this is what you want: 

void Comms()
{
while(IsTradeAllowed() == true)
   {                                                                                                                                  
   if(InitiateComms == true)
   {                                                                                                                                    
   Sleep(CommsTime*100*PeriodSeconds());
   SendMail("Looper_BA1",                                                                                                    
          "n/Balance =" + DoubleToString(AccountBalance(),8) +
          "n/Total Balance Growth" + DoubleToString((AccountBalance() - StartBalance),8) +
          "n/Equity" + DoubleToString(AccountEquity()) +
          "n/Total Balance Growth" + DoubleToString((AccountEquity() - StartEquity),8)) ;                
   }
   }
}
GK0135
12
GK0135  
honest_knave:

This is the line that is causing you problems:

if(InitiateComms == true)(Sleep(CommsTime*100*PeriodSeconds()))

I *think* this is what you want: 

void Comms()
{
while(IsTradeAllowed() == true)
   {                                                                                                                                  
   if(InitiateComms == true)
   {                                                                                                                                    
   Sleep(CommsTime*100*PeriodSeconds());
   SendMail("Looper_BA1",                                                                                                    
          "n/Balance =" + DoubleToString(AccountBalance(),8) +
          "n/Total Balance Growth" + DoubleToString((AccountBalance() - StartBalance),8) +
          "n/Equity" + DoubleToString(AccountEquity()) +
          "n/Total Balance Growth" + DoubleToString((AccountEquity() - StartEquity),8)) ;                
   }
   }
}

Hello Honest_knave,

 

Thank you for your assistance! Your recommendation has eliminated two of my errors, the only one that remains is the " 'SendMail' - Some operator expected".

Any recommendations?

Regards, 

honest_knave
Moderator
2296
honest_knave  
GK0135:

Hello Honest_knave,

 

Thank you for your assistance! Your recommendation has eliminated two of my errors, the only one that remains is the " 'SendMail' - Some operator expected".

Any recommendations?

Regards, 

I think you missed the ; at the end of the Sleep line?
whroeder1
16336
whroeder1  
honest_knave: I think you missed the ; at the end of the Sleep line?
That plus the fact that OP's using parentheses instead of braces
To add comments, please log in or register