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

 
MakarFX:

I don't know, I'll have to check.

What is there to check...? If we assume that the history contains several trades with the same closing time, they must be processed sequentially, one after another. TheOnTradeTransaction handler does exactly that (handles trade events) and there is no need to invent a "wheel".

 
Mihail Matkovskij:

What's there to check...? If we assume that there are several trades with the same closing time in the history, then they must be processed sequentially, one after another. TheOnTradeTransaction handler does just that (handles trade events) and there is no need to invent a "wheel".

as an alternative to the total profit

profit+=HistoryDealGetDouble(ticket,DEAL_PROFIT); 
 
MakarFX:

as an option for total profit

No. That is not an option!

 
Mihail Matkovskij:

No. That's not an option!

Why not?
 
Eugen8519:

Alternatively, trade alerts can be enabled in the terminal and the server will send them to the mobile apphttps://www.metatrader5.com/ru/releasenotes .

Что нового в MetaTrader 5?
Что нового в MetaTrader 5?
  • www.metatrader5.com
Всего поддерживаются три типа уведомлений: об ордерах, о сделках и о балансовых операциях. При включении опции доступные виды уведомлений будут выведены в журнал терминала:
 
Mihail Matkovskij:

Alternatively, trade alerts can be enabled in the terminal and the server will send them to the mobile apphttps://www.metatrader5.com/ru/releasenotes .

It seems to be the best option)
 
MakarFX:
Why?

Because trades cannot be skipped. Imagine 2 trades closed on the TP and you only sent notification of one. Or their total profit (as you suggested). What is that supposed to tell the user...? Not clear... :)

Let me explain even more clearly. The number of notifications must always correspond to the number of trades.

Plus,SendNotification has limitations on the frequency of sending notifications. So, we have to make sure that the application calls the function no more than 2 times per second and no more than 10 times per minute. Create a queue of notifications and send them no more often than specified in the documentation.

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

Because trades cannot be skipped. Imagine 2 trades closed on the TP and you only sent notification of one. Or their total profit (as you suggested). What is that supposed to tell the user...? Not clear... :)

You haven't seen his EA.

I told you, as far as I understood he wanted notifications of orders opening and closing, and it does not matter what the reason is.

The man wants to see on his phone that the EA is doing something.

 
MakarFX:

You haven't seen his EA.

I told you, as far as I understood he wants notifications about opening and closing orders and it doesn't matter for what reason.

The man wants to see on his phone that the EA is doing something.

I have edited the previous post.

No. He wants to track closing by SL and TP.

This is the forum for trading, automated trading systems and strategy testing.

Any questions from newbies in MQL4 and MQL5, help and discussion on algorithms and codes

Eugen8519, 2021.08.07 12:20



Help me to position the function correctly

SendNotification ("текст");




Inserted it to report entry into position here

void OPENORDER(string ord)

  {
  
  double priceL=m_symbol.Ask();
   if(ord=="Sell")      
    SendNotification ("текст");

        //--- check for free money
            if(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_BUY,my_lot,priceL)<0.0)
               printf("We have no money. Free Margin = %f",m_account.FreeMargin());
            else
      if(!m_trade.Sell(my_lot,Symbol(),m_symbol.Bid(),my_SL,my_TP,""))
         Print("BUY_STOP -> false. Result Retcode: ",m_trade.ResultRetcode(),
               ", description of Retcode: ",m_trade.ResultRetcodeDescription(),
               ", ticket of order: ",m_trade.ResultOrder());                     // Если sell, то не открываемся
     double priceS=m_symbol.Bid();
   if(ord=="Buy")
    SendNotification ("текст");
 //--- check for free money
            if(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_SELL,my_lot,priceS)<0.0)
               printf("We have no money. Free Margin = %f",m_account.FreeMargin());
            else
      if(!m_trade.Buy(my_lot,Symbol(),m_symbol.Ask(),my_SL,my_TP,""))
 
         Print("Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
               ", description of result: ",m_trade.ResultRetcodeDescription(),
               ", ticket of deal: ",m_trade.ResultDeal());
   return;
 }

And I am already successfully getting notifications on my smartphone.




But how and where to insert

SendNotification

To get a message when I reach stop loss ortake profit?


 
Mihail Matkovskij:

Edited the previous message.

No. What he needs to do is track the SL and TP closures.

OK, you're right. I got it wrong.