Wick Reject MA Indicator... Code issues need expert advice.....

 

  I tried to code on my own.. but looks like something wrong somewhere as the indicator came out at the wrong place...  

What i'm trying to code here is,
*If a candle High price is above MA, the candle Open, Close and Low price is below MA, it will show a Down arrow.
*If a candle Low price is below MA, the candle Open, Close and High price is above MA, it will show a Up arrow.

 

//+------------------------------------------------------------------+
//|                                            Wick Rejection v2.mq4 |
//|        Copyright 2015, MetaQuotes Rizal Ijal Izan Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Rizal Ijal Izan MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "2.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot MA_Low
#property indicator_label1  "MA_Low"
//--- Arrow
#property indicator_label2  "ArrUp"
#property indicator_label3  "ArrDn"
//--- input parameters
enum eprice
  {
   s0 = 0,//LOW/HIGH
   s1 = 1 //CLOSE/CLOSE
  };
//---
input string str1="============MOVING AVERAGE LOW============";//======================
input int mal_period= 20;//PERIOD
input int mal_shift = 0;//SHIFT
input ENUM_MA_METHOD mal_method=MODE_SMA;//METHOD
input ENUM_APPLIED_PRICE mal_price=PRICE_CLOSE;//PRICE
input color mal_col=clrWhite;//LINE COLOR
input int mal_width=2;//LINE THICKNESS

input string str2="============ARROW============";//======================
input int arrup_W=2;//Arrow Up Width
input color arrup_C=clrLime;//Arrow Up Color
int arrup_code=115;//Arrow Up Code
input int arrdn_W=2;//Arrow Dn Width
input color arrdn_C=clrOrangeRed;//Arrow Dn Color
int arrdn_code=115;//Arrow Dn Code

//--- indicator buffers
double         MA_LowBuffer[];
double         ArrUpBuffer[];
double         ArrDnBuffer[];
//---
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(3);
   SetIndexBuffer(0,MA_LowBuffer);SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,mal_width,mal_col);
   SetIndexBuffer(1,ArrUpBuffer);SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,arrup_W,arrup_C);SetIndexArrow(6,arrup_code);
   SetIndexBuffer(2,ArrDnBuffer);SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,arrdn_W,arrdn_C);SetIndexArrow(5,arrdn_code);

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
   for(int i=ObjectsTotal(); i>=0; i--)
     {
      if(StringSubstr(ObjectName(i),0,5)=="Comb_")
        {
         ObjectDelete(ObjectName(i));
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i,limit;
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)limit=limit+2;
   for(i=limit-2;i>=0;i--)
     { 
      MA_LowBuffer[i]=iMA(_Symbol,_Period,mal_period,mal_shift,mal_method,mal_price,i);
      if(iHigh(NULL,PERIOD_CURRENT,1)>MA_LowBuffer[i] && iOpen(NULL,PERIOD_CURRENT,1)>MA_LowBuffer[i] && iClose(NULL,PERIOD_CURRENT,1)>MA_LowBuffer[i]&& iLow(NULL,PERIOD_CURRENT,1)<MA_LowBuffer[i])
        {ArrUpBuffer[i]=Low[i]-15*pix_y();} 
      if(iHigh(NULL,PERIOD_CURRENT,1)>MA_LowBuffer[i] && iOpen(NULL,PERIOD_CURRENT,1)<MA_LowBuffer[i] && iClose(NULL,PERIOD_CURRENT,1)<MA_LowBuffer[i]&& iLow(NULL,PERIOD_CURRENT,1)<MA_LowBuffer[i])
        {ArrDnBuffer[i]=High[i]+15*pix_y();}     
     }
//---------------
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double pix_y()
  {
   return((ChartGetDouble(0,CHART_PRICE_MAX,0)-ChartGetDouble(0,CHART_PRICE_MIN,0))/ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0));
  }

   This the result that i get on my chart

 

  It doesn't show at the right candle... any expert advice to point out or show the code error i did?

 

Much appreciate your kind help...

Moderator may delete if found this thread not suitable...

Regards 

 
if(iHigh(NULL,PERIOD_CURRENT,i+1)>MA_LowBuffer[i] && iOpen(NULL,PERIOD_CURRENT,i+1)>MA_LowBuffer[i] && iClose(NULL,PERIOD_CURRENT,i+1)>MA_LowBuffer[i]&& iLow(NULL,PERIOD_CURRENT,i+1)<MA_LowBuffer[i])
        {ArrUpBuffer[i]=Low[i]-15*pix_y();} 

or

if(high[i+1]>MA_LowBuffer[i] && open[i+1]>MA_LowBuffer[i] && close[i+1])>MA_LowBuffer[i]&& low[i+1]<MA_LowBuffer[i])
        {ArrUpBuffer[i]=low[i]-15*pix_y();} 
 
Ernst Van Der Merwe:

or

SOLVE!!!!!

Thank you so much.. i+1 made so much diff.. been trying to solve it since 24hrs ago....

 
Mohammad Rizal Bin Rahmat:

SOLVE!!!!!

Thank you so much.. i+1 made so much diff.. been trying to solve it since 24hrs ago....

now i'm putting an alert, will this be correct?
 if(use_alert)
 {  
 if(ArrUpBuffer[1]!=1) Alert(_Symbol," ",_Period," ",up_alert);
 if(ArrDnBuffer[1]!=1) Alert(_Symbol," ",_Period," ",down_alert);
 
if(high[i+1]>MA_LowBuffer[i] && open[i+1]>MA_LowBuffer[i] && close[i+1])>MA_LowBuffer[i]&& low[i+1]<MA_LowBuffer[i])
  {
   ArrUpBuffer[i]=low[i]-15*pix_y();
   if(prev_calculated>0 && use_alert)
      Alert(_Symbol," ",_Period," ",up_alert);
  } 
 
Ernst Van Der Merwe:
Hi Sir, i adjusted the alert due to the value needed to activated the alert, but i'm having issue is that the alert keep on popping... how can i make it to just give the alert once for each triggered?

  {
   int i=0,j=0;
   ArrayResize(mess_data,NumPair+1,20);
   ArrayResize(mess_color,NumPair+1,20);
//---
   for(int k=0;k<NumPair;k++)
     {
      for(j=0;j<tf_desk;j++)
        {
         double MAL=iMA(pair[k],Trend_Timeframe[j],mal_period,mal_shift,mal_method,mal_price,0);
         if(iHigh(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iOpen(pair[k],Trend_Timeframe[j],0)<=MAL &&
         iClose(pair[k],Trend_Timeframe[j],0)<=MAL &&
         iLow(pair[k],Trend_Timeframe[j],0)<=MAL)
        {mess_data[k][j]="D";mess_color[k][j]=clrRed;
         if(k>0 && use_alert)
         Alert(pair[k]," ",Trend_Timeframe[j]," ",down_alert);}
         if(iHigh(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iOpen(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iClose(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iLow(pair[k],Trend_Timeframe[j],0)<=MAL)
        {mess_data[k][j]="U";mess_color[k][j]=clrLime;
         if(k>0 && use_alert)
         Alert(pair[k]," ",Trend_Timeframe[j]," ",up_alert);}
         else {mess_data[k][j]="X";mess_color[k][j]=clrGray;}
        }
     }
  }
 
   static bool alert=false;
//---
//---
   if(k>0 && use_alert && !alert)
     {
      Alert(pair[k]," ",Trend_Timeframe[j]," ",down_alert);
      alert=true;
     }
   //---
   else if(k>0 && use_alert && !alert)
     {
      Alert(pair[k]," ",Trend_Timeframe[j]," ",up_alert);
      alert=true;
     }
   //---
   else 
     {
      mess_data[k][j]="X";mess_color[k][j]=clrGray;
      alert=false;
     }
 
Ernst Van Der Merwe:

It still doesn't works.... If the result is positive, the alert keep on popping up till the next candle or till there isn't any sign. if there is sign, it will keep on giving alert non stop.

Here's the whole code.. so basically i put the alert same as the dashboard... cause i want to monitor multiply pairs and TF. so if the dash board shows a U or D at a pair and TF, it will shows the alert but it keep on beeping and poppinp up non stop till there isn't the D or U shown. but i still need the U or D to be shown. just need the alert to popup just once each time.

Thank you sir 

 

//+------------------------------------------------------------------+
//|                                                      EXTREME.mq4 |
//|        Copyright 2015, MetaQuotes Rizal Ijal Izan Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Rizal Ijal Izan MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot MA_Low
#property indicator_label1  "MA_Low"
//--- Arrow1
#property indicator_label2  "ArrUp"
#property indicator_label3  "ArrDn"
//--- input parameters
enum eprice
  {
   s0 = 0,//LOW/HIGH
   s1 = 1 //CLOSE/CLOSE
  };
//---
input string str1="============MOVING AVERAGE LOW============";//======================
input int mal_period= 5;//PERIOD
input int mal_shift = 0;//SHIFT
input ENUM_MA_METHOD mal_method=MODE_LWMA;//METHOD
input ENUM_APPLIED_PRICE mal_price=PRICE_LOW;//PRICE
input color mal_col=clrMagenta;//LINE COLOR
input int mal_width=0;//LINE THICKNESS

input string str2="============ALERTS============";//======================
input bool a_m1 = false;//ALERT M1
input bool a_m5 = true;//ALERT M5
input bool a_m15= true;//ALERT M15
input bool a_m30= true;//ALERT M30
input bool a_h1 = true;//ALERT H1
input bool a_h4 = false;//ALERT H4
input bool a_d1 = false;//ALERT D1
input bool a_w1 = false;//ALERT W1
input bool a_mn = false;//ALERT MN

input string str3="============ARROW============";//======================
input int arrup_W=2;//Arrow Up Width
input color arrup_C=clrLime;//Arrow Up Color
int arrup_code=115;//Arrow Up Code
input int arrdn_W=2;//Arrow Dn Width
input color arrdn_C=clrOrangeRed;//Arrow Dn Color
int arrdn_code=115;//Arrow Dn Code

input string str4="============PAIRS============";//*ENTRY OF THE PAIRS TO BE SHOWN, 
extern string pairs="EURUSD,GBPUSD,NZDUSD,EURJPY";//EX. EURUSD,GBPUSD,NZDUSD,EURJPY* 
input bool show_db=true;//Show Dashboard
input ENUM_BASE_CORNER p_loc=CORNER_RIGHT_LOWER;//PANEL LOCATION
color Background_Color=C'40,40,40';
input color Text_Color=clrWhite;
input color Text_Label_Color=clrYellow;
extern int Offset_X = 10;
extern int Offset_Y = 10;

input string str5="============ALERT============";//======================
extern string al_set = "Alerts settings";
extern bool use_alert = true;
extern string down_alert = "WICK REJECTION FOR SELL";
extern string up_alert = "WICK REJECTION FOR BUY";

//--- indicator buffers
double         MA_LowBuffer[];
double         ArrUpBuffer[];
double         ArrDnBuffer[];

//---
string pair[];
int x,y,NumPair,ofs_sema=20;
string tf_label[];//={"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int tf_desk = 0;
int tf_lab_ofset[]={4,4,2,2,4,4,4,4,2};
//int Trend_Timeframe[9]={1,5,15,30,60,240,1440,10080,43200};
int Trend_Timeframe[];
int y1,yo[3],lo,xp1[2];
string mess_data[][9];
color mess_color[][9];

static bool alert=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(3);
   SetIndexBuffer(0,MA_LowBuffer);SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,mal_width,mal_col);
   SetIndexBuffer(1,ArrUpBuffer);SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,arrup_W,arrup_C);SetIndexArrow(1,arrup_code);
   SetIndexBuffer(2,ArrDnBuffer);SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,arrdn_W,arrdn_C);SetIndexArrow(2,arrdn_code);
//---
   Background_Color=(color)ChartGetInteger(0,CHART_COLOR_BACKGROUND);
   pairs = StringTrimLeft(pairs);
   pairs = StringTrimRight(pairs);
   while(true && !IsStopped())
     {
      if(StringSubstr(pairs,StringLen(pairs)-1)==",")
         pairs=StringSubstr(pairs,0,StringLen(pairs)-1);
      else break;
     }
   int pos=0,p=1;
   while(true && !IsStopped())
     {
      pos=StringFind(pairs,",",0);
      ArrayResize(pair,p,100);
      pair[p-1]=StringTrimLeft(StringTrimRight(StringSubstr(pairs,0,pos)));
      pairs=StringSubstr(pairs,pos+1);
      if(pos<1)break;
      p++;
     }
//---
   NumPair=ArraySize(pair);
   int extend_board=0;
   double symlen=0;
   for(int j=0;j<ArraySize(pair);j++)
      symlen=MathMax(symlen,StringLen(pair[j]));
//---
if(a_m1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=1;}
if(a_m5){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M5";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=5;}
if(a_m15){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M15";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=15;}
if(a_m30){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M30";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=30;}
if(a_h1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="H1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=60;}
if(a_h4){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="H4";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=240;}
if(a_d1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="D1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=1440;}
if(a_w1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="W1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=10080;}
if(a_mn){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="MN";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=43200;}
//--- 
   int ylen=4*NumPair;
   if(NumPair==1)ylen++;
//---
   switch(p_loc)
     {
      case 0:
         x = Offset_X+10;
         y = Offset_Y+20;
         //---
         yo[0]=y;
         yo[1]=-20;
         yo[2]=1;
         y1=5;
         xp1[0]=35;
         xp1[1]=70;
         //---
         break;
      case 1:
         x = Offset_X+10;
         y = Offset_Y+10;
         //---
         yo[0]=y;
         yo[1]=-25;
         yo[2]=1;
         y1=10;
         xp1[0]=100+20*(tf_desk-1);
         xp1[1]=0;
         //---
         ArraySetAsSeries(tf_label,true);
         ArraySetAsSeries(tf_lab_ofset,true);
         ArraySetAsSeries(Trend_Timeframe,true);
         //---
         break;
      case 2:
         x = Offset_X+10;
         y = Offset_Y+10;
         //---
         yo[0]=y+15*(NumPair);
         yo[1]=10;
         yo[2]=-1;
         y1=5;
         xp1[0]=35;
         xp1[1]=70;
         //---
         break;
      case 3:
         x = Offset_X+10;
         y = Offset_Y+10;
         //---
         yo[0]=y+15*(NumPair);
         yo[1]=10;
         y1=5;
         yo[2]=-1;
         xp1[0]=100+20*(tf_desk-1);
         xp1[1]=0;
         //---
         ArraySetAsSeries(tf_label,true);
         ArraySetAsSeries(tf_lab_ofset,true);
         ArraySetAsSeries(Trend_Timeframe,true);
         //---
         break;
     }

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
   for(int i=ObjectsTotal(); i>=0; i--)
     {
      if(StringSubstr(ObjectName(i),0,5)=="Comb_")
        {
         ObjectDelete(ObjectName(i));
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CreateText(string label,int posx,int posy,string text,int fontsize,string font,color fontcolor,ENUM_ANCHOR_POINT anchor,ENUM_BASE_CORNER corner)
  {
   ObjectDelete(label);
   ObjectCreate(label,OBJ_LABEL,0,0,0);
   ObjectSet(label,OBJPROP_CORNER,corner);
   ObjectSet(label,OBJPROP_ANCHOR,anchor);
   ObjectSet(label,OBJPROP_XDISTANCE,posx);
   ObjectSet(label,OBJPROP_YDISTANCE,posy);
   ObjectSet(label,OBJPROP_BACK,false);
   ObjectSetText(label,text,fontsize,font,fontcolor);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i,limit;
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)limit=limit+2;
   for(i=limit-2;i>=0;i--)
     {
      MA_LowBuffer[i]=iMA(_Symbol,_Period,mal_period,mal_shift,mal_method,mal_price,i);
       if(iHigh(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] && 
         iOpen(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i] &&
         iClose(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i] &&
         iLow(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i])
        {ArrDnBuffer[i]=High[i]+50*pix_y();}
       if(iHigh(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] && 
         iOpen(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] &&
         iClose(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] &&
         iLow(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i])
        {ArrUpBuffer[i]=Low[i]-50*pix_y();}
     }
//---------------
   int total=NumPair;
//---
   y=yo[0];
//---
   if(show_db)
     {
      load_data();
      for(i=0; i<tf_desk; i++)
        {
         CreateText("Comb_Segment_Label_"+(string)i,xp1[1]+x+tf_lab_ofset[i]+ofs_sema*i,y+y1,(string)tf_label[i],6,"Verdana",Text_Label_Color,ANCHOR_CENTER,p_loc);
        }
      //---
      for(int k=0; k<NumPair; k++)
        {
         CreateText("Comb_Symbol_"+(string)k,xp1[0]-10,y-yo[1],pair[k],10,"Arial Black",Text_Color,ANCHOR_LEFT,p_loc);
         for(i=0; i<tf_desk; i++)
           {
            CreateText("Comb_Segment_"+(string)i+"_"+(string)k,xp1[1]+3+x+ofs_sema*i,y-yo[1],mess_data[k][i],10,"Verdana",Gray,ANCHOR_CENTER,p_loc);
            ObjectSet("Comb_Segment_"+(string)i+"_"+(string)k,OBJPROP_COLOR,mess_color[k][i]);
           }
         y+=15*yo[2];
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double pix_y()
  {
   return((ChartGetDouble(0,CHART_PRICE_MAX,0)-ChartGetDouble(0,CHART_PRICE_MIN,0))/ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void load_data()
  {
   int i=0,j=0;
   ArrayResize(mess_data,NumPair+1,20);
   ArrayResize(mess_color,NumPair+1,20);
//---
   for(int k=0;k<NumPair;k++)
     {
      for(j=0;j<tf_desk;j++)
        {
         double MAL=iMA(pair[k],Trend_Timeframe[j],mal_period,mal_shift,mal_method,mal_price,0);
         if(iHigh(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iOpen(pair[k],Trend_Timeframe[j],0)<=MAL &&
         iClose(pair[k],Trend_Timeframe[j],0)<=MAL &&
         iLow(pair[k],Trend_Timeframe[j],0)<=MAL) 
         {mess_data[k][j]="D";mess_color[k][j]=clrRed;
         if(k>0 && use_alert)
         Alert(pair[k]," ",Trend_Timeframe[j]," ",down_alert);}
         
         if(iHigh(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iOpen(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iClose(pair[k],Trend_Timeframe[j],0)>=MAL &&
         iLow(pair[k],Trend_Timeframe[j],0)<=MAL)
         {mess_data[k][j]="U";mess_color[k][j]=clrLime;
         if(k>0 && use_alert)
         Alert(pair[k]," ",Trend_Timeframe[j]," ",up_alert);} 
         
         else {mess_data[k][j]="X";mess_color[k][j]=clrGray;}         
        }
     }
  }
//+------------------------------------------------------------------+
 
#property copyright "Copyright 2015, Rizal Ijal Izan MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot MA_Low
#property indicator_label1  "MA_Low"
//--- Arrow1
#property indicator_label2  "ArrUp"
#property indicator_label3  "ArrDn"
//--- input parameters
enum eprice
  {
   s0 = 0,//LOW/HIGH
   s1 = 1 //CLOSE/CLOSE
  };
//---
input string str1="============MOVING AVERAGE LOW============";//======================
input int mal_period= 5;//PERIOD
input int mal_shift = 0;//SHIFT
input ENUM_MA_METHOD mal_method=MODE_LWMA;//METHOD
input ENUM_APPLIED_PRICE mal_price=PRICE_LOW;//PRICE
input color mal_col=clrMagenta;//LINE COLOR
input int mal_width=0;//LINE THICKNESS

input string str2="============ALERTS============";//======================
input bool a_m1= false;//ALERT M1
input bool a_m5 = true;//ALERT M5
input bool a_m15= true;//ALERT M15
input bool a_m30= true;//ALERT M30
input bool a_h1 = true;//ALERT H1
input bool a_h4 = false;//ALERT H4
input bool a_d1 = false;//ALERT D1
input bool a_w1 = false;//ALERT W1
input bool a_mn = false;//ALERT MN

input string str3="============ARROW============";//======================
input int arrup_W=2;//Arrow Up Width
input color arrup_C=clrLime;//Arrow Up Color
int arrup_code=115;//Arrow Up Code
input int arrdn_W=2;//Arrow Dn Width
input color arrdn_C=clrOrangeRed;//Arrow Dn Color
int arrdn_code=115;//Arrow Dn Code

input string str4="============PAIRS============";//*ENTRY OF THE PAIRS TO BE SHOWN, 
extern string pairs="EURUSD,GBPUSD,NZDUSD,EURJPY";//EX. EURUSD,GBPUSD,NZDUSD,EURJPY* 
input bool show_db=true;//Show Dashboard
input ENUM_BASE_CORNER p_loc=CORNER_RIGHT_LOWER;//PANEL LOCATION
color Background_Color=C'40,40,40';
input color Text_Color=clrWhite;
input color Text_Label_Color=clrYellow;
extern int Offset_X = 10;
extern int Offset_Y = 10;

input string str5="============ALERT============";//======================
extern string al_set="Alerts settings";
extern bool use_alert=true;
extern string down_alert="WICK REJECTION FOR SELL";
extern string up_alert="WICK REJECTION FOR BUY";

//--- indicator buffers
double         MA_LowBuffer[];
double         ArrUpBuffer[];
double         ArrDnBuffer[];

//---
string pair[];
int x,y,NumPair,ofs_sema=20;
string tf_label[];//={"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int tf_desk=0;
int tf_lab_ofset[]={4,4,2,2,4,4,4,4,2};
//int Trend_Timeframe[9]={1,5,15,30,60,240,1440,10080,43200};
int Trend_Timeframe[];
int y1,yo[3],lo,xp1[2];
string mess_data[][9];
color mess_color[][9];

static bool alert=false;

int alert_flag;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(3);
   SetIndexBuffer(0,MA_LowBuffer);SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,mal_width,mal_col);
   SetIndexBuffer(1,ArrUpBuffer);SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,arrup_W,arrup_C);SetIndexArrow(1,arrup_code);
   SetIndexBuffer(2,ArrDnBuffer);SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,arrdn_W,arrdn_C);SetIndexArrow(2,arrdn_code);
//---
   Background_Color=(color)ChartGetInteger(0,CHART_COLOR_BACKGROUND);
   pairs = StringTrimLeft(pairs);
   pairs = StringTrimRight(pairs);
   while(true && !IsStopped())
     {
      if(StringSubstr(pairs,StringLen(pairs)-1)==",")
         pairs=StringSubstr(pairs,0,StringLen(pairs)-1);
      else break;
     }
   int pos=0,p=1;
   while(true && !IsStopped())
     {
      pos=StringFind(pairs,",",0);
      ArrayResize(pair,p,100);
      pair[p-1]=StringTrimLeft(StringTrimRight(StringSubstr(pairs,0,pos)));
      pairs=StringSubstr(pairs,pos+1);
      if(pos<1)break;
      p++;
     }
//---
   NumPair=ArraySize(pair);
   int extend_board=0;
   double symlen=0;
   for(int j=0;j<ArraySize(pair);j++)
      symlen=MathMax(symlen,StringLen(pair[j]));
//---
   if(a_m1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=1;}
   if(a_m5){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M5";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=5;}
   if(a_m15){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M15";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=15;}
   if(a_m30){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="M30";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=30;}
   if(a_h1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="H1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=60;}
   if(a_h4){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="H4";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=240;}
   if(a_d1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="D1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=1440;}
   if(a_w1){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="W1";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=10080;}
   if(a_mn){tf_desk++;ArrayResize(tf_label,tf_desk,9);tf_label[tf_desk-1]="MN";ArrayResize(Trend_Timeframe,tf_desk,9);Trend_Timeframe[tf_desk-1]=43200;}
//--- 
   int ylen=4*NumPair;
   if(NumPair==1)ylen++;
//---
   switch(p_loc)
     {
      case 0:
         x = Offset_X+10;
         y = Offset_Y+20;
         //---
         yo[0]=y;
         yo[1]=-20;
         yo[2]=1;
         y1=5;
         xp1[0]=35;
         xp1[1]=70;
         //---
         break;
      case 1:
         x = Offset_X+10;
         y = Offset_Y+10;
         //---
         yo[0]=y;
         yo[1]=-25;
         yo[2]=1;
         y1=10;
         xp1[0]=100+20*(tf_desk-1);
         xp1[1]=0;
         //---
         ArraySetAsSeries(tf_label,true);
         ArraySetAsSeries(tf_lab_ofset,true);
         ArraySetAsSeries(Trend_Timeframe,true);
         //---
         break;
      case 2:
         x = Offset_X+10;
         y = Offset_Y+10;
         //---
         yo[0]=y+15*(NumPair);
         yo[1]=10;
         yo[2]=-1;
         y1=5;
         xp1[0]=35;
         xp1[1]=70;
         //---
         break;
      case 3:
         x = Offset_X+10;
         y = Offset_Y+10;
         //---
         yo[0]=y+15*(NumPair);
         yo[1]=10;
         y1=5;
         yo[2]=-1;
         xp1[0]=100+20*(tf_desk-1);
         xp1[1]=0;
         //---
         ArraySetAsSeries(tf_label,true);
         ArraySetAsSeries(tf_lab_ofset,true);
         ArraySetAsSeries(Trend_Timeframe,true);
         //---
         break;
     }

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
   for(int i=ObjectsTotal(); i>=0; i--)
     {
      if(StringSubstr(ObjectName(i),0,5)=="Comb_")
        {
         ObjectDelete(ObjectName(i));
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CreateText(string label,int posx,int posy,string text,int fontsize,string font,color fontcolor,ENUM_ANCHOR_POINT anchor,ENUM_BASE_CORNER corner)
  {
   ObjectDelete(label);
   ObjectCreate(label,OBJ_LABEL,0,0,0);
   ObjectSet(label,OBJPROP_CORNER,corner);
   ObjectSet(label,OBJPROP_ANCHOR,anchor);
   ObjectSet(label,OBJPROP_XDISTANCE,posx);
   ObjectSet(label,OBJPROP_YDISTANCE,posy);
   ObjectSet(label,OBJPROP_BACK,false);
   ObjectSetText(label,text,fontsize,font,fontcolor);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i,limit;
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)limit=limit+2;
   for(i=limit-2;i>=0;i--)
     {
      MA_LowBuffer[i]=iMA(_Symbol,_Period,mal_period,mal_shift,mal_method,mal_price,i);
      if(iHigh(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] && 
         iOpen(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i] && 
         iClose(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i] && 
         iLow(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i])
        {ArrDnBuffer[i]=High[i]+50*pix_y();}
      if(iHigh(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] && 
         iOpen(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] && 
         iClose(NULL,PERIOD_CURRENT,i+0)>=MA_LowBuffer[i] && 
         iLow(NULL,PERIOD_CURRENT,i+0)<=MA_LowBuffer[i])
        {ArrUpBuffer[i]=Low[i]-50*pix_y();}
     }
//---------------
   int total=NumPair;
//---
   y=yo[0];
//---
   if(show_db)
     {
      load_data();
      for(i=0; i<tf_desk; i++)
        {
         CreateText("Comb_Segment_Label_"+(string)i,xp1[1]+x+tf_lab_ofset[i]+ofs_sema*i,y+y1,(string)tf_label[i],6,"Verdana",Text_Label_Color,ANCHOR_CENTER,p_loc);
        }
      //---
      for(int k=0; k<NumPair; k++)
        {
         CreateText("Comb_Symbol_"+(string)k,xp1[0]-10,y-yo[1],pair[k],10,"Arial Black",Text_Color,ANCHOR_LEFT,p_loc);
         for(i=0; i<tf_desk; i++)
           {
            CreateText("Comb_Segment_"+(string)i+"_"+(string)k,xp1[1]+3+x+ofs_sema*i,y-yo[1],mess_data[k][i],10,"Verdana",Gray,ANCHOR_CENTER,p_loc);
            ObjectSet("Comb_Segment_"+(string)i+"_"+(string)k,OBJPROP_COLOR,mess_color[k][i]);
           }
         y+=15*yo[2];
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double pix_y()
  {
   return((ChartGetDouble(0,CHART_PRICE_MAX,0)-ChartGetDouble(0,CHART_PRICE_MIN,0))/ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void load_data()
  {
   int i=0,j=0;
   ArrayResize(mess_data,NumPair+1,20);
   ArrayResize(mess_color,NumPair+1,20);
//---
   for(int k=0;k<NumPair;k++)
     {
      for(j=0;j<tf_desk;j++)
        {
         double MAL=iMA(pair[k],Trend_Timeframe[j],mal_period,mal_shift,mal_method,mal_price,0);
         if(iHigh(pair[k],Trend_Timeframe[j],0)>=MAL && 
            iOpen(pair[k],Trend_Timeframe[j],0)<=MAL && 
            iClose(pair[k],Trend_Timeframe[j],0)<=MAL && 
            iLow(pair[k],Trend_Timeframe[j],0)<=MAL)
           {
            mess_data[k][j]="D";mess_color[k][j]=clrRed;
            if(k>0 && use_alert)

               if(alert_flag!=1)
                 {
                  Alert(pair[k]," ",Trend_Timeframe[j]," ",down_alert);
                  alert_flag=1;
                 }
           }


         if(iHigh(pair[k],Trend_Timeframe[j],0)>=MAL && 
            iOpen(pair[k],Trend_Timeframe[j],0)>=MAL && 
            iClose(pair[k],Trend_Timeframe[j],0)>=MAL && 
            iLow(pair[k],Trend_Timeframe[j],0)<=MAL)
           {
            mess_data[k][j]="U";mess_color[k][j]=clrLime;
            if(k>0 && use_alert)

               if(alert_flag!=2)
                 {
                  Alert(pair[k]," ",Trend_Timeframe[j]," ",up_alert);
                  alert_flag=2;
                 }
           }
         else {mess_data[k][j]="X";mess_color[k][j]=clrGray;}
        }
     }
  }
//+------------------------------------------------------------------+
 
Marco vd Heijden:
Sir, if don't mind can explain the pupose of using aler_flag? what the no. define? thank you
 
Marco vd Heijden:
This doesn't solve the issues.. the alert still keep popping up....