[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 112

 
alex12:

Tested and the result - opened 2 orders and didn't close on profit and didn't open any more.

So this option is not suitable.

So it goes back to my first post - "...incomplete TK".

 
Can you tell me if break: (1) should be inside {..} or (2) should be after }, because in the switch statement example only one action is considered after case.
int a; double b; string c;

switch (a) // --- 1.
{  
   case 1:  { b=Ask+SL_1*Point; c="with stop-loss = "+a; break; }
   case 2:  { b=Ask+SL_2*Point; c="with stop-loss = "+a; break; }
   default: { b=Ask+SL_0*Point; c="with stop-loss = 0"; }
}
switch (a) // --- 2.
{  
   case 1:  { b=Ask+SL_1*Point; c="with stop-loss = "+a; } break;
   case 2:  { b=Ask+SL_2*Point; c="with stop-loss = "+a; } break;
   default: { b=Ask+SL_0*Point; c="with stop-loss = 0"; }
}
 

Parentheses are not necessary at all. But if you do - then the break is inside.

Although... who the fuck cares, it still has to execute.

 
Mathemat:

I was thinking about {...} in case by analogy with if. If there is more than 1 action, it should be {...}. If the philosophy of case operator is such that everything (!) is executed after it, then I feel we should remove {...}, like:
switch (a)
{  
   case 1:  b=Ask+SL_1*Point; c="with stop-loss = "+a; break;
   case 2:  b=Ask+SL_2*Point; c="with stop-loss = "+a; break;
   default: b=Ask+SL_0*Point; c="with stop-loss = 0";
}
 
Well, that's what it says.
 
paladin80:
I thought about {...} in case by analogy with if. If there is more than 1 action, you need {...}. If the philosophy of the case operator is such that everything (!) is executed after it, then I feel we should remove {...} altogether, like:

Everything is performed before the break, otherwise default.

i.e.

case 1:  b=Ask+SL_1*Point; c="with stop-loss = "+a; break;
или
case 1:  b=Ask+SL_1*Point; c="with stop-loss = "+a; return(09,05);
приемлема и работает.

{...} is implied from case to break (try output;)).

 
Just, a small exception. GO TO operator, but only inside {} :)
 
costy_: Execute everything before the break, otherwise default.

Yeah, and your code won't compile at all - because of this:

return(09,05);
 
Can you tell me something: I am using several arrays in my calculations and I need to switch between arrays, but it is not very convenient to use constant condition before each use of the required array. Are there any reference variables in MT4 to check the condition once and then write in it which array I need to work, I haven't found it in documentation.
 

No, variables (and arrays too) can only be passed by reference to a function.

Reason: