Mobile notifications

 
Im getting my alerts on my pc and i enabled them for my phone and put in the code but im not getting them on my phone. Also when I test the notification it works. Any ideas on what this is?
 
Tiberious:
Im getting my alerts on my pc and i enabled them for my phone and put in the code but im not getting them on my phone. Also when I test the notification it works. Any ideas on what this is?

Do not double post!

I have deleted your duplicate topic.

Nobody can help you if you don't show your code.

 
Here is the code what I added was - input bool SendNotification = true; and I have the messages linked to my phone, when I test it works just fine, but not when I get an actual alret
#property strict



double LotsToTrade = 0.1;     //Lot size : Due to change

double Magic = 8;
int MaxTrades = 50;

int MaxCloseSpreadPips = 7;
//double StopLoss = 0;
//double ProfitTarget = 0;

// Trade Time Delay
int TradeDelayTimeSeconds = (1 * 1 * 5 * 60);      //5 minute delay
datetime LastTradePlacedTimestamp = 0;

extern bool ShowAlertsOnly = true;      //Only show alerts when signals.
input bool SendNotification = true;

extern string sep0 = " ********** Dynamic SL / TP Settings **********";
extern int Number_Of_Lookback_Candles = 15;
extern bool is_Dynamic_SL = true;
extern double SL_Percentage = 113;
extern bool is_Dynamic_TP = true;
extern double TP_Percentage = 100;



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
{
    SL_Percentage = SL_Percentage - 100;

    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
    double SlowMovingAverage = iMA(NULL, 0, 365, 0, MODE_SMA, PRICE_CLOSE, 0);
    //double FastMovingAverage = iMA(NULL, 0, 180, 0, MODE_SMA, PRICE_CLOSE, 0);

    double LowerBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 1);
    double UpperBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 2);
    double PrevLowerBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 2);
    double PrevUpperBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 2);

    double RsiIndicator      = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);


    if (GetTotalOpenTrades() < MaxTrades)
    {

        if ((TimeCurrent() - LastTradePlacedTimestamp) < TradeDelayTimeSeconds) return;
        int signal = CheckEntrySignal();

        static datetime last_alert_time = 0;
        if(signal != -1 && ShowAlertsOnly)
        {
            if((TimeCurrent() - last_alert_time) > TradeDelayTimeSeconds)
            {
                string msg = "New " + (signal == OP_BUY ? "Buy" : "Sell") + " signal on " + _Symbol;
                Alert(msg);
                last_alert_time = TimeCurrent();
            }
            return;
        }

        //*************************************************************************************************************************
        //Buy Paramaters
        if (signal == OP_BUY
                //(Close[1] > SlowMovingAverage) && RsiIndicator <= 30 && (Close[2] < PrevLowerBB && Close[1] > LowerBB )
           )
        {
            // Here Updating SL / TP
            double takeprofit = 0, stoploss = 0;

            // Finding Highest Point and converting it into points;
            double val = getHighestValue();
            double diff = NormalizeDouble(val - Close[1], Digits()) / Point;
            Print("Total Points from High to entry are " + diff);
            if(is_Dynamic_TP)
            {
                takeprofit = NormalizeDouble(Ask + ((diff * (TP_Percentage / 100)) * Point()), Digits());
            }
            if(is_Dynamic_SL)
            {
                stoploss = NormalizeDouble(Ask - ((diff * (SL_Percentage / 100)) * Point()), Digits());
            }

            int OrderResult = OrderSend(Symbol(), OP_BUY, LotsToTrade, Ask, 10, stoploss, takeprofit, NULL, Magic, 0, clrAliceBlue);
            LastTradePlacedTimestamp = TimeCurrent();
        }

        //Sell Paramaters
        else if (
            signal == OP_SELL
            //(Close[1] < SlowMovingAverage) && RsiIndicator >= 70 && (Close[2] > PrevUpperBB && Close[1] < UpperBB)
        )
        {
            // Here Updating SL / TP
            double takeprofit = 0,  stoploss = 0;

            // Finding Highest Point and converting it into points;
            double val = getLowestValue();
            double diff = NormalizeDouble(Close[1] - val, Digits()) / Point;
            Print("Total Points from Low to entry are " + diff);
            if(is_Dynamic_TP)
            {
                takeprofit = NormalizeDouble(Bid - ((diff * (TP_Percentage / 100)) * Point()), Digits());
            }
            if(is_Dynamic_SL)
            {
                stoploss = NormalizeDouble(Bid + ((diff * (SL_Percentage / 100)) * Point()), Digits());
            }

            int OrderResult = OrderSend(Symbol(), OP_SELL, LotsToTrade, Bid, 10, stoploss, takeprofit, NULL, Magic, 0, clrCrimson);
            LastTradePlacedTimestamp = TimeCurrent();
        }
        //**************************************************************************************************************************
    }
    //if (GetTotalProfits() > ProfitTarget) CloseAllTrades();
    //if (GetTotalProfits() < StopLoss) CloseAllTrades();

}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CheckEntrySignal()
{
    double SlowMovingAverage = iMA(NULL, 0, 365, 0, MODE_SMA, PRICE_CLOSE, 0);
    if(Open[2] > Close[2]
            && Close[2] < iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 2)
            && iRSI(_Symbol, _Period, 14, PRICE_CLOSE, 2) <= 30
            ///////////
            && Open[1] < Close[1]
            && Open[1] < iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 1)
            //
            && Close[1] > SlowMovingAverage
      )
        return OP_BUY;

    if(Open[2] < Close[2]
            && Close[2] > iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 2)
            && iRSI(_Symbol, _Period, 14, PRICE_CLOSE, 2) >= 70
            ///////////
            && Open[1] > Close[1]
            && Open[1] > iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 1)
            && Close[1] < SlowMovingAverage
      )
        return OP_SELL;

    return -1;
}

//Return the total Number of open Trades
int GetTotalOpenTrades()
{

    int TotalTrades = 0;

    //Loop through open orders and add them to TotalTrades
    for (int t = 0; t < OrdersTotal(); t++)
    {

        if(OrderSelect(t, SELECT_BY_POS, MODE_TRADES))
        {
            if(OrderSymbol() != Symbol()) continue;
            if(OrderMagicNumber() != Magic) continue;
            if(OrderCloseTime() != 0) continue;

            TotalTrades = (TotalTrades + 1);
        }
    }

    return TotalTrades;

}



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAllTrades()
{

    int CloseResult = 0;

    for (int t = 0; t < OrdersTotal(); t++)
    {

        if(OrderSelect(t, SELECT_BY_POS, MODE_TRADES))
        {

            if (OrderMagicNumber() != Magic) continue;
            if (OrderSymbol() != Symbol()) continue;
            if (OrderType() == OP_BUY) CloseResult = OrderClose(OrderTicket(), OrderLots(), Bid, MaxCloseSpreadPips, clrAliceBlue);
            if (OrderType() == OP_SELL) CloseResult = OrderClose(OrderTicket(), OrderLots(), Ask, MaxCloseSpreadPips, clrCrimson);

            t--;
        }

    }
    return;
}
//Check total profit for all trades combined
double GetTotalProfits()
{

    double TotalProfits = 0.0;
    for (int t = 0; t < OrdersTotal(); t++)
    {

        if(OrderSelect(t, SELECT_BY_POS, MODE_TRADES))
        {

            if (OrderMagicNumber() != Magic) continue;
            if (OrderSymbol() != Symbol()) continue;
            if (OrderCloseTime() != 0) continue;
            TotalProfits = (TotalProfits + OrderProfit());
        }
    }
    return TotalProfits;

}



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double getHighestValue()
{
    double hi = -999999;
    for(int i = 1 ; i < Number_Of_Lookback_Candles ; i++)
    {
        if(High[i] > hi)
        {
            hi = High[i];
        }
    }
    return hi;
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double getLowestValue()
{
    double lo = 999999;
    for(int i = 1 ; i < Number_Of_Lookback_Candles ; i++)
    {
        if(Low[i] < lo)
        {
            lo = Low[i];
        }
    }
    return lo;
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
 
Tiberious:
Here is the code what I added was - input bool SendNotification = true; and I have the messages linked to my phone, when I test it works just fine, but not when I get an actual alret
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property strict



double LotsToTrade = 0.1;     //Lot size : Due to change

int Magic = 8;
int MaxTrades = 50;

int MaxCloseSpreadPips = 7;
//double StopLoss = 0;
//double ProfitTarget = 0;

// Trade Time Delay
int TradeDelayTimeSeconds = (1 * 1 * 5 * 60);      //5 minute delay
datetime LastTradePlacedTimestamp = 0;

extern bool ShowAlertsOnly = true;      //Only show alerts when signals.
input bool SendNotificationx = true;

extern string sep0 = " ********** Dynamic SL / TP Settings **********";
extern int Number_Of_Lookback_Candles = 15;
extern bool is_Dynamic_SL = true;
extern double SL_Percentage = 113;
extern bool is_Dynamic_TP = true;
extern double TP_Percentage = 100;



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   SL_Percentage = SL_Percentage - 100;

   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   double SlowMovingAverage = iMA(NULL, 0, 365, 0, MODE_SMA, PRICE_CLOSE, 0);
//double FastMovingAverage = iMA(NULL, 0, 180, 0, MODE_SMA, PRICE_CLOSE, 0);

   double LowerBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 1);
   double UpperBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 2);
   double PrevLowerBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 2);
   double PrevUpperBB = iBands(NULL, 0, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 2);

   double RsiIndicator      = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);


   if(GetTotalOpenTrades() < MaxTrades)
     {

      if((TimeCurrent() - LastTradePlacedTimestamp) < TradeDelayTimeSeconds)
         return;
      int signal = CheckEntrySignal();

      static datetime last_alert_time = 0;
      static datetime last_Notify_time = 0;
      
      /////////////////Send Notify ///
      if(signal != -1 && SendNotificationx)
        {
         if((TimeCurrent() - last_Notify_time) > TradeDelayTimeSeconds)
           {
            string msg = "New " + (signal == OP_BUY ? "Buy" : "Sell") + " signal on " + _Symbol;
            SendNotification(msg);
            last_Notify_time = TimeCurrent();
           }
         //return;
        }
        //// End Notfify  
      if(signal != -1 && ShowAlertsOnly)
        {
         if((TimeCurrent() - last_alert_time) > TradeDelayTimeSeconds)
           {
            string msg = "New " + (signal == OP_BUY ? "Buy" : "Sell") + " signal on " + _Symbol;
            Alert(msg);
            last_alert_time = TimeCurrent();
           }
         return;
        }

      //*************************************************************************************************************************
      //Buy Paramaters
      if(signal == OP_BUY
         //(Close[1] > SlowMovingAverage) && RsiIndicator <= 30 && (Close[2] < PrevLowerBB && Close[1] > LowerBB )
        )
        {
         // Here Updating SL / TP
         double takeprofit = 0, stoploss = 0;

         // Finding Highest Point and converting it into points;
         double val = getHighestValue();
         double diff = NormalizeDouble(val - Close[1], Digits()) / Point;
         Print("Total Points from High to entry are " + string(diff));
         if(is_Dynamic_TP)
           {
            takeprofit = NormalizeDouble(Ask + ((diff * (TP_Percentage / 100)) * Point()), Digits());
           }
         if(is_Dynamic_SL)
           {
            stoploss = NormalizeDouble(Ask - ((diff * (SL_Percentage / 100)) * Point()), Digits());
           }

         int OrderResult = OrderSend(Symbol(), OP_BUY, LotsToTrade, Ask, 10, stoploss, takeprofit, NULL, Magic, 0, clrAliceBlue);
         if(GetLastError()==0 && SendNotificationx)
         {
          SendNotification(Symbol()+" BUY ORDER OPEN");
         }
         LastTradePlacedTimestamp = TimeCurrent();
        }

      //Sell Paramaters
      else
         if(
            signal == OP_SELL
            //(Close[1] < SlowMovingAverage) && RsiIndicator >= 70 && (Close[2] > PrevUpperBB && Close[1] < UpperBB)
         )
           {
            // Here Updating SL / TP
            double takeprofit = 0,  stoploss = 0;

            // Finding Highest Point and converting it into points;
            double val = getLowestValue();
            double diff = NormalizeDouble(Close[1] - val, Digits()) / Point;
            Print("Total Points from Low to entry are " + string(diff));
            if(is_Dynamic_TP)
              {
               takeprofit = NormalizeDouble(Bid - ((diff * (TP_Percentage / 100)) * Point()), Digits());
              }
            if(is_Dynamic_SL)
              {
               stoploss = NormalizeDouble(Bid + ((diff * (SL_Percentage / 100)) * Point()), Digits());
              }

            int OrderResult = OrderSend(Symbol(), OP_SELL, LotsToTrade, Bid, 10, stoploss, takeprofit, NULL, Magic, 0, clrCrimson);
            if(GetLastError()==0 && SendNotificationx)
         {
          SendNotification(Symbol()+" SELL ORDER OPEN!.");
         }
            LastTradePlacedTimestamp = TimeCurrent();
           }
      //**************************************************************************************************************************
     }
//if (GetTotalProfits() > ProfitTarget) CloseAllTrades();
//if (GetTotalProfits() < StopLoss) CloseAllTrades();

  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CheckEntrySignal()
  {
   double SlowMovingAverage = iMA(NULL, 0, 365, 0, MODE_SMA, PRICE_CLOSE, 0);
   if(Open[2] > Close[2]
      && Close[2] < iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 2)
      && iRSI(_Symbol, _Period, 14, PRICE_CLOSE, 2) <= 30
///////////
      && Open[1] < Close[1]
      && Open[1] < iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_LOWER, 1)
//
      && Close[1] > SlowMovingAverage
     )
      return OP_BUY;

   if(Open[2] < Close[2]
      && Close[2] > iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 2)
      && iRSI(_Symbol, _Period, 14, PRICE_CLOSE, 2) >= 70
///////////
      && Open[1] > Close[1]
      && Open[1] > iBands(_Symbol, _Period, 20, 2.0, 0, PRICE_CLOSE, MODE_UPPER, 1)
      && Close[1] < SlowMovingAverage
     )
      return OP_SELL;

   return -1;
  }

//Return the total Number of open Trades
int GetTotalOpenTrades()
  {

   int TotalTrades = 0;

//Loop through open orders and add them to TotalTrades
   for(int t = 0; t < OrdersTotal(); t++)
     {

      if(OrderSelect(t, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() != Symbol())
            continue;
         if(OrderMagicNumber() != Magic)
            continue;
         if(OrderCloseTime() != 0)
            continue;

         TotalTrades = (TotalTrades + 1);
        }
     }

   return TotalTrades;

  }



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAllTrades()
  {

   int CloseResult = 0;

   for(int t = 0; t < OrdersTotal(); t++)
     {

      if(OrderSelect(t, SELECT_BY_POS, MODE_TRADES))
        {

         if(OrderMagicNumber() != Magic)
            continue;
         if(OrderSymbol() != Symbol())
            continue;
         if(OrderType() == OP_BUY)
            CloseResult = OrderClose(OrderTicket(), OrderLots(), Bid, MaxCloseSpreadPips, clrAliceBlue);
         if(OrderType() == OP_SELL)
            CloseResult = OrderClose(OrderTicket(), OrderLots(), Ask, MaxCloseSpreadPips, clrCrimson);

         t--;
        }

     }
   return;
  }
//Check total profit for all trades combined
double GetTotalProfits()
  {

   double TotalProfits = 0.0;
   for(int t = 0; t < OrdersTotal(); t++)
     {

      if(OrderSelect(t, SELECT_BY_POS, MODE_TRADES))
        {

         if(OrderMagicNumber() != Magic)
            continue;
         if(OrderSymbol() != Symbol())
            continue;
         if(OrderCloseTime() != 0)
            continue;
         TotalProfits = (TotalProfits + OrderProfit());
        }
     }
   return TotalProfits;

  }



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double getHighestValue()
  {
   double hi = -999999;
   for(int i = 1 ; i < Number_Of_Lookback_Candles ; i++)
     {
      if(High[i] > hi)
        {
         hi = High[i];
        }
     }
   return hi;
  }


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double getLowestValue()
  {
   double lo = 999999;
   for(int i = 1 ; i < Number_Of_Lookback_Candles ; i++)
     {
      if(Low[i] < lo)
        {
         lo = Low[i];
        }
     }
   return lo;
  }
//+------------------------------------------------------------------+
 
Mehmet Bastem:

So the only modification I needed was the sendNotification. Thank you

Reason: