How can a I make this start from 05:00 hours instead of 00:00 hours

 

Hi

I have this indicator that I downloaded as freeware to show the highest and lowest prices for the day expressed in the code as the R1 and R2, there are other functions in the indicator that are not used.

The indicator starts at 00:00 hours each day, how can this be made to start at 05:00 hours instead?

Thanks

Antony

//+------------------------------------------------------------------+
//|                                                        Igrok.mq4 |
//|                                                   Andrei Andreev |
//|                                             http://www.andand.ru |
//+------------------------------------------------------------------+

// BASED ON:
//+------------------------------------------------------------------+
//|                                                   ^X_Sensors.mq4 |
//|                                                    Version 2.0.1 |
//|------------------------------------------------------------------|
//|                     Copyright © 2007, Mr.WT, Senior Linux Hacker |
//|                                     http://w-tiger.narod.ru/wk2/ |
//+------------------------------------------------------------------+
#property copyright "Andrei Andreev"
#property link      "http://www.andand.ru"

#property indicator_chart_window
extern int ForDays=1;
extern int _Shift = 10;
extern color _R_Color = Blue;
extern color _S_Color = Red;


int _N_Time,  _My_Period,  ObjectId;
string OBJECT_PREFIX = "LEVELS";
//-------------------------------------------------------------------------------------------
int init() {

_My_Period=PERIOD_D1;



_N_Time = 0;

ObjectCreate("S1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);

ObjectCreate("R1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);
ObjectCreate("R2 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);



ObjectSet("S1 line", OBJPROP_RAY, 1);
ObjectSet("S1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("S1 line", OBJPROP_COLOR, _S_Color);


ObjectSet("R1 line", OBJPROP_RAY, 1);
ObjectSet("R1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R1 line", OBJPROP_COLOR, _R_Color);

ObjectSet("R2 line", OBJPROP_RAY, 1);
ObjectSet("R2 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R2 line", OBJPROP_COLOR, _R_Color);






ObjectCreate("R1 label", OBJ_TEXT, 0, Time[0], 0);
ObjectCreate("R2 label", OBJ_TEXT, 0, Time[0], 0);

ObjectCreate("S1 label", OBJ_TEXT, 0, Time[0], 0);



ObjectId = 0;
return(0);
}
//-------------------------------------------------------------------------------------------
int deinit() {


ObjectDelete("R1 label");
ObjectDelete("R1 line");
ObjectDelete("R2 label");
ObjectDelete("R2 line");

ObjectDelete("S1 label");
ObjectDelete("S1 line");


ObDeleteObjectsByPrefix(OBJECT_PREFIX);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {

if ( _N_Time == Time[0] ) return(0);

double open,close, high, low, koeff1, koeff2,P, R1, R2, S1;
double _rates[][6];
double AverageRange;

ArrayCopyRates(_rates, NULL, _My_Period);
int err = GetLastError();
if(err == 4066) {
  Sleep(1000);
  if(iClose(NULL, _My_Period, 0) != Close[0]) {
    Sleep(1000);
    return(0);
  }
}
close = _rates[1][4];
high = _rates[0][3];
low = _rates[0][2];
open = _rates[0][1];

AverageRange=0;
for (int i=1;i<ForDays+1;i++)
    {
    AverageRange=AverageRange+(_rates[i][3]-_rates[i][2])/Point;
    }
AverageRange=NormalizeDouble(AverageRange/ForDays,0); 
int _bars = iBarShift(Symbol(),Period(),iTime(Symbol(),1440,0),false);

R1 =MathMin(
    (MathMin(iClose(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_OPEN,_bars,0)),
            iOpen(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_OPEN,_bars,0)))),
    (MathMin(iClose(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_CLOSE,_bars,0)),
            iOpen(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_CLOSE,_bars,0)))));
            
R2 =MathMax(
    (MathMax(iClose(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_OPEN,_bars,0)),
            iOpen(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_OPEN,_bars,0)))),
    (MathMax(iClose(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_CLOSE,_bars,0)),
            iOpen(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_CLOSE,_bars,0)))));


string s1,r1,r2;

  s1 = DoubleToStr(S1, Digits);

  r1 = DoubleToStr(R2-R1, Digits);
  r2 = DoubleToStr(R2-R1, Digits);


  

//---- Pivot Lines
ObjectSetText("R1 label", "                           "+r1+"", 8, "Fixedsys", _R_Color);
ObjectSetText("R2 label", "                           "+r2+"", 8, "Fixedsys", _R_Color);
ObjectSetText("S1 label", "                        Open "+s1+"", 8, "Fixedsys", _S_Color);




ObjectMove("R1 label", 0, Time[0], R1);
ObjectMove("R2 label", 0, Time[0], R2);


ObjectMove("S1 label", 0, Time[0], S1);


ObjectMove("S1 line", 0, Time[_bars], S1);
ObjectMove("S1 line", 1, Time[0], S1);




ObjectMove("R1 line", 0, Time[_bars], R1);
ObjectMove("R1 line", 1, Time[0], R1);

ObjectMove("R2 line", 0, Time[_bars], R2);
ObjectMove("R2 line", 1, Time[0], R2);


//====
   
_N_Time = Time[0];
//---- End Of Program
return(0);
}
//+------------------------------------------------------------------+



void ObDeleteObjectsByPrefix(string Prefix)
  {
   int L = StringLen(Prefix);
   int i = 0; 
   while(i < ObjectsTotal())
     {
       string ObjName = ObjectName(i);
       if(StringSubstr(ObjName, 0, L) != Prefix) 
         { 
           i++; 
           continue;
         }
       ObjectDelete(ObjName);
     }
  }
//-------------------------------------------------------------------------------------------
 

change this line:

int _bars = iBarShift(Symbol(),Period(),iTime(Symbol(),1440,0),false);

with:

int _bars = iBarShift(Symbol(),Period(),D'05:00',false);
 

Hi

Thanks for the quick reply, I have done that but when compiling the file I get this error:

"date literal string is complete"

Thanks

Antony

 

& it's not working ?

 

Hi

Sorry yes, its does work, I thought with the error it wouldn't.

Thanks for your help

Antony

 

it's not an error it's a warning EA Script or indicator doesn't have a problem to work if there is a warning

 

Hi Again

I was wondering, can this be made so that the indicator shows the highs and lows for time starting 00:00hours and then after 13:00hours it shows the highs and lows from 05:00 hours?

Thanks for the help

Antony

Reason: