Channel three prices

Author: Copyright © 2021, Vladimir Karputov
Price Data Components
0 Views
0 Downloads
0 Favorites
Channel three prices
ÿþ//+------------------------------------------------------------------+

//|                                         Channel three prices.mq5 |

//|                              Copyright © 2021, Vladimir Karputov |

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

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

#property copyright "Copyright © 2021, Vladimir Karputov"

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

#property version   "1.000"

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_plots   3

//--- plot Ceiling

#property indicator_label1  "Ceiling"

#property indicator_type1   DRAW_LINE

#property indicator_color1  clrRed

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot Middle

#property indicator_label2  "Middle"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrSpringGreen

#property indicator_style2  STYLE_DASHDOT

#property indicator_width2  1

//--- plot Floor

#property indicator_label3  "Floor"

#property indicator_type3   DRAW_LINE

#property indicator_color3  clrBlue

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1

//--- indicator buffers

double   CeilingBuffer[];

double   MiddleBuffer[];

double   FloorBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,CeilingBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,MiddleBuffer,INDICATOR_DATA);

   SetIndexBuffer(2,FloorBuffer,INDICATOR_DATA);

//--- set accuracy

   IndicatorSetInteger(INDICATOR_DIGITS,Digits());

//---

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

     {

      CeilingBuffer[i]=high[i];

      MiddleBuffer[i]=(high[i]+low[i])/2.0;

      FloorBuffer[i]=low[i];

     }

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

   return(rates_total);

  }

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

Comments