Delete pre-alert

 

Hi guys. I have a problem I can not solve. I created this code where I have a pre-alert. Buffer1 and buffer2 are pre-alert, while the Buffer 3 and Buffer 4 are

the real alert.

I wish I could erase the dots of the pre-alert all the times that of Alert arrow appears. I made several attempts but did not succeed. Can you help me?

Thank you all, Massimo

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 4

#property indicator_type1 DRAW_ARROW
#property indicator_width1 1
#property indicator_color1 Yellow
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 1
#property indicator_color2 Yellow
#property indicator_label2 "Sell"

#property indicator_type3 DRAW_ARROW
#property indicator_width3 1
#property indicator_color3 Green
#property indicator_label3 "Buy"

#property indicator_type4 DRAW_ARROW
#property indicator_width4 1
#property indicator_color4 Red
#property indicator_label4 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];

double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | Test @ "+Symbol()+","+Period()+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(4);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 108);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 108);
   SetIndexBuffer(2, Buffer3);
   SetIndexEmptyValue(2, 0);
   SetIndexArrow(2, 241);
   SetIndexBuffer(3, Buffer4);
   SetIndexEmptyValue(3, 0);
   SetIndexArrow(3, 242);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| 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 limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   ArraySetAsSeries(Buffer3, true);
   ArraySetAsSeries(Buffer4, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
      ArrayInitialize(Buffer3, 0);
      ArrayInitialize(Buffer4, 0);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if(iDeMarker(NULL, PERIOD_CURRENT, 3, i) == 0 //DeMarker is equal to fixed value
      && iDeMarker(NULL, PERIOD_CURRENT, 3, 1+i) != 0 //DeMarker is not equal to fixed value
      )
        {
         Buffer1[i] = Low[i] - iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick Low - Average True Range
        }
      else
        {
         Buffer1[i] = 0;
        }
      //Indicator Buffer 2
      if(iDeMarker(NULL, PERIOD_CURRENT, 3, i) == 1 //DeMarker is equal to fixed value
      && iDeMarker(NULL, PERIOD_CURRENT, 3, 1+i) != 1 //DeMarker is not equal to fixed value
      )
        {
         Buffer2[i] = High[i] + iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick High + Average True Range
        }
      else
        {
         Buffer2[i] = 0;
        }
      //Indicator Buffer 3
      if(iDeMarker(NULL, PERIOD_CURRENT, 4, i) == 0 //DeMarker is equal to fixed value
      && iDeMarker(NULL, PERIOD_CURRENT, 4, 1+i) != 0 //DeMarker is not equal to fixed value
      )
        {
         Buffer3[i] = Low[i] - iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick Low - Average True Range
         //Buffer1[i]=False;
         //Buffer2[i]=False;
         
         
        }
      else
        {
         Buffer3[i] = 0;
        }
      //Indicator Buffer 4
      if(iDeMarker(NULL, PERIOD_CURRENT, 4, i) == 1 //DeMarker is equal to fixed value
      && iDeMarker(NULL, PERIOD_CURRENT, 4, 1+i) != 1 //DeMarker is not equal to fixed value
      )
        {
         Buffer4[i] = High[i] + iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick High + Average True Range
         //Buffer1[i]=False;
         //Buffer2[i]=False;
        }
      else
        {
         Buffer4[i] = 0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

 

Delete 

 double Buffer1[];

double Buffer2[];
anf than delte all what comilier will say.
 
Hello eevviill thanks for the answer, but you have to help me because I can not solve. I entered the code but I can not figure out where to enter "delete".

Thanks for everything and for your kindness, greetings, Massimo.

//Indicator Buffer 3
      if(iDeMarker(NULL, PERIOD_CURRENT, 4, i) == 0 
      && iDeMarker(NULL, PERIOD_CURRENT, 4, 1+i) != 0
      )
        {
         Buffer3[i] = Low[i] - iATR(NULL, PERIOD_CURRENT, 14, i); 
        
         Buffer1[1]=0;
         Buffer2[1]=0;
         
         
        }
      else
        {
         Buffer3[i] = 0;
        }
 

?

Attach code in file. 

 
eevviill:

?

Attach code in file. 


Eevviill Hello, I tried but it gives me error. Where I'm wrong. I'm sorry!! Thank you!!

 //Indicator Buffer 3
      if(iDeMarker(NULL, PERIOD_CURRENT, 4, i) == 0 //DeMarker is equal to fixed value
      && iDeMarker(NULL, PERIOD_CURRENT, 4, 1+i) != 0 //DeMarker is not equal to fixed value
      )
        {
         Buffer3[i] = Low[i] - iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick Low - Average True Range
          delete
          double Buffer1[1];
          double Buffer2[1];
         
         
        }
      else
        {
         Buffer3[i] = 0;
        }
 
omissamf: . Buffer1 and buffer2 are pre-alert,  ... erase the dots of the pre-alert
Just don't assign to them
/*
     //Indicator Buffer 1
      if(iDeMarker(NULL, PERIOD_CURRENT, 3, i) == 0 //DeMarker is equal to fixed value
      && iDeMarker(NULL, PERIOD_CURRENT, 3, 1+i) != 0 //DeMarker is not equal to fixed value
      )
        {
         Buffer1[i] = Low[i] - iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick Low - Average True Range
        }
      else
        {
         Buffer1[i] = 0;
        }
      //Indicator Buffer 2
      if(iDeMarker(NULL, PERIOD_CURRENT, 3, i) == 1 //DeMarker is equal to fixed value
      && iDeMarker(NULL, PERIOD_CURRENT, 3, 1+i) != 1 //DeMarker is not equal to fixed value
      )
        {
         Buffer2[i] = High[i] + iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick High + Average True Range
        }
      else
        {
         Buffer2[i] = 0;
        }
*/
     //Indicator Buffer 3
:
 
omissamf:

Eevviill Hello, I tried but it gives me error. Where I'm wrong. I'm sorry!! Thank you!!

And do not use this 

if(Digits() == 5 || Digits() == 3)

     {

      myPoint *= 10;

     } 

 

There are many pairs that have 1Point=4,6... digits

Just set to inputs

enum dig_koefs

{

_1=1,_10=10,_100=100, 

};

extern  dig_koefs point_koef=_10;

...

 myPoint = Point*point_koef; 

	          
Files:
lfuk45qi.mq4  4 kb
 
Hi guys and thanks for the answers, but I still do not understand. Forgive me !!!
In the attached photo, we see the result indicator. If I did not declare the buffer half as suggest by WHRoeder, the graph does not appear on pre-alert.
  I would rather that when you see the green or red arrow, yellow dots of pre-alert disappear, leaving only the arrows of Alert.
I would like every time you see an arrow, the buffer1 / 2 results were deleted from the chart.
  Thanks for everything, Massimo.




 
Hi guys, I have tried to solve in this world, but it does not work. If the arrow disappear, appear again all the yellow dots.
Thanks for your cooperation, Massimo.
//Indicator Buffer 3
      if(iDeMarker(NULL,PERIOD_CURRENT,4,i)==0 //DeMarker is equal to fixed value
         && iDeMarker(NULL,PERIOD_CURRENT,4,1+i)!=0 //DeMarker is not equal to fixed value
         )
        {
         Buffer3[i]=Low[i]-iATR(NULL,PERIOD_CURRENT,14,i); //Set indicator value at Candlestick Low - Average True Range
        SetIndexStyle(0,DRAW_ARROW,EMPTY,1,clrNONE);
        //SetIndexStyle(1,DRAW_ARROW,EMPTY,1,clrNONE);

        }
      else
        {
         Buffer3[i]=0;
         SetIndexStyle(0,DRAW_ARROW,EMPTY,1,clrYellow);
         //SetIndexStyle(1,DRAW_ARROW,EMPTY,1,clrYellow);
 
I have atached ready file. Is it ok?
 
eevviill:
I have atached ready file. Is it ok?
Hello eevviill. In the file you sent me, you have taken away the buffer 1/2 which are the pre-alert.
Instead, the pre alert should appear and must disappear when the alert appears.
The pre alert are the yellow dots. When I see the yellow dot I prepare for entry and I wait to appear the arrow. If I see the arrow , I enter otherwise expect another occasion. When the red or green arrow appear,  I would like the yellow dots were deleted, leaving the cleanest look.
Thanks for everything, Massimo.
Reason: