Modify this volume alert please!

My guess is that its missing some code because it does not want to start. After I drag it to the chart, choose options and click OK, nothing shows up. And the expert tab says it was removed.

If possible:

  1. The volume I’m looking at is on the 5min but options for other TFs would be nice.

  2. I need this on a bar by bar basis. So if Volume>x, send an email. If the next bar is also Volume>x, send another email. An email should be sent everytime Volume>x BUT no repeat emails for the same alert.

Thank you thank you thank you to anyone that can do this!


//+------------------------------------------------------------------+
//|                                                  VolumeSpike.mq4 |
//|                                   Copyright © 2008, Antonuk Oleg |
//|                                            [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Antonuk Oleg"
#property link      "[email protected]"

#property indicator_chart_window
//---- input parameters
extern string    emailSubject="Time to trade (VolumeSpike indicator)",
                 emailText="It is  signal from VolumeSpike indicator";
extern int       volumeValue=50;

int currentDay, lastDay;
bool emailSentToday;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   emailSentToday=false;
   currentDay=DayOfYear();
   lastDay=DayOfYear();

   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   if(!emailSentToday)
   {
      if(Volume[0]>volumeValue)
         SendMail(emailSubject,emailText);
      
      emailSentToday=true;   
   }
   else
   {
      currentDay=DayOfYear();
      
      if(currentDay!=lastDay)
      {
         emailSentToday=false;
         lastDay=currentDay;
      }
   }   
   
   return(0);
}
//+------------------------------------------------------------------+

This should work per Bar on any timeframe.


//+------------------------------------------------------------------+
//|                                                  VolumeSpike.mq4 |
//|                                   Copyright © 2008, Antonuk Oleg |
//|                                            [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Antonuk Oleg"
#property link      "[email protected]"

#property indicator_chart_window
//---- input parameters
extern string    emailSubject="Time to trade (VolumeSpike indicator)",
                 emailText="It is  signal from VolumeSpike indicator";
extern int       volumeValue=50;

int currentDay, lastDay;
bool emailSentToday;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   emailSentToday=false;
   currentDay=iBars(NULL,0);
   lastDay=iBars(NULL,1);

   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   if(!emailSentToday)
   {
      if(iVolume(NULL,0,0)>volumeValue)
         SendMail(emailSubject,emailText);
         emailSentToday= true;
  
   }
   if (emailSentToday)
   {   if(iVolume(NULL,0,0)<volumeValue)
        emailSentToday= false;
   }
   return(0);
}
//+------------------------------------------------------------------+

THANKS A BUNCH! I will let you know if theres any problems.

Works like a charm! Thanks a million!

If it isn’t too much of a bother… Can you do the same to this one? I tried myself but just keep messing it up. I SWEAR! I’m done after this one! :smiley:

Again, its bar by bar. I would like an email sent if the wick/indicator passes a threshold of say… 7 pips on either side of the histogram. The histogram reads the entire price so 7 pips would be 0.0007

Thanks in advance!!!


//+------------------------------------------------------------------+

//| Wick.mq4 |

//| Seavo |

//| http://www.forexfactory.com/member.php?u=17692 |

//+------------------------------------------------------------------+

#property copyright "Seavo"

#property link "http://www.forexfactory.com/member.php?u=17692"

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 White
#property indicator_color4 White

//---- external variables
extern bool ShowAtr = false;
extern int AtrPeriod = 14;
extern double  kAtr = 0.62;

extern bool ShowNetWick = true;


//---- buffers

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
if (ShowAtr)
{
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);

SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
}
string short_name = "Wick";

IndicatorShortName(short_name);

//----

return(1);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

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--;

int pos=Bars-counted_bars;



//---- main calculation loop
double dResult1;
double dResult2;
double dResult3;
double dResult4;
while(pos>=0)

{
if (iOpen(NULL, 0, pos) > iClose(NULL, 0, pos)){
   dResult1 = iHigh(NULL, 0, pos) - iOpen(NULL, 0, pos);
   }
if (iOpen(NULL, 0, pos) <= iClose(NULL, 0, pos)){
   dResult1 = iHigh(NULL, 0, pos) - iClose(NULL, 0, pos);
   }
if (iOpen(NULL, 0, pos) > iClose(NULL, 0, pos)){
   dResult2 = iLow(NULL, 0, pos) - iClose(NULL, 0, pos);
   }
if (iOpen(NULL, 0, pos) <= iClose(NULL, 0, pos)){
   dResult2 = iLow(NULL, 0, pos) - iOpen(NULL, 0, pos);
   }
if (ShowAtr){
   dResult3 = iATR(NULL,0,AtrPeriod, pos)*kAtr ;
   dResult4 = (0 - iATR(NULL,0,AtrPeriod, pos)*kAtr );

   ExtMapBuffer3[pos]= dResult3 ;
   ExtMapBuffer4[pos]= dResult4 ;

   }

 if (ShowNetWick)
   {
      double dResultNet =  dResult1 +dResult2;
      if (dResultNet>0) {  //dResult1= dResultNet;
                           ExtMapBuffer1[pos]= dResultNet ;
                         }
      else                 ExtMapBuffer2[pos]= dResultNet ;
   }
  else
   {
   ExtMapBuffer1[pos]= dResult1 ;
   ExtMapBuffer2[pos]= dResult2 ;
   }
   

pos--;

}

//----

return(0);

}

//+------------------------------------------------------------------+