# switch case operator to open multiple order

Hi, I have a strategy that will open limit order at multiple price point. This time I tried to use switch case operator in my code, here's the result:

```if(InpLotMode == LOT_MODE_EQUITY_RISK_PCT)
{
for(int i = 4; i >= 0; i--)
{
double price = 0;
switch(i)
{
case 1:
price = Level1;
break;
case 2:
price = Level2;
break;
case 3:
price = Level3;
break;
case 4:
price = Level4;
break;
}
lotSize = NormalizeDouble(OptimalLotSize(CurrentSymbol, InpLotSize, MathAbs(price - Level5)),2);

if(!trade.OrderOpen(CurrentSymbol, ORDER_TYPE_SELL_LIMIT, lotSize, price, price, Level5, Level6, ORDER_TIME_GTC))
Print("failed to open order in price level ", i);
}
}```

*code is complied but not tested.

For the syntax itself, does the usage in my code is correct?

Looks correct, but everybody here would have to try run it in debugger which you can do yourself.

1. Set break points at every line by double clicking on the line numbers.
2. Run it through debugger.
3. Click the blue 🔵 play button again to jump to the next break point.
4. Mark and right click on variables to put them into observation through the context menu.
5. See how the variables change during the run.

Luandre Ezra:

Hi, I have a strategy that will open limit order at multiple price point. This time I tried to use switch case operator in my code, here's the result:

*code is complied but not tested.

For the syntax itself, does the usage in my code is correct?

Your lotsize might fail if your minimum LotSize for a Symbol is 0.1 . Trading volume should be a multiple of lotstep

Luandre Ezra: i, I have a strategy that will open limit order at multiple price point.

There is no need to create pending orders in code.

1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

Don't worry about it unless you're scalping M1 or trading news.

2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

Thanks everyone, I rarely using switch case operator since usually I don't need it. Just need to make sure that my syntax is correct or not. And thanks Daniel for the tips, I forgot to put a check for minimum lot in there.