help on new developed indicator

 

the arrow doesnt show on live until i switch time frame , please help me .

below is the codes.

//+------------------------------------------------------------------+
//|                                              signalindicator.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Red

#property indicator_color4 Red

extern int FastEMA = 5;
extern int SlowEMA = 6;
extern int RSIPeriod = 7;
extern bool Alerts = TRUE;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_2[];
int a = 0;
int b = 0;
double x = 0.0;
double y = 0.0;
 double alertshow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_NONE);
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,4);
   SetIndexArrow(2, 241);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,4);
   SetIndexArrow(3, 242);
   SetIndexBuffer(3, arrow_2);
   SetIndexEmptyValue(3, 0.0);

   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }
//+------------------------------------------------------------------+
//| expert start 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 counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   int li_0;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   if(counted_bars==0)
      li_0=MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else
      li_0=Bars-counted_bars;
   for (int i = 0; i < li_0; i++) {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
      if (x > 0.0 && irsi_1 > 50.0) a = 1;
      else
         if (x < 0.0 && irsi_1 < 50.0) a = 2;
      if (a == 1 && b == 2) {
         arrow_2[i - 1] = High[i - 1] - 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
      } else {
         if (a == 2 && b == 1) {
            arrow_1[i - 1] = Low[i - 1] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
         }
      }
      b = a;
      y = x;
   }
   if (Alerts && c) {
      PlaySound("alert.wav");
      if (b == 2)  
      
         if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol()," buy signal");
            alertshow=Time[1];
           }
      else
         if (b == 1) if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol(),"  sell signal");
            alertshow=Time[1];
           }
   }
//----
   return(prev_calculated);
  }
//+------------------------------------------------------------------+
 
//+------------------------------------------------------------------+
//|                                              signalindicator.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Red

#property indicator_color4 Red

extern int FastEMA = 5;
extern int SlowEMA = 6;
extern int RSIPeriod = 7;
extern bool Alerts = TRUE;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_2[];
int a = 0;
int b = 0;
double x = 0.0;
double y = 0.0;
 double alertshow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_NONE);
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,4);
   SetIndexArrow(2, 241);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,4);
   SetIndexArrow(3, 242);
   SetIndexBuffer(3, arrow_2);
   SetIndexEmptyValue(3, 0.0);

   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }
//+------------------------------------------------------------------+
//| expert start 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 counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   int li_0;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   if(counted_bars==0)
      li_0=MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else
      li_0=Bars-counted_bars;
   for (int i = 0; i < li_0; i++) {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i+1);
      x = buffer_1[i] - buffer_2[i];
      if (x > 0.0 && irsi_1 > 50.0) a = 1;
      else
         if (x < 0.0 && irsi_1 < 50.0) a = 2;
      if (a == 1 && b == 2) {
         arrow_2[i ] = High[i +1] - 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
      } else {
         if (a == 2 && b == 1) {
            arrow_1[i ] = Low[i +1] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
         }
      }
      b = a;
      y = x;
   }
   if (Alerts && c) {
      PlaySound("alert.wav");
      if (b == 2)  
      
         if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol()," buy signal");
            alertshow=Time[1];
           }
      else
         if (b == 1) if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol(),"  sell signal");
            alertshow=Time[1];
           }
   }
//----
   
 
I need ur help , gurus in the house should please help me out
 
If you had looked in the journal you would have seen the array exceeded message. When i is zero array_2[i - 1] and High[i - 1] do not exist.
Why does an arrow depend on a future price?
 for (int i = 0; i < li_0; i++) {
   :
      if (a == 1 && b == 2) {
         arrow_2[i - 1] = High[i - 1]
 
WHRoeder:
If you had looked in the journal you would have seen the array exceeded message. When i is zero array_2[i - 1] and High[i - 1] do not exist.
Why does an arrow depend on a future price?


sir,have done that , but am still having the same problem and even the signal doesnt print base on  my condition again.

please help me out

//+------------------------------------------------------------------+
//|                                              signalindicator.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Red

#property indicator_color4 Red

extern int FastEMA = 5;
extern int SlowEMA = 6;
extern int RSIPeriod = 7;
extern bool Alerts = TRUE;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_2[];
int a = 0;
int b = 0;
double x = 0.0;
double y = 0.0;
 double alertshow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_NONE);
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,4);
   SetIndexArrow(2, 241);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,4);
   SetIndexArrow(3, 242);
   SetIndexBuffer(3, arrow_2);
   SetIndexEmptyValue(3, 0.0);

   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }
//+------------------------------------------------------------------+
//| expert start 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 counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   int li_0;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   if(counted_bars==0)
      li_0=MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else
      li_0=Bars-counted_bars;
   for (int i = 0; i < li_0; i++) {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
      if (x > 0.0 && irsi_1 > 50.0) a = 1;
      else
         if (x < 0.0 && irsi_1 < 50.0) a = 2;
      if (a == 1 && b == 2) {
         arrow_2[i +1] = High[i +1] - 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
      } else {
         if (a == 2 && b == 1) {
            arrow_1[i +1] = Low[i +1] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
         }
      }
      b = a;
      y = x;
   }
   if (Alerts && c) {
      PlaySound("alert.wav");
      if (b == 2)  
      
         if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol()," buy signal");
            alertshow=Time[1];
           }
      else
         if (b == 1) if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol(),"  sell signal");
            alertshow=Time[1];
           }
   }
//----
 
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   if(counted_bars==0)
      li_0=MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else
      li_0=Bars-counted_bars;
   for (int i = 0; i < li_0; i++) {
  1. No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 forum
  2. What is the minus 10? Handle your look back properly.
  3. Always count down so you can't use future values in computing past results (repainting.)
    int lookBack = MathMax(FastEMA,SlowEMA);
    int li_0 = Bars - 1 - MathMax(lookBack, counted_bars);
    for(int i = li_0; i >= 0; --i){
    

  4. if (x > 0.0 && irsi_1 > 50.0) a = 1;
    else
       if (x < 0.0 && irsi_1 < 50.0) a = 2;
    if (a == 1 && b == 2) {
    If neither are true, the value of a is from a future bar. The value of b is always a future bar. Count down and you must initialize them to the value they had at li_0 + 1. Therefor you must save them in two additional buffers.
  5. If changing the loop doesn't help, add print statements and find out why.
 
WHRoeder:
  1. No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 forum
  2. What is the minus 10? Handle your look back properly.
  3. Always count down so you can't use future values in computing past results (repainting.)
  4. If neither are true, the value of a is from a future bar. The value of b is always a future bar. Count down and you must initialize them to the value they had at li_0 + 1. Therefor you must save them in two additional buffers.
  5. If changing the loop doesn't help, add print statements and find out why.

Sir , have done that ,but noting show up .

here is the adjusted code


//+------------------------------------------------------------------+
//|                                              signalindicator.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Red


int FastEMA = 5;
 int SlowEMA = 6;
 int RSIPeriod = 7;
extern bool Alerts = TRUE;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_2[];
int a = 0;
int b = 0;
bool c;
double x = 0.0;
double y = 0.0;
 double alertshow;
 int lookBack;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_NONE);
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,4);
   SetIndexArrow(2, 217);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,4);
   SetIndexArrow(3, 218);
   SetIndexBuffer(3, arrow_2);
   SetIndexEmptyValue(3, 0.0);
   
   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }
//+------------------------------------------------------------------+
//| expert start 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 counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars;
   if(counted_bars==0)
   lookBack = MathMax(FastEMA,SlowEMA);
   int li_0 = Bars - 1 - MathMax(lookBack, counted_bars);
   for(int i = li_0; i >= 0; --i) {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
     if (x > 0.0 && irsi_1 > 50.0) a = 1;
      else
   if (x < 0.0 && irsi_1 < 50.0) a = 2;
   if (a == 1 && b == 2)  {
         arrow_2[i +1] = High[i +1] + 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
        
      } else {
         if (a == 2 && b== 1) {
            arrow_1[i +1] = Low[i +1] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
          
         }
      }
      y = x;
   }
   if (Alerts && c) {

      if (b == 2)  
      
         if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol()," buy signal");
            alertshow=Time[1];
           }
      else
         if (b == 1) if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol(),"  sell signal");
            alertshow=Time[1];
           }
   }
//----
   return(rates_total);
  }   
//----
 

I think you should change this

 for (int i = 0; i < li_0; i++)

for this :

 for (int i = li_0; i >= 0; i--) 

But if you do that, for some weird raison, your up_arrow become down_arrow, and vice versa.


if it is reliable this way, then change the up_arrow for the down_arrow :-)

Edit : I find this

 if (x > 0.0 && irsi_1 > 50.0){ a = 1;  } // if this is up condition a = 1 ( check if (FAST - SLOW) >0 is up condition
       if (x < 0.0 && irsi_1 < 50.0) { a = 2; }
      if (a == 1 && old == 2) 
         {
         arrow_down[i] = High[i] - 5.0 * Point;// then if a=1 should be up_arrow 
         c= TRUE;
         price_10 = Ask;
         } 
     if (a == 2 && old == 1 ) 
           {
            arrow_1[i] = Low[i] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
            }
      old = a; // store the old value, then compare it to new one(a), to see if it get new condition


Edit : I get it, it was falsely coded, the i++ go and see if there is a change on bar 2 or 3, in the past, if there is a change the change is in reverse order, it work because the old value is stored, and cannot be changed thereafter.

 for (int i = li_0; i >=0; i--) {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
      if (x > 0.0 && irsi_1 > 50.0) a = 1;
      else
         if (x < 0.0 && irsi_1 < 50.0) a = 2;
      if (a == 1 && b == 2) {
          arrow_1[i] = Low[i] - 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
      } else {
         if (a == 2 && b == 1) {
           arrow_2[i] = High[i] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
         }
      }
      b = a;
      y = x;
   }

The alert wll have to be recoded

 
kewu: Sir , have done that ,but noting show up .
No you didn't
you must initialize them to the value they had at li_0 + 1. Therefor you must save them in two additional buffers.
 
WHRoeder:
kewu: Sir , have done that ,but noting show up .
No you didn't
you must initialize them to the value they had at li_0 + 1. Therefor you must save them in two additional buffers.


Sir, i don't understand u , can u please help me to do it so that i will learn from it .
 
ffoorr:

I think you should change this

for this :

But if you do that, for some weird raison, your up_arrow become down_arrow, and vice versa.


if it is reliable this way, then change the up_arrow for the down_arrow :-)

Edit : I find this

Edit : I get it, it was falsely coded, the i++ go and see if there is a change on bar 2 or 3, in the past, if there is a change the change is in reverse order, it work because the old value is stored, and cannot be changed thereafter.

The alert wll have to be recoded

Have done it but it doesnt produce base on my condition.

here is my code

//+------------------------------------------------------------------+
//|                                              signalindicator.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Red


int FastEMA = 5;
 int SlowEMA = 6;
 int RSIPeriod = 7;
extern bool Alerts = TRUE;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_2[];
int a = 0;
int b = 0;
double x = 0.0;
double y = 0.0;
 double alertshow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_NONE);
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,4);
   SetIndexArrow(2, 241);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,4);
   SetIndexArrow(3, 242);
   SetIndexBuffer(3, arrow_2);
   SetIndexEmptyValue(3, 0.0);

   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }
//+------------------------------------------------------------------+
//| expert start 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 counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   int li_0;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   if(counted_bars==0)
      li_0=MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else
      li_0=Bars-counted_bars;
      
   for (int i = li_0; i >= 0; i--)
  {
   
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
       if (x > 0.0 && irsi_1 > 50.0)
            { a = 1;  }
      else
          if (x < 0.0 && irsi_1 < 50.0)
                { a = 2; }
          
     if (a == 1 && b == 2) {
            arrow_1[i] = Low[i] + 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
         
      } 
     else 
         if (a == 2 && b == 1) {
         arrow_2[i] = High[i] - 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
         }
      
      b = a;
      y = x;
   }
   if (Alerts && c) {
    
      if (b == 2)  
      
         if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol()," sell signal");
            alertshow=Time[1];
           }
      else
         if (b == 1) if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol(),"  buy signal");
            alertshow=Time[1];
           }
   }
//----
   return(prev_calculated);
  }
//+------------------------------------------------------------------+
Reason: