//+------------------------------------------------------------------+ //| Week HiLo.mq4 | //| GumRai | //| none | //+------------------------------------------------------------------+ #property copyright "GumRai" #property link "none" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot WeekHigh #property indicator_label1 "WeekHigh" #property indicator_type1 DRAW_LINE #property indicator_color1 clrDodgerBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot WeekLow #property indicator_label2 "WeekLow" #property indicator_type2 DRAW_LINE #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- input parameters //--- indicator buffers double WeekHighBuffer[]; double WeekLowBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,WeekHighBuffer); SetIndexBuffer(1,WeekLowBuffer); //--- 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(Period()>PERIOD_D1) return(0); int limit; if(prev_calculated==0) limit=rates_total-2; else limit=1; for(int index=limit;index>=0;index--) { //if(TimeDayOfWeek(Time[index+1])>=5 && TimeDayOfWeek(Time[index])<5) if(TimeDayOfWeek(Time[index+1])>TimeDayOfWeek(Time[index])) { WeekHighBuffer[index]=High[index]; WeekLowBuffer[index]=Low[index]; } else { if(High[index]>WeekHighBuffer[index+1]) WeekHighBuffer[index]=High[index]; else WeekHighBuffer[index]=WeekHighBuffer[index+1]; if(Low[index]