Bar Rule Arrow

Author: Copyright © 2021, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
Bar Rule Arrow
ÿþ//+------------------------------------------------------------------+

//|                                               Bar Rule Arrow.mq5 |

//|                              Copyright © 2021, Vladimir Karputov |

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

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

#property copyright "Copyright © 2021, Vladimir Karputov"

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

#property version   "1.000"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot Rule_1

#property indicator_label1  "Rule 1"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrDodgerBlue

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot Rule_2

#property indicator_label2  "Rule 2"

#property indicator_type2   DRAW_ARROW

#property indicator_color2  clrTomato

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- input parameters

input group             "Arrows"

input uchar                InpRule_1ArrowCode         = 71;          // Arrow 'Rule 1': code (font Wingdings)

input int                  InpRule_1ArrowShift        = 10;          // Arrow 'Rule 1': vertical shift in pixel

input uchar                InpRule_2ArrowCode         = 72;          // Arrow 'Rule 2': code (font Wingdings)

input int                  InpRule_2ArrowShift        = 10;          // Arrow 'Rule 2': vertical shift in pixel

//--- indicator buffers

double   Rule_1Buffer[];

double   Rule_2Buffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,Rule_1Buffer,INDICATOR_DATA);

   SetIndexBuffer(1,Rule_2Buffer,INDICATOR_DATA);

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

   PlotIndexSetInteger(0,PLOT_ARROW,InpRule_1ArrowCode);

   PlotIndexSetInteger(1,PLOT_ARROW,InpRule_2ArrowCode);

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

   PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-InpRule_1ArrowShift);

   PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,InpRule_2ArrowShift);

//--- an empty value for plotting, for which there is no drawing

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

  {

//---

   if(rates_total<2)

      return(0);

//---

   int limit=prev_calculated-1;

   if(prev_calculated==0)

     {

      Rule_1Buffer[0]=0.0;

      Rule_2Buffer[0]=0.0;

      limit=1;

     }

//--- main loop

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

     {

      Rule_1Buffer[i]=0.0;

      Rule_2Buffer[i]=0.0;

      //--- Rule 1

      if(high[i-1]<high[i])

         if(close[i]<(low[i]+(high[i]-low[i])/3.0))

            Rule_1Buffer[i]=high[i];

      //--- Rule 2 low =865, G5< C ?@54K4CI53> 10@0, 0 close 2 25@E=59 B@5B8.

      if(low[i-1]>low[i])

         if(close[i]>(high[i]-(high[i]-low[i])/3.0))

            Rule_2Buffer[i]=low[i];

     }

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