Help With Parentheses

 

Hi

I am having trouble with Parentheses.

I know i should'nt but i can not figure out how to add a simple extra if statement.

This code works

int init()
{
if(60*EndHr+EndMn<=(60*StartHr+(StartMn+15)))
  {
   Print("invalid trading time");
   return INIT_PARAMETERS_INCORRECT;
  }


But this code throws up parentheses and other errors based on where i think extra closing ones should go.

Currently they are unbalanced but even balancing them up i still get errors. My background is VBA and this code styling is proving a challenge despite some hours looking at web based doumenttion and examples.

int init()

{
     if UseTimeSlot = false
      {
       NumberOfMins = 15
      }
      else
      {
         if(60*EndHr+EndMn<=(60*StartHr+(StartMn+NumberOfMins)))    //extern bool UseTimeSlot = false;
         {
   //Print("invalid trading time");
   return INIT_PARAMETERS_INCORRECT;
         }

Anyone any ideas.

I can feel a smack on the forehead coming up.

Thanks

Paxman

 
Paxman:

Hi

I am having trouble with Parentheses.

I know i should'nt but i can not figure out how to add a simple extra if statement.

This code works

int init()
{
if(60*EndHr+EndMn<=(60*StartHr+(StartMn+15)))
  {
   Print("invalid trading time");
   return INIT_PARAMETERS_INCORRECT;
  }


But this code throws up parentheses and other errors based on where i think extra closing ones should go.

Currently they are unbalanced but even balancing them up i still get errors. My background is VBA and this code styling is proving a challenge despite some hours looking at web based doumenttion and examples.

int init()

{
     if UseTimeSlot = false
      {
       NumberOfMins = 15
      }
      else
      {
         if(60*EndHr+EndMn<=(60*StartHr+(StartMn+NumberOfMins)))    //extern bool UseTimeSlot = false;
         {
   //Print("invalid trading time");
   return INIT_PARAMETERS_INCORRECT;
         }

Anyone any ideas.

I can feel a smack on the forehead coming up.

Thanks

Paxman

When you post code use Alt+S

attach code

 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Nothing wrong with your first code — compiles fine. You problem may be higher. Always post the context of your code — like the definitions of your variables and the error messages and indicate the corresponding line number.

  3. NumberOfMins = 15 
    Missing a terminating semicolon.
 
William Roeder:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Nothing wrong with your first code — compiles fine. You problem may be higher. Always post the context of your code — like the definitions of your variables and the error messages and indicate the corresponding line number.

  3. Missing a terminating semicolon.
int init()

{
     if UseTimeSlot = false; //this one to
      {
       NumberOfMins = 15;
      }
      else
      {
         if(60*EndHr+EndMn<=(60*StartHr+(StartMn+NumberOfMins)))    //extern bool UseTimeSlot = false;
         {
   //Print("invalid trading time");
   return INIT_PARAMETERS_INCORRECT;
         }

I found another one...

 
Kenneth Parling:

I found another one...

There are over 400 variables so i have shown the ones involved in this code.

I inserted the missing semi colons and it serves up another error. I have given line numbers just to give scale here as i am not sure it does much else. Not sure if or how i can include them in the paste of code.

Unexpected end of program (right click go to line, takes you to the very end of the code. Line 7985

Plus Unexpected parentheses (right click go to line, takes you to immediately after the int init(). Line 595

I thought the question simple as the first bit of code worked and only on inserting the extra if statement did it give errors.

I assumed it was merely a poor nesting effort.

I can post more of the code but there are thousands of lines and i am not sure if it will help.

What i have now found is that the closing brace at the end of the int init() code (Line 1116) now highlights when clicked with the opening brace immediately after the else. Line 600


Anything else to try?

Thanks Paxman


       extern bool UseTimeSlot                  = false;
       extern int NumberOfMins                  = 30; 
       int TimeSlot                             =15;
         extern int StartHr                     = 1;
         extern int StartMn                     =10; 
         extern int EndHr                       = 2;
         extern int EndMn                       =20;       
         string Chart_Server_Start_Time = StringFormat("%02d:%02d",StartHr ,StartMn);
         string Chart_Server_End_Time = StringFormat("%02d:%02d",EndHr ,EndMn);

int init()

{
     if UseTimeSlot = false;
      {
       NumberOfMins = 15;
      }
      else
      {      // this now highlights with the end brace immediately after the int init()
         if(60*EndHr+EndMn<=(60*StartHr+(StartMn+NumberOfMins)))    //extern bool UseTimeSlot = false;
         {
   //Print("invalid trading time");
   return INIT_PARAMETERS_INCORRECT;
 
   if(UseTimeSlot = false)
     {
      NumberOfMins = 15;
     }
   else
     {
      // this now highlights with the end brace immediately after the int init()
      if(60*EndHr+EndMn<=(60*StartHr+(StartMn+NumberOfMins)))    //extern bool UseTimeSlot = false;
        {
         //Print("invalid trading time");
         return INIT_PARAMETERS_INCORRECT;
        }
     }

.

Reason: