_MAX_Stops_Multi_v1.1





//+------------------------------------------------------------------+
//|                                        _MAX_Stops_Multi_v1.0.mq4 |
//|                                                 Copyright © 2009 |
//|                                       Written by Massimo Gentili |
//|                                          whitehawk71@hotmail.com |                                      
//|                         Freely inspired from ATR Stops by Agorad |  
//+------------------------------------------------------------------+
#property copyright "Copyright Massimo Gentili © 2009 "

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

double Buffer.Up[],Buffer.Dn[];//buffers


double alertBar;


extern double OverBoost = 0.065;
extern double Kv=0.05;
extern double Kz=0.0;
extern int Precision = 7;
extern string Valid_TF = "_______ CUR, M1, M5, M30, H1, H4, D1, W1, MN1 _______";
extern string TimeFrame="CUR";   // CUR, M1, M5, M30, H1, H4, D1, W1, MN1
extern bool AlertEnabled=false;
extern bool DetailsOnMajorTF=true;
int TF=0;

int LastAlertBarTime;
//int LastAlertType = 0; // 0 - is never alerted, 1 - buy breakout, 2 - sell breakout

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators


// Uncomment if you want to show lines
// comment if you want to show dots 
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);

// comment if you want to show lines
// Uncomment if you want to show dots 
/*
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT);
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
*/
   SetIndexBuffer(0,Buffer.Up);
   SetIndexBuffer(1,Buffer.Dn);
   
   IndicatorShortName("MAX_Stops_Multi");
   SetIndexLabel(0,"MAX_Stops_(" + TimeFrame + ") Up Dir");
   SetIndexLabel(1,"MAX_Stops_(" + TimeFrame + ") Down Dir");
   
   SetIndexDrawBegin(0,2);
   SetIndexDrawBegin(1,2);

//----
        if ( TimeFrame == "CUR" ) TF = 0; 
   else if ( TimeFrame == "M1"  ) TF = 1;   
   else if ( TimeFrame == "M5"  ) TF = 5;   
   else if ( TimeFrame == "M15" ) TF = 15;   
   else if ( TimeFrame == "M30" ) TF = 30;   
   else if ( TimeFrame == "H1"  ) TF = 60;   
   else if ( TimeFrame == "H4"  ) TF = 240;   
   else if ( TimeFrame == "D1"  ) TF = 1440;   
   else if ( TimeFrame == "W1"  ) TF = 10080;   
   else if ( TimeFrame == "MN1" ) TF = 43200;   

   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(),TF); 
   
   limit=Bars-counted_bars;
   if ( !DetailsOnMajorTF ) limit += TF/Period();
   
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;
   
      //double sar = NormalizeDouble(iCustom(Symbol(),TimeFrame,Step,Maximum,y),Precision);
      Buffer.Up[i] = NormalizeDouble(iCustom(Symbol(),TF,"_MAX_Stops_v1.1", OverBoost, Kv, Kz, 1, y),Precision);
      Buffer.Dn[i] = NormalizeDouble(iCustom(Symbol(),TF,"_MAX_Stops_v1.1", OverBoost, Kv, Kz, 0, y),Precision);
      
// Alert treatment  
   if ( AlertEnabled && (LastAlertBarTime != Time[0]) )
   {
      string AlertMsg = "";
      if ( (Buffer.Up[1] == EMPTY_VALUE) &&  (Buffer.Up[0] != EMPTY_VALUE) ) AlertMsg = "UP direction at";
      if ( (Buffer.Dn[1] == EMPTY_VALUE) &&  (Buffer.Dn[0] != EMPTY_VALUE) ) AlertMsg = "DOWN direction at";
 
      
      if ( AlertMsg != "" ) 
      {
        LastAlertBarTime = Time[0];
        Alert ("[" + TimeFrame + "] Possible Breakout for " + AlertMsg + " at " + TimeToStr(iTime(NULL, TF, 0), TIME_DATE|TIME_MINUTES)); 
      }  
   }
   }

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



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_ARROW


Indicators Used:




Custom Indicators Used:
_MAX_Stops_v1.1

Order Management characteristics:

Other Features: