need help creating objects in chart - page 2

 
FlashX:

but OrdersTotal() represents the amount of open orders not their position!?


so if i have 2 open orders it say OrderTotal() = 2.

When i would say OrdersTotal()-1, then i would have 1 open order instead of 2.

No, you have one at position 1 and one at position 0
 

ok now i got it but it still doesnt work.

i tried out to change several variables who are possible in this context but no.

any further help?

 
void CloseAllOrders(int op = -1){
    for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if (
        OrderSelect(iPos, SELECT_BY_POS)                    // Only my orders w/
    &&  OrderMagicNumber() == Magic.Number                  // my magic number
    &&  OrderSymbol()      == chart.symbol                  // and my pair,
    &&  (op < 0 || op == OrderType())                       // and wanted type.
    ){  // Don't combine with &&'s Compiler bug.
        if (!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), ...)
            Alert("OrderClose failed ", GetLastError());
    }
}
You can not close an order if the market is closer than MarketInfo(chart.symbol, MODE_STOPLEVEL)*Point
 
FlashX:


any further help?

Show your new code that doesn't work . . . or use WHRoeder's