Double size

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

//|                                                  Double size.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   "1.000"

#property indicator_chart_window

#property indicator_buffers 6

#property indicator_plots   4

//--- plot Up

#property indicator_label1  "Up"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrYellowGreen

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot High

#property indicator_label2  "High"

#property indicator_type2   DRAW_COLOR_ARROW

#property indicator_color2  clrDeepSkyBlue,clrPaleVioletRed

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- plot Low

#property indicator_label3  "Low"

#property indicator_type3   DRAW_COLOR_ARROW

#property indicator_color3  clrDeepSkyBlue,clrPaleVioletRed

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1

//--- plot Down

#property indicator_label4  "Down"

#property indicator_type4   DRAW_ARROW

#property indicator_color4  clrYellowGreen

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1

//--- input parameters

input uchar    InpUpDownArrowCode      = 174;   // Up and Down: arrow code (font Wingdings)

input uchar    InpHighLowArrowCode     = 172;   // High and Low: arrow code (font Wingdings)

//--- indicator buffers

double         UpBuffer[];

double         HighBuffer[];

double         HighColors[];

double         LowBuffer[];

double         LowColors[];

double         DownBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,UpBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,HighBuffer,INDICATOR_DATA);

   SetIndexBuffer(2,HighColors,INDICATOR_COLOR_INDEX);

   SetIndexBuffer(3,LowBuffer,INDICATOR_DATA);

   SetIndexBuffer(4,LowColors,INDICATOR_COLOR_INDEX);

   SetIndexBuffer(5,DownBuffer,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,InpUpDownArrowCode);

   PlotIndexSetInteger(1,PLOT_ARROW,InpHighLowArrowCode);

   PlotIndexSetInteger(2,PLOT_ARROW,InpHighLowArrowCode);

   PlotIndexSetInteger(3,PLOT_ARROW,InpUpDownArrowCode);

//---

   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;

//--- main loop

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

     {

      double size=0;

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

        {

         HighColors[i]=1.0;

         LowColors[i]=1.0;

         size=open[i]-close[i];

        }

      else

        {

         HighColors[i]=0.0;

         LowColors[i]=0.0;

         size=close[i]-open[i];

        }

      //---

      UpBuffer[i]=high[i]+size;

      HighBuffer[i]=high[i];

      LowBuffer[i]=low[i];

      DownBuffer[i]=low[i]-size;

     }

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