Navigation:Home > Content >

Price_Action_CPR.mq4

Time: 2016-11-25 | Download file:Price_Action_CPR.mq4

//+------------------------------------------------------------------+
//|                                             Price Action_CPR.mq4 |
//+------------------------------------------------------------------+

#property copyright "Dmitry Zhebrak aka Necron,© 2010"
#property link      "http://www.fxgeneral.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Gray
#property indicator_color2 Gray
//---- input parameters
extern bool show_pattern=true;
extern int Size = 1;       // Изменение размера значка.
extern double multiplier=1;
extern int Bars_ATR=233;//период для ATR
extern int Code_Arrow=159;

//---- buffers
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
 {
  // indicator buffers mapping  
 if (show_pattern == true) SetIndexBuffer(0, ExtUpFractalsBuffer);
 if (show_pattern == true) SetIndexBuffer(1, ExtDownFractalsBuffer);
  //  drawing settings
  SetIndexStyle (0, DRAW_ARROW, EMPTY, Size);
  SetIndexArrow (0, Code_Arrow);
  SetIndexStyle (1, DRAW_ARROW, EMPTY, Size);
  SetIndexArrow (1, Code_Arrow);
  //----
  SetIndexEmptyValue (0, 0.0);
  SetIndexEmptyValue (1, 0.0);
  // name for DataWindow
  SetIndexLabel (0,  "CPR_Dn");
  SetIndexLabel (1,  "CPR_Up");
  // initialization done   
  return(0);
 }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
 {

  int    i,nCountedBars;
  bool   bFound;
  bool   AlertUP, AlertDOWN;
  double dCurrent,range;
  nCountedBars=IndicatorCounted();
  range=iATR(NULL,0,Bars_ATR,0);

  // last counted bar will be recounted    
  if (nCountedBars <= 2) i = Bars - nCountedBars + 8;
  if (nCountedBars > 2)
   {
    nCountedBars--;
    i = Bars - nCountedBars + 8;
    
    
   }
  // Up and Down Fractals
  while (i >= 1)
   {
    // Fractals up
    bFound = false;
    dCurrent = High[i];
    if (Open[i]>=Close[i+1]  && High[i] > High[i + 1] && Close[i]<=Close[i+1])
     {
      bFound = true;
      AlertUP = true;
      ExtUpFractalsBuffer[i] = dCurrent +range*multiplier/10;
     }
                               
    // Fractals down
    bFound = false;
    dCurrent = Low[i];
    if (Open[i]<=Close[i+1] && Low[i] < Low[i + 1] && Close[i]>=Close[i+1])
     {
      bFound = true;
      AlertDOWN = true;
      ExtDownFractalsBuffer[i] = dCurrent -range*multiplier/10;
     }
                               
    i--;
   }
  return(0);
 }
//+------------------------------------------------------------------+

Recommend