How to implement the closing of positions one at a time after N minutes ? - page 7

 
Renat Akhtyamov:

Have you translated into English?

And in the experts tab it is in Russian?


No, everything is the default.

 
Natalya Dzerzhinskaya:

No, everything is by default.

in the experts tab please look - are the errors translated in russian?

 
Natalya Dzerzhinskaya:

Yes, the code works.

I use int instead of bool to close in your code

int close;

And one ticket is used for all closes buy and sell, but this is just for test. Maybe because of this there is an error because buy is closed and there is no close for sell.

Well, that's correct, that's the way it's supposed to be

 
Renat Akhtyamov:

in the experts tab, can you please check - are errors broadcast in russian?


Everything is broadcast in English

 
Natalya Dzerzhinskaya:

everything is broadcast in English

The original idea, according to your descriptions, was that

I put the code on the first page, at the end of which

if(TicketFirst>0)
{
//ну и пошло-поехало...
}

You needed to put one of 2 close functions in this condition and close the order found by the ticket (I put two), i.e.

if(TicketFirst>0)
{
                  if(OrderSelect(TicketFirst, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(TicketFirst,OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),0,clrRed);
                     if(close<0){if(Fun_Error(GetLastError())==1)return;}
                  }
                  if(OrderSelect(TicketFirst, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(TicketFirst,OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),0,clrBlue);
                     if(close<0){if(Fun_Error(GetLastError())==1)return;}
                  }

}

and place the error handling function after the whole code

Plus there should be some logic in the input condition to the close function, you haven't explained it to the end, I wrote about that too.

And it would be OK.

If left like that, the same ticket would be closed twice. There will be a 4108 error when closing an order with a ticket already closed the first time.

 
Renat Akhtyamov:

well that's right, that's the way it's meant to be

You should not think about it, but use help and write value of bool type.

However, you can use int, it won't change anything anyway.

Run the script, you can run it 50 times in a row, and the close variable will never equal -1. This means that errors will not translate in any language, not even in Chinese.

//+------------------------------------------------------------------+
#property version   "1.00"
#property strict
#property show_inputs

input int MyTicket = 451971753;

int close = -1;

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//закрытие по тикету, переделайте под свой

   if(OrderSelect(MyTicket,SELECT_BY_TICKET)==true)
     {
      close=OrderClose(MyTicket,OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),0,clrRed);
      if(close<0) Print("ERROR равен -1: ",close);
      if(close==0) Print("ERROR не может быть -1 НИКОГДА: ",close);
     }
  }


 
Vitaly Muzichenko:

You should not think about it, but use help and write value of bool type.

However, you can use int, it won't change anything anyway.

Run the script, you can run it 50 times in a row, and the close variable will never equal -1. This means that errors will not translate in any language, not even in Chinese.

Vitaly, you don't have to teach me.

I remember teaching you myself about a year or two ago how to switch to 5-circle, so you have less experience so far...

You didn't make one of mine, but you're saying...
 
Renat Akhtyamov:

Vitaly, you don't have to lecture me.

I remember teaching you myself about a year or two ago how to switch to a 5-crank, so you have less experience so far...

I even gave you an example, don't make yourself look bad!

 
Vitaly Muzichenko:

Yes I even gave an example, don't make yourself look bad!

It's not like you did one with mine, you did it your way, and you say...

What's your build anyway?

and you're not showing me the experts' tab, you're showing me the journal. That's two big differences.

The error in my case is broadcast by the Expert Advisor in the Expert Advisors tab.
 
Renat Akhtyamov:

You didn't make one of mine, you made one of your own, and you say...

What's your build, anyway?

and you're not showing me the experts tab, you're showing me the log. There's actually two big differences.

The error in my case is transmitted by the Expert Advisor in the Expert Advisors tab.

I get it, you're trying to troll me.

Okay, I'm out of here.

No, I guess I'll just write to servicedesk and tell them I got a faulty terminal.