//https://forex-station.com/viewtopic.php?f=579496&t=8472953&hilit=Intraday+channel+breakout&start=10 //------------------------------------------------------------------ #property copyright "© Mladen, 2018" #property link "mladenfx@gmail.com" #property version "1.00" //------------------------------------------------------------------ #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 C'0,55,0' #property indicator_color2 C'55,0,0' #property indicator_color3 C'0,89,0' #property indicator_color4 C'89,0,0' #property indicator_color5 clrAqua #property indicator_color6 clrMagenta //#property indicator_style3 STYLE_SOLID //#property indicator_style4 STYLE_SOLID #property indicator_width5 3 #property indicator_width6 3 #property strict //--- // input string inpStartTime = "7:00"; // Start time input string inpEndTime = "8:30"; // Ending time input bool ShowBars = true; // Show Breakout bars? // //--- // double fillu[],filld[],limu[],limd[],histou[],histod[],histoc[]; //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int OnInit() { IndicatorBuffers(7); SetIndexBuffer(0,fillu); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(1,filld); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(2,limu); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(3,limd); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(4,histou);SetIndexStyle(4,ShowBars ? DRAW_HISTOGRAM : DRAW_NONE); SetIndexBuffer(5,histod);SetIndexStyle(5,ShowBars ? DRAW_HISTOGRAM : DRAW_NONE); SetIndexBuffer(6,histoc); // //--- // if (_Period>=PERIOD_D1) { Alert("Indicator can work on time frames less than daily only"); return(INIT_FAILED); } IndicatorShortName("Channel "+inpStartTime+" "+inpEndTime+" breakout"); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // 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 i,counted_bars = prev_calculated; if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit=MathMin(rates_total-counted_bars,rates_total-1); // // // // // int _secondsStart = (int)StringToTime("1970.01.01 "+inpStartTime); int _secondsEnd = (int)StringToTime("1970.01.01 "+inpEndTime); for (i=limit;i>=0; i--) { datetime _startTime = StringToTime(TimeToString(Time[i],TIME_DATE))+_secondsStart; datetime _endTime = StringToTime(TimeToString(Time[i],TIME_DATE))+_secondsEnd; double max = ((i=Time[i]) { max = High[i]; min = Low[i]; for (int k=1; i+k=_startTime; k++) { max = fmax(max,High[i+k]); min = fmin(min,Low[i+k]); } } limu[i] = max; limd[i] = min; if (_startTime<=Time[i] && _endTime>=Time[i]) { fillu[i] = max; filld[i] = min; histou[i] = EMPTY_VALUE; histod[i] = EMPTY_VALUE; } else { fillu[i] = (limu[i]+limd[i])*0.5; filld[i] = (limu[i]+limd[i])*0.5; histoc[i] = (ilimu[i]) ? 1 : (Close[i]limd[i]) ? 0 : histoc[i+1] : 0; if (histoc[i] == 1) { histou[i] = High[i]; histod[i] = Low[i]; } if (histoc[i] ==-1) { histod[i] = High[i]; histou[i] = Low[i]; } } } return(rates_total); }