Bull Bear Dot

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

//|                                                Bull Bear Dot.mq5 |

//|                              Copyright © 2020, Vladimir Karputov |

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

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

#property copyright "Copyright © 2020, Vladimir Karputov"

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

#property version   "1.003"

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_plots   2

//--- plot Middle Dot"

#property indicator_label1  "Middle Dot"

#property indicator_type1   DRAW_COLOR_ARROW

#property indicator_color1  clrDeepSkyBlue,clrTomato

#property indicator_style1  STYLE_SOLID

#property indicator_width1  5

//--- plot Middle Line"

#property indicator_label2  "Middle Line"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrGold

#property indicator_style2  STYLE_SOLID

#property indicator_width2  2

//--- input parameters

input group             "Arrow"

input uchar    InpCode     = 159;   // Arrow code for style DRAW_ARROW (font Wingdings)

//--- indicator buffers

double   MiddleDotBuffer[];

double   MiddleDotColor[];

double   MiddleLineBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,MiddleDotBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,MiddleDotColor,INDICATOR_COLOR_INDEX);

   SetIndexBuffer(2,MiddleLineBuffer,INDICATOR_DATA);

//--- set accuracy

   IndicatorSetInteger(INDICATOR_DIGITS,Digits());

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

   PlotIndexSetInteger(0,PLOT_ARROW,InpCode);

//---

   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++)

     {

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

      MiddleLineBuffer[i]=MiddleDotBuffer[i];

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

         MiddleDotColor[i]=0.0;

      else

         MiddleDotColor[i]=1.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 ---