probem with alert in my indicator mql4

 

hello, i need help with my program indicator on Metaeditor about alert, i have some error with alert mode 

someone can help me 

thanks 

Files:
ema.mq4  11 kb
 
Laurent63:

hello, i need help with my program indicator on Metaeditor about alert, i have some error with alert mode 

someone can help me 

thanks 

Maybe you can help others to help you by actually giving some details.

Do you go to the doctor and just say "I'm ill, please cure me"? No, you tell the doctor your symptoms so that he knows where to start diagnosis.

 
Laurent63: i have some error
  1. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
  2. Your problem is your code doesn't even compile.
          slowerMAafter=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i-1);
           int whichCross = iMA-1;
           if (iMA[whichCross][=High] >=alertsLevel) || iMA[whichCross][=Low] >= alertsLevel)
    
    You have code that correctly calls the iMA function. Then you use it as a variable (wrong) and then you use it as an array (wrong).
 
Keith Watford:

Maybe you can help others to help you by actually giving some details.

Do you go to the doctor and just say "I'm ill, please cure me"? No, you tell the doctor your symptoms so that he knows where to start diagnosis.



yes its right but i write already some problem with alert mode, i don't arrive to program my alert program


 
William Roeder:
  1. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
  2. Your problem is your code doesn't even compile. You have code that correctly calls the iMA function. Then you use it as a variable (wrong) and then you use it as an array (wrong).
without alert my indicator work good for me but i don't arrive tu put alert program inside 
 
Laurent63:

hello, i need help with my program indicator on Metaeditor about alert, i have some error with alert mode 

someone can help me 

thanks 

//+------------------------------------------------------------------+
//|                                                       SANTAN.mq4 |
//|                                           Based on EMA_CROSS.mq4 |
//|                      Copyright © 2019, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2019, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2

enum am
{
  a, // Long & Short
  b, // Long
  c  // Short
};  

extern bool   alertsOn              = false;
extern am     alertsMode            = a;
extern int    alertsLevel           = 3;
extern bool   alertsMessage         = true;
extern bool   alertsSound           = false;
extern bool   alertsMobile          = false;
extern bool   alertsEmail           = false;
//----
double CrossUp[];
double CrossDown[];
extern int FasterMode=3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA=  3;
extern int SlowerMode=3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA=  3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
datetime prevtime;
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
  //+------------------------------------------------------------------+
bool NewBar()
  {
   static datetime lastbar;
   datetime curbar=Time[0];
   if(lastbar!=curbar)
     {
      lastbar=curbar;
      return (true);
     }
   else
     {
      return(false);
     }
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
  int start() 
   {
   int limit, i, counter;
   double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
   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;
      fasterMAnow=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
      fasterMAprevious=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);
      fasterMAafter=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);
//----
      slowerMAnow=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i);
      slowerMAprevious=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i+1);
      slowerMAafter=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i-1);
        if ((fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter)) 
        {
         CrossUp[i]=Low[i] - Range*0.5;
        }
        else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter)) 
        {
            CrossDown[i]=High[i] + Range*0.5;
        }
      }
      if(iTime(Symbol(),0,0) == prevtime)  return(0);
        prevtime = iTime(Symbol(),0,0);
    
  if( CrossUp[0]>0 && (alertsMode==a || alertsMode==b) && NewBar()) 
                   {
                   if(alertsMessage)       Alert(Symbol()+" TF:"+string(Period())+" EMA Cross BUY ");
                   if (alertsMobile)       SendNotification("Haskayafx "+Symbol()+" TF:"+IntegerToString(Period())+" EMA Cross BUY" ) ;
                   if(alertsEmail)         SendMail("Haskayafx:",Symbol()+" TF:"+IntegerToString(Period())+ " EMA Cross BUY");
                   }   
   if( CrossDown[0]>0 && (alertsMode==a || alertsMode==c) && NewBar()) 
                   {
                   if(alertsMessage)       Alert(Symbol()+" TF:"+string(Period())+" EMA Cross SELL ");
                   if (alertsMobile)       SendNotification("Haskaya  "+Symbol()+" TF:"+IntegerToString(Period())+" EMA Cross SELL" ) ;
                   if(alertsEmail)         SendMail("Haskayafx:",Symbol()+" TF:"+IntegerToString(Period())+ " EMA Cross SELL");
                   }                       
                   
                   
   return(0);
  }
 
//+-------------------------------------------------------------------+
//| Custom indicator alert fonction                                   |
//+-------------------------------------------------------------------+
//
//
//
//
//


//
//
//
//
//

//+------------------------------------------------------------------+
 
Mehmet Bastem:

sory for my late reply but doesn't work

thanks for your help

Reason: