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

 

Hi all.

I'm asking for help with this question.

I have an mt4 terminal and an Expert Advisor (homemade) which generates alerts for trading signals. I want the alerts to be sent to the mobile terminal. I configured it, the test comes, changes in order parameters come, but the alerts from the EA do not come... I do not know what the reason is, google did not give me any answers.

The alerts are reflected in the terminal itself.
 
and yet it's an awkward place to chat. Some sort of stackoverflow and/or discord channel would be nice.
 
Sergey Dymov changes in order parameters come, but the alerts from the EA do not come... I do not know what the reason is, google did not give me any answers.
You have to see the code...there are no telepaths here)
 
MakarFX #:
I need to see the code... no telepaths here)

Everything is standard

if ((EURTP>=3)&&(JPYTP<=0)&&(z!=2))

{Alert("Buy EURJPY. EUR=", EURTP, ", JPY=", JPYTP); z=2;} //

 
Sergey Dymov changes in order parameters come, but the alerts from the EA do not come... I do not know what is the reason, google did not give me any answers. The alerts are reflected in the terminal itself.

https://www.mql5.com/ru/docs/network/sendnotification

https://docs.mql4.com/ru/common/sendnotification

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

Everything is standard

if ((EURTP>=3)&&(JPYTP<=0)&&(z!=2))

{Alert("Buy EURJPY. EUR=", EURTP, ", JPY=", JPYTP); z=2;} //

if ((EURTP>=3)&&(JPYTP<=0)&&(z!=2))
    {
     Alert("Покупай EURJPY. EUR=", EURTP, ", JPY=", JPYTP); z=2;
     SendNotification(текст сообщения);
    } 
 
Thanks, guys! I'll never forget it!
 

OK, I've created and deleted lines by click only, and the colour and name change with the location of the cursor and... nothing has changed, same problems. The line is created depending on the location of the button bar. I have it at the bottom, so by condition it is yellow (Sell Stop) but here there is an occurrence in condition if(price > Ask) because when I click on the button for some crap price is equal to the highest price on the chart, that is higher than Ask, so at this point price > Ask = true. Well, fuck it, logically the next move of the mouse should fix everything, but no. Log only one click on the button.

2021.12.07 03:05:56.888 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:05:53.408 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:05:53.408 test GBPUSD,M1: Stop Loss rename onto Buy Stop false error 0
2021.12.07 03:05:53.408 test GBPUSD,M1: Buy Stop rename onto Sell Stop true error 0
2021.12.07 03:05:53.408 test GBPUSD,M1: Sell Stop rename onto Buy Stop true error 0
2021.12.07 03:05:53.408 test GBPUSD,M1: Sell Stop create true error 4204

I don't know why 4204 (No Object) maybe it's a past error.

After clicking on the button you can see a green line at Bid level, the line does not respond to a mouse cursor shift. If the cursor moves above the Asc, the messages are continually poured out

2021.12.07 03:14:00.993 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:13:59.563 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:13:57.363 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:13:57.253 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:13:57.223 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:13:57.223 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:13:57.193 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
2021.12.07 03:13:57.153 test GBPUSD,M1: Buy Stop rename onto Buy Stop false error 0
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
    datetime static dt          = 0;
    double   static price       = 0;
    int      static window      = 0;
    double   static sl          = 0;
    string   static line_name;
    double static price2 = 0;
    double static price3 = 0;
    double static price4 = 0;


  if(id==CHARTEVENT_OBJECT_CLICK){
    //Нажатие на SO в зависимоти от расположения панели создаёт линию
    if(sparam=="Button Stop Order"){
      if(panel_position == 1 || panel_position == 2){
        line_name = "Buy Stop";
        CreateLine(line_name, clrGreen);
      }
      if(panel_position == 3 || panel_position == 4){
        line_name = "Sell Stop";
        CreateLine(line_name, clrYellow);
      }
    }
    //Нажатие на линию меняет цвет на красный
    if(sparam=="Buy Stop" || sparam=="Sell Stop") {
      ObjectSetString(0,line_name,OBJPROP_NAME,"Stop Loss");
      line_name = "Stop Loss";
      Print(line_name, " onto red ",ObjectSetInteger(0, line_name, OBJPROP_COLOR, clrRed));
    }
    //Нажатие на красной линии удаляет её и отжимает кнопку
    if(sparam=="Stop Loss"){
      ObjectDelete(line_name);
      button_name = "Button Stop Order";
      ms=GetMicrosecondCount();
    }
  }
  //Если кнопка SO нажата, то линия будет следовать за курсором
  if(ObjectGetInteger(0,"Button Stop Order",OBJPROP_STATE)){
    int x = (int)lparam;
    int y = (int)dparam;
    //Переведём координаты X, Y в дату и время
    if(ChartXYToTimePrice(window,x,y,window,dt,price)){
      Comment(StringFormat("CURSOR PRICE %.5f \nIF PRICE > ASK %.5f\nIF PRICE < BID %.5f\nIF PRICE IN SPREAD ZONE %.5f",
                            price,price2,price4,price3));
      //Линия меняет цвет с зелёного на желтый
      if(price < Bid){
        price4 = price;
        if(ObjectExist(0,"Buy Stop") || ObjectExist(0,"Not Allowed")){
          Print(line_name," rename onto Sell Stop ", ObjectSetString(0,line_name,OBJPROP_NAME,"Sell Stop")," error ", GetLastError());
          line_name = "Stop Loss";
          ObjectSetInteger(0, line_name, OBJPROP_COLOR, clrYellow);
        }
      }
      //Линия меняет цвет с желтого на зелёный
      if(price > Ask){
        price2 = price;
        if(ObjectExist(0,"Sell Stop") || ObjectExist(0,"Not Allowed")){
          Print(line_name," rename onto Buy Stop ", ObjectSetString(0,line_name,OBJPROP_NAME,"Buy Stop")," error ", GetLastError());
          line_name = "Buy Stop";
          ObjectSetInteger(0, line_name, OBJPROP_COLOR, clrGreen);
        }
      }
      //Линия меняет цвет на серый если в зоне спреда
      if(price > Bid && price < Ask){
        price3 = price;
        if(ObjectExist(0,"Sell Stop") || ObjectExist(0,"Buy Stop")){
          Print(line_name," rename onto Not Allowed ", ObjectSetString(0,line_name,OBJPROP_NAME,"Not Allowed")," error ", GetLastError());
          line_name = "Not Allowed";
          ObjectSetInteger(0, line_name, OBJPROP_COLOR, clrGray);
        }
      }
      //Прикрепляем линию к курсору
      if(id == CHARTEVENT_MOUSE_MOVE)
        if(ObjectMove(line_name,0,0,price))
          ChartRedraw(0);
    }
  }else if(ObjectExist(0,line_name)) Print(line_name," delete ",ObjectDelete(line_name)," error ", GetLastError());
  //Если нажать Esc то удалится линия и кнопка отожмется
  if(id == CHARTEVENT_KEYDOWN && lparam == 27){
      button_name = "Button Stop Order";
      ms=GetMicrosecondCount();
  }
}
//----------------------------------------------------------------------
void CreateLine(const string name, const color clr)
{
  Print(name," create ",ObjectCreate(0, name, OBJ_HLINE, 0,TimeCurrent(),Bid)," error ", GetLastError());
  ObjectSetInteger(0, name, OBJPROP_COLOR, clr);
  ObjectSetInteger(0, name, OBJPROP_STYLE, 3); 
}
bool ObjectExist(const long _chartID, const string _name) { return(ObjectFind(_chartID, _name) >= 0); }
 
Nerd Trader #:


My advice to you, as a novice programmer. Learn how to use debug (a very powerful tool). And figure it out for yourself. It's interesting. If it gets complicated (which is unlikely), start with an easy one. Debug will help you figure out how your application works in great detail.

Отладка программ на MQL5
Отладка программ на MQL5
  • www.mql5.com
Эта статья ориентирована в первую очередь на программистов, которые уже изучили язык, но еще недостаточно освоились в разработке программ. Статья раскрывает практические приемы отладки программ и является объединенным опытом, не только моим, но и многих программистов, на опыте которых я учился.
 
Mihail Matkovskij #:

My advice to you, as a novice programmer. Learn how to use debug (a very powerful tool). And figure it out for yourself. It's interesting. If it gets complicated (which is unlikely), start with an easy one. Debug should help you figure out how your application works down to the smallest detail.

I usually don't need it because it doesn't work in the tester, but in this case it works with real data and you should give it a try. What I understand, version of this code with renaming object is not different from last time, when objects were recreated with colour change, because renaming does the same thing: it creates object with new name and deletes old one.


UPD

Buttons I use to create lines in mql4 in debug mode are absent in the chart

Reason: