[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 968

 

Please help.

Can someone explain why this function does not close all open orders at once?

//-------------------------------------------------------------------+
int CloseOrders(int mn) // procedure to close all orders
{
int total = OrdersTotal();

for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == mn && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);
}

if (OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
}
if (OrderType()==OP_BUYSTOP)
{
OrderDelete(OrderTicket());
}

if (OrderType()==OP_SELLSTOP)
{
OrderDelete(OrderTicket());
}
}
}
return(0);
}

 
kwadrad:

Please help.

Can someone explain why this function does not close all open orders at once:


Try this

void CloseOrders() 
{
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS))
          {
          if(OrderType()==0)
             OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),Digits),5);
          if(OrderType()==1)
             OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),Digits),5);
          if(OrderType()>1)
             OrderDelete(OrderTicket());
          }
     }
}
 

Please help with this question.....

How do I change the TP for an order that is already open?

 
pr0fess0r64:

Please help with this question.....

How do I change the TP for an order that is already open?

like this https://docs.mql4.com/ru/trading/OrderModify
 
Techno:

try this


Thanks, I'll give it a try.

Don't you need return at the end of the function?

 
kwadrad:


Thanks, I'll give it a try.

Is return at the end of the function unnecessary?

No, I don't.
 

The compiler won't accept quite basic things, help me please!

int start()

int f;f=1;

It swears like this-

'int' - semicolon expected C:\Orderly couture\expertsÃärson.mq4 (38, 4)

'f' - expression on global scope not allowed C:³³'s prints³'s printsó's borders.mq4 (38, 10)

 
Dimka-novitsek:

The compiler won't accept quite elementary things, help please!

int start()

int f;f=1;

It swears like this-

Who's going to put the brackets in? Pushkin? And he's right to swear, too bad he doesn't call you names )))

int start()
{
int f;f=1;
}
 
Dimka-novitsek:

The compiler won't accept quite basic things, help please!


int start(){
   int f;
   f=1;
}

{}{}{}{}{}{}{}{}{}{}{}{}{}{}
 

Kind people, please help.

Help make the information text in this indicator multicoloured and slightly bolder. The word DOWN red bold word UP green also bold text. Also to the left of the indicator names also make it a bit bolder

Reason: