Alerts sent to MT5 app

 

Friends,


With Metatrader 5 open on my desktop I would like to receive notifications in the app (for certain conditions, example, SMA crossings, etc) 

I have tested the push notifications for the APP (the standard test) and it worked.

But my coded alerts do not make any push notifications in my mobile app. What would be the problem ? Is there a specific line of code that communicates with the mobile app ?

//+------------------------------------------------------------------+
//|                                                  EA_Telegram.mq5 |
//|                                          Copyright 2020, CMTrade |
//+------------------------------------------------------------------+
#property copyright "xxx"
#property link      "xxx"
#property version   "1.00"


int cLastAcimaMM=0;
int cLastAbaixoMM=0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(5);
   
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
double Last=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_LAST),_Digits);
double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);

bool LastAcimaMM=false;
bool LastAbaixoMM=false;


double Buffer_A[];//A sempre é a MM mais rapida
int Handle_A=iMA(_Symbol,PERIOD_M1,50,0,MODE_SMA,PRICE_MEDIAN);
ArraySetAsSeries(Buffer_A,true);
CopyBuffer(Handle_A,0,0,21,Buffer_A);

double Buffer_B[];//A sempre é a MM mais rapida
int Handle_B=iMA(_Symbol,PERIOD_M10,10,0,MODE_SMA,PRICE_MEDIAN);
ArraySetAsSeries(Buffer_B,true);
CopyBuffer(Handle_B,0,0,21,Buffer_B);

double Buffer_C[];//A sempre é a MM mais rapida
int Handle_C=iMA(_Symbol,PERIOD_M15,10,0,MODE_SMA,PRICE_MEDIAN);
ArraySetAsSeries(Buffer_C,true);
CopyBuffer(Handle_C,0,0,21,Buffer_C);

if(Last>Buffer_A[0] && Last>Buffer_B[0] && Last>Buffer_C[0]){   
   LastAcimaMM=true;
   cLastAcimaMM++;
   cLastAbaixoMM=0;
}


if(Last<Buffer_A[0] && Last<Buffer_B[0] && Last>Buffer_C[0])  { 
   LastAbaixoMM=true;   
   cLastAbaixoMM++;
   cLastAcimaMM=0;   
}

if(cLastAcimaMM==1){
   Alert(_Symbol + " AcimaMMs");
   PlaySound("alert.wav");
}   

if(cLastAbaixoMM==1){
   Alert(_Symbol + " AbaixoMMs");
   PlaySound("alert.wav");
}   

//just for test putting "true" the alert works on desktop!
if(false){
   Alert(_Symbol + " AcimaMMs");
   PlaySound("alert.wav");
}   
  }
xavierbell
xavierbell
  • www.mql5.com
Added topic Alerts as a push notifications while mt5 is offline Hey guys i have really the small problem but it's really hard to find the right solution the case: i want to get my alerts which i did in desktop version on my mobile as a push notifications . the only way it works now- when my computer is running
 
int Handle_A=iMA(_Symbol,PERIOD_M1,50,0,MODE_SMA,PRICE_MEDIAN);

CopyBuffer(Handle_A,0,0,21,Buffer_A);

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010
 
William Roeder:

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

Thank you, maybe your suggestion could make my code more efficient.

But the real question regards communication with the MT5 app... How to make the alerts notificate the app in the smartphone (android) ?

Reason: