ADR_MakarFX

Author: Copyright 2020, Martingeil
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
0 Views
0 Downloads
0 Favorites
ADR_MakarFX
ÿþ//+------------------------------------------------------------------+

//|                                                  ADR_MakarFX.mq4 |

//|                                       Copyright 2020, Martingeil |

//|                                             https://www.mql5.com |

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

#property copyright "Copyright 2020, Martingeil"

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict // 70:><5=B8@C9B5 MBC AB@>:C B>340 =5 1C4CB 2KE>48BL ?@54C?@5645=8O ?@8 :><?8;OF88

#property indicator_chart_window  

//---- input parameters

input int   CountDays  = 1;       // 8AB>@8O 4=59, 1-B5:CI89 45=L

input color col_R1     = clrRed;

input color col_S1     = clrBlue;

input int   style      = 0; // AB8;L ;8=89

input int   widh       = 2; // B>;I8=0 ;8=89

input bool  FillBack   = false;   // 0;820BL >1J5:BK

//---- 

int shift;

datetime ny_time[];

datetime time1;

datetime time2;

double high_,high1,high2,high3,high4,high5;

double low_,low1,low2,low3,low4,low5;

double range;

double R1,R2,S1,S2;

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   

//---

   return(INIT_SUCCEEDED);

  }

int deinit(){ObjDel(); Comment(""); return(0);}  

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

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

  {

//---

  ObjDel();

  for (shift=0;shift<=CountDays-1;shift++)

  {

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

  time1  = iTime(NULL,PERIOD_D1,shift);  

  time2  = time1 + 24*3600+Period(); 

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

  high1  = iHigh(NULL,PERIOD_D1,shift+1);  high2  = iHigh(NULL,PERIOD_D1,shift+2);

  high3  = iHigh(NULL,PERIOD_D1,shift+3);  high4  = iHigh(NULL,PERIOD_D1,shift+4);

  high5  = iHigh(NULL,PERIOD_D1,shift+5);

  

  low1   = iLow(NULL,PERIOD_D1,shift+1);   low2   = iLow(NULL,PERIOD_D1,shift+2);

  low3   = iLow(NULL,PERIOD_D1,shift+3);   low4   = iLow(NULL,PERIOD_D1,shift+4);

  low5   = iLow(NULL,PERIOD_D1,shift+5);

  

  range  = ((high1-low1)+(high2-low2)+(high3-low3)+(high4-low4)+(high5-low5))/5.0;

  

  high_   = iHigh(NULL,PERIOD_D1,shift);    low_    = iLow(NULL,PERIOD_D1,shift);

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

  R1 = low_;

  R2 = R1+range;

  

  S1 = high_;

  S2 = S1-range;

 

  PlotLine("R1_Makar["+shift+"]",R1,R2,col_R1);

  PlotLine("S1_Makar["+shift+"]",S1,S2,col_S1);

  }

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

   return(rates_total);

  }

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

void ObjDel()

{

   if (ObjectsTotal() > 0)

   for (int num=0;num<=CountDays;num++)

   {

   ObjectDelete("R1_Makar["+num+"]");

   ObjectDelete("S1_Makar["+num+"]");

   }     

}

// ----

void PlotLine(string name,double value1,double value2,color colr)

{

   bool res = ObjectCreate(name,OBJ_RECTANGLE,0,time1,value1,time2,value2);

   ObjectSet(name, OBJPROP_WIDTH, widh);

   ObjectSet(name, OBJPROP_STYLE, style);

   ObjectSet(name, OBJPROP_BACK, FillBack);

   ObjectSet(name, OBJPROP_COLOR, colr);

}

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