law_of_repetition_s7

Author: © 2009 Stigal
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
law_of_repetition_s7
ÿþ//+------------------------------------------------------------------+

//|                           edited from      law_of_repetition.mq4 |

//|                                                           Stigal |

//| Editor: sova75'2017                                              |

//+------------------------------------------------------------------+

#property copyright "© 2009 Stigal"

#property link "https://www.mql5.com/en/users/timstigal"

#property version "1.00"

#property description "Law of Repetition."

#property description "Indicator based on the law Repetition, indicating a similar spark in the past on the schedule, highlighted their red dot."

#property strict

//---

#define major   1

#define minor   0

//---

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Red

#property indicator_width1  1

//---

extern int MyBar=0; // My Bar (number of bar with which to compare the schedule from the end)

extern int Body_Plus=70; // Body Plus (indicate an upper limit of the range of items)

extern int Body_Minus=70; // Body Minus (indicate an bottom limit of the range of items)

extern int UpperShadow_Plus=30; // Upper Shadow Plus (indicate an upper limit of the range of items)

extern int UpperShadow_Minus=30; // Upper ShadowMinus (indicate an bottom limit of the range of items)

extern int LowerShadow_Plus=30; // Lower Shadow Plus (indicate an upper limit of the range of items)

extern int LowerShadow_Minus=30; // Lower Shadow Minus (indicate an bottom limit of the range of items)

//---

double candles[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

   Comment("");

   SetIndexBuffer(0,candles);

   SetIndexEmptyValue(0,0.0);

   SetIndexStyle(0,DRAW_ARROW);

   SetIndexArrow(0,108);

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function                       |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

   Comment("");

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate (const int rates_total,      // Size of input timeseries

                 const int prev_calculated,  // Processed bars on the previous call

                 const datetime &time[],     // Time 

                 const double &open[],       // Open 

                 const double &high[],       // High 

                 const double &low[],        // Low 

                 const double &close[],      // Close 

                 const long &tick_volume[],  // Tick Volume 

                 const long &volume[],       // Real Volume 

                 const int &spread[])        // Spread 

  {

   int counted=IndicatorCounted();

   if(counted < 0) return (-1);

   if(counted>0) counted--;

//---

   int limit=Bars-counted;

//---

   double dy= 0;

   for(int i=1; i<= 20; i++)

     {

      dy+=0.3*(High[i]-Low[i])/20;

     }

//---

   for(int i=MyBar; i<limit; i++)

     {

      candles[i]=0.0;



      if(Open[MyBar]>Close[MyBar])

        {

         if(Open[i]<=Close[i]) continue;

        }



      if(Open[MyBar]<Close[MyBar])

        {

         if(Open[i]>=Close[i]) continue;

        }



      if(Open[MyBar]==Close[MyBar])

        {

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

        }



      //-----



      bool A=(MathAbs(Open[MyBar]-Close[MyBar])-Body_Minus*Point<=MathAbs(Open[i]-Close[i]) && 

              MathAbs(Open[i]-Close[i])<=MathAbs(Open[MyBar]-Close[MyBar])+Body_Plus*Point);



      bool B=(High[MyBar]-MathMax(Open[MyBar],Close[MyBar])-UpperShadow_Minus*Point<=High[i]-MathMax(Open[i],Close[i]) && 

              High[i]-MathMax(Open[i],Close[i])<=High[MyBar]-MathMax(Open[MyBar],Close[MyBar])+UpperShadow_Plus*Point);



      bool C=(MathMin(Open[MyBar],Close[MyBar])-Low[MyBar]-LowerShadow_Minus*Point<=MathMin(Open[i],Close[i])-Low[i] && 

              MathMin(Open[i],Close[i])-Low[i]<=MathMin(Open[MyBar],Close[MyBar])-Low[MyBar]+LowerShadow_Plus*Point);



      if(A && B && C)

        {

         candles[i]=High[i]+dy;

        }

     }

//---

   int count=0;

   for(int i=0; i<Bars; i++)

     {

      if(candles[i]>0) count++;

     }

//---

   Comment("\n Total found: ",count);

   return(0);

  }

//+------------------------------------------------------------------+

Comments