Download MetaTrader 5

How to use switch statement,What problom of my below code

To add comments, please log in or register
Publish the program in the Market and sell it to millions of traders!
47803124
157
47803124 2014.09.08 12:25 
switch(x)
            {
               case 1: 
                  if(USD==1) firstcurrent=1; if(USD==2)  firstcurrent=2;
               case 2: 
                  if(EUR==1) firstcurrent=1; if(EUR==2)  firstcurrent=2;
               case 3: 
                  if(GBP==1) firstcurrent=1; if(GBP==2)  firstcurrent=2;
               case 4: 
                  if(CHF==1) firstcurrent=1; if(CHF==2)  firstcurrent=2;
               case 5: 
                  if(JPY==1) firstcurrent=1; if(JPY==2)  firstcurrent=2;
               case 6: 
                  if(AUD==1) firstcurrent=1; if(AUD==2)  firstcurrent=2; 
               case 7: 
                  if(CAD==1) firstcurrent=1; if(CAD==2)  firstcurrent=2;   
               case 8: 
                  if(NZD==1) firstcurrent=1; if(NZD==2)  firstcurrent=2;              
            }
          switch(y)
            {
               case 1: 
                  if(USD==1) secondcurrent=1; if(USD==2)  secondcurrent=2;
               case 2: 
                  if(EUR==1) secondcurrent=1; if(EUR==2)  secondcurrent=2;
               case 3: 
                  if(GBP==1) secondcurrent=1; if(GBP==2)  secondcurrent=2;
               case 4: 
                  if(CHF==1) secondcurrent=1; if(CHF==2)  secondcurrent=2;
               case 5: 
                  if(JPY==1) secondcurrent=1; if(JPY==2)  secondcurrent=2;
               case 6: 
                  if(AUD==1) secondcurrent=1; if(AUD==2)  secondcurrent=2; 
               case 7: 
                  if(CAD==1) secondcurrent=1; if(CAD==2)  secondcurrent=2;   
               case 8: 
                  if(NZD==1) secondcurrent=1; if(NZD==2)  secondcurrent=2;              
            }
Alain Verleyen
Moderator
30731
Alain Verleyen 2014.09.08 12:41  
You need to add "break;". See switch documentation.
To add comments, please log in or register