//+------------------------------------------------------------------+ //| FirstHourHiLo.mq4 | //| GumRai | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "GumRai" #property link "http://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window //--- input parameters input int MarketOpenTime=3; input color HighLineColour= Blue; input color LowLineColour= Red; input int LineWidth=1; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { //--- for(int i=ObjectsTotal()-1;i>=0;i--) { string ObName= ObjectName(i); if(StringFind(ObName,"OpenTime")==-1 ) continue; ObjectDelete(ObName); } //--- } //+------------------------------------------------------------------+ //| 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=Bars-prev_calculated; if(limit>Bars-10) limit=Bars-10; else limit=limit+1; for(int i=limit;i>0;i--) { datetime bartime=iTime(NULL,PERIOD_H1,i); string sbartime=TimeToString(bartime,TIME_DATE||TIME_MINUTES); if( TimeHour(bartime ) ==MarketOpenTime ) { double MarketOpenTimehigh=iHigh(NULL,PERIOD_H1,i); double MarketOpenTimelow=iLow(NULL,PERIOD_H1,i); datetime bartimeplusday=bartime+(24*PERIOD_H1*60)-1; if(ObjectFind("OpenTimehigh"+sbartime)!=0) { ObjectCreate("OpenTimehigh"+sbartime,OBJ_TREND,0,bartime,MarketOpenTimehigh,bartimeplusday,MarketOpenTimehigh); ObjectSet("OpenTimehigh"+sbartime,OBJPROP_COLOR,HighLineColour); ObjectSet("OpenTimehigh"+sbartime,OBJPROP_RAY_RIGHT,false); ObjectSet("OpenTimehigh"+sbartime,OBJPROP_RAY_LEFT,false); ObjectSet("OpenTimehigh"+sbartime,OBJPROP_WIDTH,LineWidth); } if(ObjectFind("OpenTimelow"+sbartime)!=0) { ObjectCreate("OpenTimelow"+sbartime,OBJ_TREND,0,bartime,MarketOpenTimelow,bartimeplusday,MarketOpenTimelow); ObjectSet("OpenTimelow"+sbartime,OBJPROP_COLOR,LowLineColour); ObjectSet("OpenTimelow"+sbartime,OBJPROP_RAY_RIGHT,false); ObjectSet("OpenTimelow"+sbartime,OBJPROP_RAY_LEFT,false); ObjectSet("OpenTimelow"+sbartime,OBJPROP_WIDTH,LineWidth); } } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+