BigBarSound_v1

Author: Alexey Volchanskiy
Price Data Components
Miscellaneous
It plays sound alertsIt issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
BigBarSound_v1
//+------------------------------------------------------------------+
//|                                                  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"

#include <Trade\SymbolInfo.mqh>

enum StartPoint {OpenClose,HighLow};

input ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT;
input int             BarPoint  = 200;
input StartPoint      SP        = HighLow;
input string          WavFile   = "alert.wav";
input bool            ShowAlert = false;

MqlRates rates_array[1];
CSymbolInfo symbolInfo;
//+------------------------------------------------------------------+
//| Detects begin of new bar                                         |
//+------------------------------------------------------------------+
bool NewBar()
  {
   static datetime lastbar=0;
   datetime curbar=rates_array[0].time;
   if(lastbar!=curbar)
     {
      lastbar=curbar;
      return (true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   double diff=0;
   static bool trigger=true; // for one-shot play sound in bar duration
   symbolInfo.RefreshRates();
   if(!CopyRates(_Symbol,TimeFrame,0,1,rates_array))
     {
      Print("ERROR: Can't copy the new bar data!");
      return;
     }
   if(NewBar())
      trigger=true;

   if(SP==OpenClose)
      diff=MathAbs(symbolInfo.Ask()-rates_array[0].open);
   else
      diff=MathAbs(rates_array[0].high-rates_array[0].low);
   if(trigger && diff>=BarPoint*Point())
     {
      PlaySound(WavFile);
      trigger=false;
      if(ShowAlert)
         Alert("Signal!");
     }
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---