Notification by script Alert EMA Cross

 

Dear together,

I have a Problem to get my script alert on my mobile by SendNotification.

The Indicator works well with an Arrow and an sound, but not wirth notification. 

Test Notification works all well.

If I try to modify the script allert, the Indicator doesn't work annymore.

Thanks to all!!!

Olli 

PS: Here is the Script for the Indicator alert: 

 

double CrossUp[];

double CrossDown[];

extern int FasterEMA = 5;

extern int SlowerEMA = 13;

extern bool SoundON=true;

double alertTag;

 double control=2147483647;

 

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int init()

  {

//---- indicators

   SetIndexStyle(0, DRAW_ARROW, EMPTY,1);

   SetIndexArrow(0, 233);

   SetIndexBuffer(0, CrossUp);

   SetIndexStyle(1, DRAW_ARROW, EMPTY,1);

   SetIndexArrow(1, 234);

   SetIndexBuffer(1, CrossDown);

//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function                       |

//+------------------------------------------------------------------+

int deinit()

  {

//---- 



//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int start() {

   int limit, i, counter;

   double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;

   double Range, AvgRange;

   int counted_bars=IndicatorCounted();

//---- check for possible errors

   if(counted_bars<0) return(-1);

//---- last counted bar will be recounted

   if(counted_bars>0) counted_bars--;



   limit=Bars-counted_bars;

   

   for(i = 0; i <= limit; i++) {

   

      counter=i;

      Range=0;

      AvgRange=0;

      for (counter=i ;counter<=i+9;counter++)

      {

         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);

      }

      Range=AvgRange/10;

       

      fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i);

      fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);

      fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);



      slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i);

      slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);

      slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

      

      if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) {

         CrossUp[i] = Low[i] - Range*0.5;

      }

      else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) {

          CrossDown[i] = High[i] + Range*0.5;

      }

        if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){

         Alert("EMA Cross Trend going Down on ",Symbol()," ",Period());

        alertTag = Time[0];

      }

        if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){

       Alert("EMA Cross Trend going Up on ",Symbol()," ",Period());

        alertTag = Time[0];

        } 

  }

   return(0);

}

 
 

Alert()  can take multiple parameters . . .   check the Dcoumentation

 

SendNotification() can only take one . . .   check the Documentation

 

Use StringConcatenate()  to combine your parameters into one string . . . 

 
RaptorUK:

Alert()  can take multiple parameters . . .   check the Dcoumentation

 

SendNotification() can only take one . . .   check the Documentation

 

Use StringConcatenate()  to combine your parameters into one string . . . 


Don't know how i can use this information?

 
olli:

If I try to modify the script allert, the Indicator doesn't work annymore. 

Show your modification please.
 
RaptorUK:
Show your modification please.

I replaced "Alert" with "SendNotification"

 

 if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) {

         CrossUp[i] = Low[i] - Range*0.5;

      }

      else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) {

          CrossDown[i] = High[i] + Range*0.5;

      }

        if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){

         SendNotification("EMA Cross Trend going Down on ",Symbol()," ",Period());

        alertTag = Time[0];

      }

        if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){

       SendNotification("EMA Cross Trend going Up on ",Symbol()," ",Period());

        alertTag = Time[0];

        } 
 
olli:

I replaced "Alert" with "SendNotification"


RaptorUK:

Alert()  can take multiple parameters . . .   check the Dcoumentation

 

SendNotification() can only take one . . .   check the Documentation

 

Use StringConcatenate()  to combine your parameters into one string . . . 

Read the documentation I gave links too,  look at the examples in the documentation.
 
RaptorUK:


Read the documentation I gave links too,  look at the examples in the documentation.

 


O.K. I read. But where do i integrate this? I have no object!

 

double lastclose=Close[0];
  if(lastclose>my_signal)
    SendNotification("Price changed "+DoubleToStr(lastclose,Digits));
 
olli:


O.K. I read. But where do i integrate this? I have no object!

 

You have this:

SendNotification(  "EMA Cross Trend going Down on ",    Symbol(),    " ",    Period()    );

// and this

SendNotification(  "EMA Cross Trend going Up on ",      Symbol(),     " ",    Period()   );

 the comma  ,  separates the parameters you are passing to the function,  Alert() can take several parameters,  so your code works with Alert() . . . .  SendNotification() can only take one parameter so you have to combine the parameters in the brackets  ( )   the examples in the documentation show you how to do this . . .    you can use  +    or StringConcatenate()

 
RaptorUK:

You have this:

 the comma  ,  separates the parameters you are passing to the function,  Alert() can take several parameters,  so your code works with Alert() . . . .  SendNotification() can only take one parameter so you have to combine the parameters in the brackets  ( )   the examples in the documentation show you how to do this . . .    you can use  +    or StringConcatenate()

 

Have to much work to check out this now.

Reason: