Bunch Candle

Author: Copyright © 2022, Vladimir Karputov
2 Views
0 Downloads
0 Favorites
Bunch Candle
ÿþ//+------------------------------------------------------------------+

//|                                                 Bunch Candle.mq5 |

//|                              Copyright © 2022, Vladimir Karputov |

//|                      https://www.mql5.com/en/users/barabashkakvn |

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

#property copyright "Copyright © 2022, Vladimir Karputov"

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

#property version   "1.00"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot Bunch Bull

#property indicator_label1  "Bunch Bull"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrLimeGreen

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot Bear

#property indicator_label2  "Bunch Bear"

#property indicator_type2   DRAW_ARROW

#property indicator_color2  clrLavender

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- input parameters

//--- indicator buffers

double   BunchBullBuffer[];

double   BunchBearBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,BunchBullBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,BunchBearBuffer,INDICATOR_DATA);

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

   PlotIndexSetInteger(0,PLOT_ARROW,159);

   PlotIndexSetInteger(1,PLOT_ARROW,159);

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

   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,0);

   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,0);

//--- Set as an empty value 0

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);

   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);

//---

   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[])

  {

//---

   int limit=prev_calculated-1;

   if(prev_calculated==0)

      limit=0;

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

     {

      BunchBullBuffer[i]=0.0;

      BunchBearBuffer[i]=0.0;

      double candle_size=high[i]-low[i];

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

        {

         double bode_size=close[i]-open[i];

         if(bode_size<0.5*candle_size)

            BunchBullBuffer[i]=(close[i]+open[i])/2.0;

        }

      else

        {

         double bode_size=open[i]-close[i];

         if(bode_size<0.5*candle_size)

            BunchBearBuffer[i]=(close[i]+open[i])/2.0;

        }

     }

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

   return(rates_total);

  }

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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---