Dual Candlestick 2

Author: Copyright © 2020, Vladimir Karputov
Price Data Components
0 Views
0 Downloads
0 Favorites
Dual Candlestick 2
ÿþ//+------------------------------------------------------------------+

//|                                           Dual Candlestick 2.mq5 |

//|                              Copyright © 2020, Vladimir Karputov |

//|                     https://www.mql5.com/ru/market/product/43516 |

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

#property copyright "Copyright © 2020, Vladimir Karputov"

#property link      "https://www.mql5.com/ru/market/product/43516"

#property version   "2.000"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot BearishHarami

#property indicator_label1  "Sell Signal"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrRed

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot BullishHarami

#property indicator_label2  "Buy Signal"

#property indicator_type2   DRAW_ARROW

#property indicator_color2  clrBlue

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- input parameters

input uchar    InputSellCode  = 248;         // Arrow code for Sell Signal (font Wingdings)

input uchar    InputBuyCode   = 246;         // Arrow code for Buy Signal (font Wingdings)

input char     InpShift       = 10;          // Vertical shift of arrows in pixels

input ushort   InpTolerance   = 6;           // Tolerance, in points (1.00045-1.00055=10 points)

//--- indicator buffers

double   SellSignalBuffer[];

double   BuySignalBuffer[];

//---

double   m_tolerance          = 0.0;         // Tolerance -> double

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,SellSignalBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,BuySignalBuffer,INDICATOR_DATA);

//--- setting a code from the Wingdings charset as the property of PLOT_ARROW

   PlotIndexSetInteger(0,PLOT_ARROW,InputSellCode);

   PlotIndexSetInteger(1,PLOT_ARROW,InputBuyCode);

//--- set the vertical shift of arrows in pixels

   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,InpShift);

   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,-InpShift);

//--- set as an empty value 0

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);

   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);

//---

   m_tolerance=InpTolerance*Point();

//---

   return(INIT_SUCCEEDED);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

//---

   if(rates_total<9)

      return(0);

   int limit=prev_calculated-1;

   if(prev_calculated==0)

     {

      SellSignalBuffer[0]=0.0;

      BuySignalBuffer[0]=0.0;

      limit=1;

     }

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

     {

      SellSignalBuffer[i-1]=0.0;

      BuySignalBuffer[i-1]=0.0;

      SellSignalBuffer[i]=0.0;

      BuySignalBuffer[i]=0.0;



      if((high[i]-high[i-1]<=m_tolerance) && (low[i-1]-low[i]<=m_tolerance))

        {

         if(open[i-1]<close[i-1])

            BuySignalBuffer[i-1]=high[i-1];

         else

            if(open[i-1]>close[i-1])

               SellSignalBuffer[i-1]=low[i-1];

        }

     }

//--- return value of prev_calculated for next call

   return(rates_total);

  }

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

Comments