ADX crossing indicator w/ Alerts - Alerts Repeat Continuously

 

Can anyone help me with the below indicator. The alert repeats Continuously. I would just like it to alert me once. Any help would be appreciated.

 
cpickens:

Can anyone help me with the below indicator. The alert repeats Continuously. I would just like it to alert me once. Any help would be appreciated.

 

<CODE DELETED>

Please read some other posts before posting . . .

Please edit your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 

 
Can someone please help me so the alert only happens once. Thanks
//+------------------------------------------------------------------+
//|                                                   ADXcrosses.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int ADXcrossesPeriod = 14;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//----
double b4plusdi, b4minusdi, nowplusdi, nowminusdi;
int    nShift;   
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
    SetIndexStyle(0, DRAW_ARROW, 0, 1);
    SetIndexArrow(0, 233);
    SetIndexBuffer(0, ExtMapBuffer1);
//----
    SetIndexStyle(1, DRAW_ARROW, 0, 1);
    SetIndexArrow(1, 234);
    SetIndexBuffer(1, ExtMapBuffer2);
//---- name for DataWindow and indicator subwindow label
    IndicatorShortName("ADXcrosses(" + ADXcrossesPeriod + ")");
    SetIndexLabel(0, "ADXcrUp");
    SetIndexLabel(1, "ADXcrDn"); 
//----
    switch(Period())
      {
        case     1: nShift = 1;   break;    
        case     5: nShift = 3;   break; 
        case    15: nShift = 5;   break; 
        case    30: nShift = 10;  break; 
        case    60: nShift = 15;  break; 
        case   240: nShift = 20;  break; 
        case  1440: nShift = 80;  break; 
        case 10080: nShift = 100; break; 
        case 43200: nShift = 200; break;               
      }
//----
    return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
    return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int limit;
    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(int i = 0; i < limit; i++)
      {
        b4plusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_PLUSDI, i - 1);
        nowplusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_PLUSDI, i);
        b4minusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_MINUSDI, i - 1);
        nowminusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_MINUSDI, i);  
        //----
        if(b4plusdi > b4minusdi && nowplusdi < nowminusdi)
            ExtMapBuffer1[i] = Low[i] - nShift*Point;
        //----
        if(b4plusdi < b4minusdi && nowplusdi > nowminusdi)
            ExtMapBuffer2[i] = High[i] + nShift*Point;
      }
//----
    return(0);
  }
//+------------------------------------------------------------------+
 
cpickens: Can someone please help me so the alert only happens once. Thanks
  1. There is NO alert call in your posted code.
  2. b4plusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_PLUSDI, i - 1);
    You want to look at the previous bar (i + 1) not a future one.
 
WHRoeder:
  1. There is NO alert call in your posted code.
  2. You want to look at the previous bar (i + 1) not a future one.


Below is the correct code with the Alert. I just want to hear it once. Thanks

//+------------------------------------------------------------------+
//| ADX Crossing.mq4 
//| Amir
//+------------------------------------------------------------------+
#property  copyright "Author - Amir"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

//---- input parameters
extern int ADXbars=14;
extern int CountBars=350;


//---- buffers
double val1[];
double val2[];

double b4plusdi,nowplusdi,b4minusdi,nowminusdi;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,108);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,108);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2                                            |
//+------------------------------------------------------------------+
int start()
  {   
   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars);
   SetIndexDrawBegin(1,Bars-CountBars);
   int i,shift,counted_bars=IndicatorCounted();


   //---- check for possible errors
   if(counted_bars<0) return(-1);

   //---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=CountBars;i++) val1[CountBars-i]=0.0;
      for(i=1;i<=CountBars;i++) val2[CountBars-i]=0.0;
            
     } 
     
for (shift = CountBars; shift>=0; shift--)

{ 

        b4plusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift-1);
        nowplusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift);
        b4minusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift-1);
        nowminusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift); 
if (b4plusdi>b4minusdi && nowplusdi<nowminusdi && i!=1)
{
   val1[shift]=Low[shift]-5*Point;
   Alert("Buy Arrow","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());
   i++;
}
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi && i!=1)
{
   val2[shift]=High[shift]+5*Point;
   Alert("Sell Arrow","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());
   i++;
}
 
      
}

   return(0);
  }
//+------------------------------------------------------------------+

 
Send Alert when shift==1
 
WHRoeder:
Send Alert when shift==1

I don't know much about coding. Where do I put this in the code. Thanks
 
Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.