Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1854

 
Mihail Matkovskij #:

Of course there is no point. But after a certain interval it is still worth trying to close this order (position). Because. Firstly, the open position cannot hang forever. Secondly, the position itself cannot be closed forever. Sooner or later, the server will accept a request to close the order(to exit the position). And if you do nothing, the result will be as I mentioned above. The deposit may fall into a big drawdown or it may be sold out.

It has been skipped recently, brokerage company disabled auto-trading on the server. It was 1 minute ago and then it was cut off.

Will we still try to close it?

 
Vitaly Muzichenko #:

It has been mentioned recently that the DC has disabled the ability to auto-trade on the server. It was 1 minute ago and then they turned it off.

Will we still try to close?

The message is correct when there are critical errors in closing positions.

 
Vitaly Muzichenko #:

It has been mentioned recently that the DC has disabled the ability to auto-trade on the server. It was 1 minute ago and then they turned it off.

Still going to try and shut it down?

Well, then we can call

AccountInfoInteger(ACCOUNT_TRADE_EXPERT)

And also

AccountInfoInteger(ACCOUNT_TRADE_ALLOWED)

И

TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)

Just in case. And do nothing with corresponding result of any or all functions. And handle errors resulting from unsuccessful closing accordingly.

In any case, we will guarantee that the robot will not trade as long as at least one of the functions prohibits it.

Документация по MQL5: Программы MQL5 / Разрешение на торговлю
Документация по MQL5: Программы MQL5 / Разрешение на торговлю
  • www.mql5.com
Разрешение на торговлю - Программы MQL5 - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Mihail Matkovskij #:

Well, and handle errors as a result of failed close accordingly.

Only I don't know, if OrderSend is called and the server has disabled the trade,will OrderSend return false or will the request be sent to the server first and then it will return a response? If the latter, then OrderSend will return true. And then you definitely need to add a function () to blockOrderSend function calls. And if the first one, then the request won't even be sent to the queue, because OrderSend returned false. Does it make sense?

 
Mihail Matkovskij #:

Only I don't know, if OrderSend is called and the server has disabled the trade,will OrderSend return false or will the request be sent to the server first and then it will return a response? If the latter, then OrderSend will return true. And then you definitely need to add a function () to blockOrderSend function calls. And if the first one, then the request won't even be sent to the queue, because OrderSend returned false. Does it make sense?

OrderSend returns a ticket when successful :)

I'll probably go to the newbie branch

 
Vitaly Muzichenko #:

OrderSend returns a ticket on success :)

I will probably go to the newbies branch

OrderSend in MQL4 returns a ticket. And in MQL5 it is a bool. I'm used to consideringMQL5 fictions.I forgot a little about MQL4 (because I'm used to porting applications from MQL5 to MQL4). In MQL5 the OrderSend bool opens and closes positions as well as creates/deletes orders. MQL5 has functions for orders, deals and positions. In MQL4, int OrderSend is for entry, and bool OrderClose is for exit. There is also bool OrderDelete for pending orders. And inMQL4 only orders are divided into market and pending orders. You made me remember what is the difference between these two languages. :)

So, one cannot know everything. And it is very easy to get confused.

 
Tretyakov Rostyslav #:

If a closing condition occurs

//-------------------------------------------------------------------+  Команда на закрытие сетки ордеров
   if((CountTrade(0) > 1 && CalculiteProfit() >= 0 && OrderGroupCloseSignal()==0)||(CountTrade(1) > 1 && CalculiteProfit() >= 0 && OrderGroupCloseSignal()==1))
     {
      flag_close=1;
     }

Here the condition is CalculiteProfit() >= 0. In this case we can calculate at what price the necessary profit will be for these positions and set there take profit or stop loss, depending on the prices and positions. And because the Buy and Sell positions are closed at different prices this is only appropriate if the positions are of the same type.

 
Andrey Sokolov #:

The condition here is CalculiteProfit() >= 0, in which case you can calculate at what price the necessary profit will be for these positions and set a take profit there.

Not me)

EVGENII SHELIPOV is the author of conditions.

 

Greetings. Can you give me a hint?

In the mt5 robot I need to put a curve like a moving average on the chart. Is there a more "civilised" way than sculpting from objects, and if so, what is it?

 
Andrey Sokolov #:

Greetings. Can you give me a hint?

In the mt5 robot I need to put a curve like a moving average on the chart. Is there a more "civilised" way than sculpting from objects, and if so, what is it?

Yes - display it
Reason: