Size of a candle histogram v2

Author: Copyright © 2019, Vladimir Karputov
Price Data Components
0 Views
0 Downloads
0 Favorites
Size of a candle histogram v2
ÿþ//+------------------------------------------------------------------+

//|                                Size of a candle histogram v2.mq5 |

//|                              Copyright © 2019, Vladimir Karputov |

//|                                           http://wmua.ru/slesar/ |

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

#property copyright "Copyright © 2019, Vladimir Karputov"

#property link      "http://wmua.ru/slesar/"

#property version   "1.000"

#property description "Size of a candle histogram v2"

//--- indicator settings

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_plots   1

#property indicator_type1   DRAW_HISTOGRAM

#property indicator_color1  clrGold

#property indicator_width1  2

//--- input parameters

input ushort   InpSizeMinimum=15;    // Candle size minimum, in points (1.00045-1.00055=10 points)

//--- indicator buffer

double   ExtBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,ExtBuffer,INDICATOR_DATA);

//--- set accuracy

   IndicatorSetInteger(INDICATOR_DIGITS,0);

//--- name for DataWindow

   string short_name="Size of a candle v2";

   IndicatorSetString(INDICATOR_SHORTNAME,short_name);

//--- sets drawing line to empty value 

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);

//---

   ArraySetAsSeries(ExtBuffer,false);

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

//| ArraySetAsSeries(time,false) =>                                  |

//|  time[0]            = D'2016.01.04 00:00:00'                     |

//|  time[rates_total-1]= D'2017.01.04 00:00:00'                     |

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

//---

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

  {

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

//| ArraySetAsSeries(time,false) =>                                  |

//|  time[0]            = D'2016.01.04 00:00:00'                     |

//|  time[rates_total-1]= D'2017.01.04 00:00:00'                     |

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

   ArraySetAsSeries(open,false);

   ArraySetAsSeries(close,false);

//---

   int limit=-1;

   if(prev_calculated==0)

      limit=0;

   else

      limit=prev_calculated-1;



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

     {

      double body=(close[i]-open[i])/Point();

      if(body>0.0)

        {

         if(body<InpSizeMinimum)

            ExtBuffer[i]=0.0;

         else

            ExtBuffer[i]=body;

        }

      else

        {

         if(-body<InpSizeMinimum)

            ExtBuffer[i]=0.0;

         else

            ExtBuffer[i]=body;

        }

     }

//--- 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 ---