Navigation:Home > Content >

LOR_2.0.mq4

Time: 2015-12-04 | Download file:LOR_2.0.mq4

#property copyright "© 2008 Law of Repetition 2.0"
#property link      "stigal.com"

#define vers   "2.1.1"


#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1  Black
#property indicator_width1  1
#property indicator_color2  Red
#property indicator_width2  1
#property indicator_width2  1
#property indicator_color3  Black
#property indicator_width3  1
#property indicator_color4  Red
#property indicator_width4  1


extern int MyBar1 = 1;

extern int MyBar1_Body_Plus = 200;
extern int MyBar1_Body_Minus = 200;

extern int MyBar1_UpperShadow_Plus = 200;
extern int MyBar1_UpperShadow_Minus = 200;

extern int MyBar1_LowerShadow_Plus = 200;
extern int MyBar1_LowerShadow_Minus = 200;

extern int MyBar2_Body_Plus = 200;
extern int MyBar2_Body_Minus = 200;

extern int MyBar2_UpperShadow_Plus = 200;
extern int MyBar2_UpperShadow_Minus = 200;

extern int MyBar2_LowerShadow_Plus = 200;
extern int MyBar2_LowerShadow_Minus = 200;


double MyBar1Buf[];
double MyBar2Buf[];
double MyBar1Candles[];
double MyBar2Candles[];

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void init() 
{
  Comment("");

  SetIndexBuffer(0, MyBar1Buf);
  SetIndexBuffer(1, MyBar1Candles);
  SetIndexBuffer(2, MyBar2Buf);
  SetIndexBuffer(3, MyBar2Candles);
  
  SetIndexEmptyValue(0, 0.0);
  SetIndexEmptyValue(1, 0.0);
  SetIndexEmptyValue(2, 0.0);
  SetIndexEmptyValue(3, 0.0);
  
  SetIndexStyle(0, DRAW_ARROW);
  SetIndexArrow(0, 108);
  
  SetIndexStyle(1, DRAW_ARROW);
  SetIndexArrow(1, 108);

  SetIndexStyle(2, DRAW_ARROW);
  SetIndexArrow(2, 108);  

  SetIndexStyle(3, DRAW_ARROW);
  SetIndexArrow(3, 108);  
}

void deinit()
{
  Comment("");
}

void start() 
{
/*
  int counted = IndicatorCounted();
  if (counted < 0) return (-1);
  if (counted > 0) counted--;
  
  int limit = Bars-counted;
*/
    
  int MyBar2 = MyBar1 + 1;
  
  //-----
  
  double dy = 0;
  for (int i=1; i <= 20; i++) 
  {
    dy += 0.3*(High[i]-Low[i])/20;
  }

  for (i=0; i < Bars; i++) 
  {
    MyBar1Buf[i] = 0.0;
    MyBar2Buf[i] = 0.0;
  }

  if (MyBar1 >= 0)
  {
    MyBar1Buf[MyBar1] = High[MyBar1] + dy;
  }
  
  if (MyBar2 >= 0)
  {
    MyBar2Buf[MyBar2] = High[MyBar2] + dy;
  }

  //-----

  bool A1, B1, C1;
  bool A2, B2, C2;

  //-----
  
  for (i=MyBar1+1; i < Bars; i++) 
  {
    if (MyBar1 < 0) break;
    
    MyBar1Candles[i] = 0.0;
    MyBar2Candles[i+1] = 0.0;
    
    if (Open[MyBar1] > Close[MyBar1])
    {
      if (Open[i] <= Close[i]) continue;
    }
    
    if (Open[MyBar1] < Close[MyBar1])
    {
      if (Open[i] >= Close[i]) continue;
    }

    if (Open[MyBar1] == Close[MyBar1])
    {
      if (Open[i] != Close[i]) continue;
    }

    //-----

    A1 = (MathAbs(Open[MyBar1]-Close[MyBar1]) - MyBar1_Body_Minus*Point <= MathAbs(Open[i]-Close[i]) && 
              MathAbs(Open[i]-Close[i]) <= MathAbs(Open[MyBar1]-Close[MyBar1]) + MyBar1_Body_Plus*Point);
    
    B1 = (High[MyBar1] - MathMax(Open[MyBar1], Close[MyBar1]) - MyBar1_UpperShadow_Minus*Point <= High[i] - MathMax(Open[i], Close[i]) && 
              High[i] - MathMax(Open[i], Close[i]) <= High[MyBar1] - MathMax(Open[MyBar1], Close[MyBar1]) + MyBar1_UpperShadow_Plus*Point);
    
    C1 = (MathMin(Open[MyBar1], Close[MyBar1]) - Low[MyBar1] - MyBar1_LowerShadow_Minus*Point <= MathMin(Open[i], Close[i]) - Low[i] && 
              MathMin(Open[i], Close[i]) - Low[i] <= MathMin(Open[MyBar1], Close[MyBar1]) - Low[MyBar1] + MyBar1_LowerShadow_Plus*Point);
    
    
    
    if (Open[MyBar2] > Close[MyBar2])
    {
      if (Open[i+1] <= Close[i+1]) continue;
    }
    
    if (Open[MyBar2] < Close[MyBar2])
    {
      if (Open[i+1] >= Close[i+1]) continue;
    }

    if (Open[MyBar2] == Close[MyBar2])
    {
      if (Open[i+1] != Close[i+1]) continue;
    }

    //-----

    A2 = (MathAbs(Open[MyBar2]-Close[MyBar2]) - MyBar2_Body_Minus*Point <= MathAbs(Open[i+1]-Close[i+1]) && 
              MathAbs(Open[i+1]-Close[i+1]) <= MathAbs(Open[MyBar2]-Close[MyBar2]) + MyBar2_Body_Plus*Point);
    
    B2 = (High[MyBar2] - MathMax(Open[MyBar2], Close[MyBar2]) - MyBar2_UpperShadow_Minus*Point <= High[i+1] - MathMax(Open[i+1], Close[i+1]) && 
              High[i+1] - MathMax(Open[i+1], Close[i+1]) <= High[MyBar2] - MathMax(Open[MyBar2], Close[MyBar2]) + MyBar2_UpperShadow_Plus*Point);
    
    C2 = (MathMin(Open[MyBar2], Close[MyBar2]) - Low[MyBar2] - MyBar2_LowerShadow_Minus*Point <= MathMin(Open[i+1], Close[i+1]) - Low[i+1] && 
              MathMin(Open[i+1], Close[i+1]) - Low[i+1] <= MathMin(Open[MyBar2], Close[MyBar2]) - Low[MyBar2] + MyBar2_LowerShadow_Plus*Point);
    
    if (A1 && B1 && C1 && A2 && B2 && C2)
    {
      MyBar1Candles[i] = High[i] + dy;
      MyBar2Candles[i+1] = High[i+1] + dy;
    }
  }
    
  //-----
  
  int MyBar1_count = 0;
  int MyBar1_L_count = 0;
  int MyBar1_S_count = 0;
  
  for (i=MyBar1+1; i < Bars; i++)
  {
    if (MyBar1Candles[i] > 0)
    {
      MyBar1_count++;

      if (i >= 2)
      {
        if (Close[i-1] > Open[i-1]) MyBar1_L_count++;
        if (Close[i-1] < Open[i-1]) MyBar1_S_count++;
      }
    }
  }

  
  Comment(
    "\n Найдено всего: ", 
      MyBar1_count, " / UP: ", MyBar1_L_count, " / DOWN: ", MyBar1_S_count
  );
  
}

Recommend