New_bar_alerter

Author: mladen
Miscellaneous
It issuies visual alerts to the screenIt sends emailsIt plays sound alerts
0 Views
0 Downloads
0 Favorites
New_bar_alerter
//------------------------------------------------------------------
#property copyright "mladen"
#property link      "www.forex-tsd.com"
#property version   "1.00"
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0

input bool alertsOn      = false; // Turn alerts on?
input bool alertsMessage = true;  // Display messageas on alerts?
input bool alertsSound   = false; // Play sound on alerts?
input bool alertsEmail   = false; // Send email on alerts?
input bool alertsShow    = false; // Display alerter comment text?


//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int OnInit() { return(0); }
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 &TickVolume[],
                const long &Volume[],
                const int &Spread[])
{
   static datetime prevTime=0;
      if (prevTime!=time[rates_total-1])
      if (prevTime!=0)
            doAlert(time[rates_total-1],"new bar formed");
      prevTime=time[rates_total-1];
   if (alertsShow) Comment("New bar alerter last checked status at : "+TimeToString(TimeLocal(),TIME_SECONDS));
   return(rates_total);
}


//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

void doAlert(datetime forTime, string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
   if (previousAlert != doWhat || previousTime != forTime) 
   {
      previousAlert  = doWhat;
      previousTime   = forTime;

      //
      //
      //
      //
      //

      message = TimeToString(TimeLocal(),TIME_SECONDS)+" "+_Symbol+" new bar alerter : "+doWhat;
         if (alertsMessage) Alert(message);
         if (alertsEmail)   SendMail(_Symbol+" new bar alerter",message);
         if (alertsSound)   PlaySound("alert2.wav");
   }
}

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