mql4 error open parenthesis expected.

 

Hi. 

i am a beginner and was practicing some basic codes but i faced 14-15 errors. i made them all ok but whatever i do the open parenthesis error wont go away. could you please see where the problem is?

and there is another error,

'else' - illegal 'else' without matching 'if'

please help me with these two errors


   int first=20;
   int second=25;
   int third=30;
   int end= (first+second+third);
   //--------------------------------------
  switch(end)
    {case 75:
       if:(first = 21)
        {Print:"first is 21";}
       else if:(first = 20)
        {Print:"first is 20";}
       else:
        {Print:"case 1: first is something other than 20&21";}
             break;
             
     case 23:Print:"case 2";
       break;
     case 10:Print:"case 3";
       break;
     default:(Print:"no case";
       break;
       
    }
  ExpertRemove();

 
AdamFuchs: please help me with these two errors

Perhaps you should read the manual, or press F1 in the editor.
            Conditional Operator if-else - Operators - Language Basics - MQL4 Reference
            Print - Common Functions - MQL4 Reference
            Operations of Relation - Operations and Expressions - Language Basics - MQL4 Reference
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

       if:(first = 21)
        {Print:"first is 21";}
       else if:(first = 20)
        {Print:"first is 20";}
       else:
 
Comments that do not relate to this topic, have been moved to "Off-topic MT4/mql4 questions.".
 

Hi

You need to learn proper syntax and how to code in mql4. It should look like this to work.

       int first=20;
   int second=25;
   int third=30;
   int end= (first+second+third);
   //--------------------------------------
  switch(end){
     case 75:
       if(first ==21)
        {Print("first is 21");}
       else if(first == 20)
        {Print("first is 20");}
       else
        {Print("case 1: first is something other than 20&21");}
        break;
             
     case 23:
       Print("case 2");
       break;
     case 10:
       Print("case 3");
       break;
     default:
       Print("no case");
       break;
       
    }
  ExpertRemove();

Have a nice day👍📊