Parabolic_mailalert

Download script
Author: Kalenzo
Parabolic_mailalert

This script is a specialized technical analysis tool designed for the MetaTrader platform. It enhances the standard Parabolic SAR (Stop and Reverse) indicator by providing visual clarity and automated notifications based on market momentum shifts.

Core Functionality

The primary purpose of this tool is to identify "trend flips." In trading, the Parabolic SAR typically appears as dots above or below the price candles to indicate potential reversal points. This script automates the tracking of these reversals and categorizes them into two distinct states: an "Up Channel" and a "Down Channel."

How the Logic Works

The script operates by constantly comparing current market prices against the calculated Parabolic SAR values across specific timeframes. Here is the step-by-step logic it follows:

  • Multi-Timeframe Analysis: Unlike basic indicators that only look at the chart you are currently viewing, this script can be configured to monitor a specific historical timeframe (such as Hourly or Daily) and project those trends onto your current screen. This allows traders to see "the big picture" while looking at shorter, faster price movements.
  • Trend Detection: The script monitors the relationship between the market's high price and the SAR value:
    • Downward Trend Logic: If the calculated SAR value is higher than the high of the current candle, the script identifies a "Down Channel."
    • Upward Trend Logic: If the SAR value falls below the high of the current candle, the script identifies an "Up Channel."
  • Visual Representation: To make these shifts easy to see at a glance, the script uses two separate visual buffers. It distinguishes between the two trends by applying different colors and styles on the chart, allowing you to immediately see which direction the trend is currently leaning.

Automated Notifications

One of the key features for active traders is the integrated alert system. The script is programmed to "watch" for the exact moment a reversal occurs:

  • Audio Alerts: You can set the tool to play a sound file automatically when the trend switches from up to down (or vice versa).
  • Email Notifications: For traders who are away from their computers, the logic includes an option to send an automated email notification the moment a trend change is detected.
  • Smart Filtering: To prevent the system from sending constant alerts during a single trend, it includes "logic gates" that ensure a notification is only triggered once per trend shift, rather than on every single candle movement.
Price Data Components
Series array that contains the highest prices of each bar
Indicators Used
Parabolic Stop and Reverse system
Miscellaneous
Implements a curve of type %1It plays sound alertsIt sends emails
12 Views
0 Downloads
0 Favorites
Parabolic_mailalert
//+------------------------------------------------------------------+
//|                                                    SAR_COLOR.mq4 |
//|                                                          Kalenzo |
//|                                       http://www.foreksik.prv.pl |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "http://www.foreksik.prv.pl"

#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 1
#property indicator_width2 1

double sarUp[],sarDn[];//buffers
extern bool AlertsEnabled=false;
extern bool email=false;
extern double Step = 0.02;//was .01
extern double Maximum = 0.2;
extern int Precision = 7;
double alertBar;
extern int TimeFrame=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT);
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT);
   SetIndexBuffer(0,sarUp);
   SetIndexBuffer(1,sarDn);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   
   IndicatorShortName("SAR COLORED");
   SetIndexLabel(0,"SAR Up Channel");
   SetIndexLabel(1,"SAR Down Channel");
   
   SetIndexDrawBegin(0,2);
   SetIndexDrawBegin(1,2);
//----
switch(TimeFrame)
   {
      case 1 : string TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current Timeframe";
   }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;
   
      double sar = NormalizeDouble(iSAR(Symbol(),TimeFrame,Step,Maximum,y),Precision);
          if(sar >= iHigh(Symbol(),0,i))
      {
       if(AlertsEnabled==true && sarUp[i] == 0 && Bars>alertBar)
        {
        PlaySound("alert.wav");

       // Alert("Parabolic SAR Going Down on ",Symbol(),"-",Period());
        if(email)SendMail("Parabolic SAR Going Down on ",Symbol());

        alertBar = Bars;
       }
         sarUp[i] = sar;  
         sarDn[i] = 0;
      }
    else
      {
       if(AlertsEnabled==true && sarDn[i] == 0 && Bars>alertBar)
        {
        PlaySound("alert.wav");

        //Alert("Parabolic SAR Channel Going Up on ",Symbol(),"-",Period());
        if(email)SendMail("Parabolic SAR Going Up on ",Symbol());
        alertBar = Bars;
        }
         sarUp[i] = 0;
         sarDn[i] = sar;
         WindowRedraw();

       }
   }
 //----
   return(0);
  }
//+------------------------------------------------------------------+

Comments