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

 
Ihor Herasko:

Excuse me. The line:

needs to be rewritten like this:


(OrderCloseTime()> 0) works, I'll leave it like that then

Thanks again))

Renat Akhtyamov:

закрытие по тикету, переделайте под свой

Also closes fine, but after closing it writes error 4108"Invalid ticket number."


 
Natalya Dzerzhinskaya:

(OrderCloseTime()> 0) works, I'll leave it that way then

Thanks again)))


Also closes fine, but after closing it says error 4108"Wrong ticket number."


So it's really wrong, won't lie.

Look into your code logic.

And you do one command to close or two?

If you've closed it once, there's nothing to do for the second, and the previous ticket will already be invalid.

 
Renat Akhtyamov:

So it's really wrong, it won't lie.

Look into the logic of your code.

Do you run one close command or two?

If you close once, there is nothing to do for the second, and the previous ticket will already be incorrect.


Your code's"close" variable will never be less than zero, read the help.

 
Ihor Herasko:

Fair points above. Why go through all the orders again if the ticket is already known?

You can close the orders immediately, when the overshoot is done.
Why search for time? Compare - close - next.
 
Taras Slobodyanik:

your code's "close" variable will never be less than zero, read the help

read it yourself...

-----------

Return value

Returns true if the function completed successfully or false if there was an error. To get the error information you need to call GetLastError().

Коды возврата торгового сервера - Коды ошибок и предупреждений - Стандартные константы, перечисления и структуры - Справочник MQL4
Коды возврата торгового сервера - Коды ошибок и предупреждений - Стандартные константы, перечисления и структуры - Справочник MQL4
  • docs.mql4.com
GetLastError() - функция, возвращающая коды ошибок. Кодовые константы ошибок определены в файле stderror.mqh. Для вывода текстовых сообщений следует использовать функцию ErrorDescription(), определенную в файле stdlib.mqh.
 
Renat Akhtyamov:

Read for yourself...

-----------

Returned value

Returns true if function completed successfully or false in case of error. To get information about the error, call GetLastError().


you don't even know the difference between types of variables)

you need to learn.

 
Taras Slobodyanik:

so you don't even know the types of variables)

You need to learn.


Forum on trading, automated trading systems and strategy testing

How to implement closing positions one by one after N-minutes ?

Natalya Dzerzhinskaya, 2017.11.22 19:17


(OrderCloseTime()> 0) works, I will leave it that way then

Thanks again)))


Also closes fine, but after closing it writes error 4108"Invalid ticket number."


Is it from the sky or something?

)

Good luck with your studies!
 
Renat Akhtyamov:

Does it come out of the sky or something?

)

Good luck with your studies!

Under what conditions could it ever work, even once every 100 years?

                  if(OrderSelect(MyTicketBuy, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(MyTicketBuy,OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),0,clrRed);
                     if(close<0){if(Fun_Error(GetLastError())==1)return;}
                  }
                  if(OrderSelect(MyTicketSell, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(MyTicketSell,OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),0,clrBlue);
                     if(close<0){if(Fu n_Error(GetLastError())==1)return;}
                  }
 
Vitaly Muzichenko:

Under what conditions could it ever work, even once every 100 years?

Well Vitaly, I don't know...............

You've got it in your post working out......

Careful, the function is on the previous page.
 
Renat Akhtyamov:

Well Vitaly, I don't know...............

You've got it in your post......

Careful, the function is on the previous page.

My point is thatclose can only be either 0(false) or 1(true), there is no other.

The same, for reliability it is better to write:

close=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),0,clrRed);
Reason: