BigBarSound

Author: Alexey Volchanskiy
Price Data Components
Series array that contains open prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
BigBarSound
//+------------------------------------------------------------------+
//|                                                  BigBarSound.mq4 |
//|                                               Alexey Volchanskiy |
//|                                         http://www.robo-forex.ru |
//+------------------------------------------------------------------+
#property copyright "Alexey Volchanskiy"
#property link      "http://www.robo-forex.ru"
#property version   "1.00"
#property strict
#property description "EA plays WavFile when bar size is lager of BarPoint value"


enum StartPoint {OpenClose,HighLow};

input int           BarPoint    = 200;
input StartPoint    SP          = HighLow;
input string        WavFile     = "alert.wav";

//+------------------------------------------------------------------+
//| Detects begin of new bar                                         |
//+------------------------------------------------------------------+
bool NewBar()
  {
   static datetime lastbar=0;
   datetime curbar=iTime(NULL,0,0);
   if(lastbar!=curbar)
     {
      lastbar=curbar;
      return (true);
     }
   return(false);
  }

void OnTick()
  {
   RefreshRates();
   double diff=0;
   static bool trigger=true; // for one-shot play sound in bar duration
   if(NewBar())
      trigger=true;

   if(SP==OpenClose)
      diff=MathAbs(Ask-iOpen(NULL,0,0));
   else
      diff=MathAbs(iHigh(NULL,0,0)-iLow(NULL,0,0));
   if(trigger && diff>=BarPoint*Point())
     {
      PlaySound(WavFile);
      trigger=false;
     }
  }

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  }

Comments