Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 179

 

Is it possible that it closed part of the order?

What if it tried this way, what does it say?

double bylo = OrderLots();
if (OrderClose( OrderTicket(), 0.1, NormalizeDouble(Bid,2), 1 ))    Alert ("  Закрито частину лоту в розмірі 0.1 від ",bylo);
else Alert("Маємо помилку ",GetLastError());
 

artmedia70:
А почему нормализуете цену до двух? До Digits нужно. А проще писать OrderClosePrice() вместо Bid


 OrderClose( OrderTicket(), 0.1, OrderClosePrice(), 1 );  
      Alert("Маємо помилку ",GetLastError());

Now gives error 4051

 
ALXIMIKS:

Is it possible that it closed part of the order?

What if you try it this way, what does it say?



bylo = 0.1 and it does not close my order.
 
Now it's all a glitch, I write:
 double p[100];
 p[i+1] = OrderProfit();
 if (p[i+1]>0) 
    {
      Alert("Є прибуток ордер ",i+1);
      OrderSelect(i+1,SELECT_BY_POS,MODE_TRADES); 
      Alert("Маємо помилку ",GetLastError());
      Alert("Вибрали ордер ",i+1);
      OrderClose( OrderTicket(), 0.1,  NormalizeDouble(Bid,Digits), 1 );  
      Alert("Маємо помилку ",GetLastError());
      Alert("Закрили ордер ",i+1); 

I+1 = 2 and everywhere, but the third order started to close.

 
Izdesbyll:

Please help!

Error 0 and the order does not close! What is wrong?

How about trying it this way:

    double ld_Price;
    if (OrderType() == 0) ld_Price = NormalizeDouble (Bid, Digits);
    else ld_Price = NormalizeDouble (Ask, Digits);
    OrderClose (OrderTicket(), OrderLots(), ld_Price, 2);

And don't forget to EXCEED the relevant order before the deletion procedure!!!

 
Izdesbyll:
Now it's a total glitch, I'm writing:

i+1 = 2 and everywhere, but the third order started to close.

If you collect tickets in an array, the order should be SELECTED by TICKET, and not by its own list (order).
 
TarasBY:

How about trying it this way:

And don't forget to EXCEPT the relevant order before the delete procedure!!!


if (p[i+1]>0) 
    {
      Alert("Є прибуток ордер ",i+1);
      OrderSelect(i+1,SELECT_BY_POS,MODE_TRADES); 
      Alert("Маємо помилку ",GetLastError());
      Alert("Вибрали ордер ",i+1);
      double ld_Price;
      if (OrderType() == 0) ld_Price = NormalizeDouble (Bid, Digits);
      else ld_Price = NormalizeDouble (Ask, Digits);
      OrderClose (OrderTicket(), OrderLots(), ld_Price, 2);  
      Alert("Маємо помилку ",GetLastError());
      Alert("Закрили ордер ",i+1); 

The THIRD order closes GetLastError = 0, i+1=2, OrderProfit() responds to the SECOND order's naught. help.... I would write (OrderTicket()-1) but I'm afraid it won't help

 
Izdesbyll:

THIRD order closes GetLastError = 0, i+1=2, OrderProfit() responds to the SECOND order's naught. help.... I would write (OrderTicket()-1) but I'm afraid it won't help

do not know how to read (unless of course there are ticket numbers in p[] array)!

    OrderSelect (p[i+1], SELECT_BY_TICKET, MODE_TRADES); 

...In general, it's very hard to catch "stupidity" from a bit of code... :)

 
Hello, could someone please tell me if there is a kind of block to close all orders (including wiping of pending orders) if all with different magic numbers, in the range of 1-60. If there is one, please post it. And if it is not so difficult with instruction where it should be inserted (because it is completely green in mql). Thanks in advance.

I forgot to tell you, I would like to close on percentage of profit of deposit.
 
xxxKillxxx:
Hello, could someone please tell me if there is a kind of block to close all orders (including wiping of pending orders) if all with different magic numbers, in the range of 1-60. If there is one, please post it. And if it is not so difficult with instruction where it should be inserted (because it is completely green in mql). Thanks in advance.

I forgot to tell you, I would like to close on percentage of profit of deposit.

I want to close all orders in the terminal and delete all pending orders with any mode, as well as on the screen shows the current situation in a small unobtrusive line, as well as statistics in points of closed orders. Installed and works like a normal Expert Advisor. The default setting is to close all at 5% profit. The settings can be changed through the menu of the Expert Advisor.
Files:
profitclose.mq4  10 kb