Refer to a specified time *today* (not yesterday)

 

Hi folks,

I've made a signal indi which works (sort of!), currently for the Australian Opening Range, my code is referring to the Opening Range price of *yesterday*...

Any ideas on how to get the code below to read the OR time/price *today*?

// Opening Range combined with if...

{     
   int currentTime = Time[i];
   
//Opening Range Sydney... if it's within the Sydney to Tokyo timezone..
         
   if(Time[i]>=StrToTime(sydney) && Time[i]<StrToTime(tokyo))
{
      if(Time[i]>=StrToTime(sydney) && Time[i]<StrToTime(tokyo) && MarketInfo(NULL,MODE_ASK)>iHigh(NULL,0,iBarShift(NULL,0,StrToTime(sydney))))
      ObjectSetText("ORsignal",CharToStr(symbol),fontSize,
      "Wingdings",BuyColor); 
         
      else if(Time[i]>=StrToTime(sydney) && Time[i]<StrToTime(tokyo) && MarketInfo(NULL,MODE_BID)<iLow(NULL,0,iBarShift(NULL,0,StrToTime(sydney))))
      ObjectSetText("ORsignal",CharToStr(symbol),fontSize,
      "Wingdings",SellColor);
            
      else
      ObjectSetText("ORsignal",CharToStr(symbol),fontSize,
      "Wingdings",NeutralColor);
}
 
Time[0];
iTime(Symbol(), PERIOD_D1, 0);
TimeCurrent();
TimeHour(TimeCurrent());


pick one

https://www.mql5.com/en/forum/150098

 



Hi qjol, thanks for the reply.

I've got Time[i] referring to the current time, my problem seems to be where I've specified an opening time, for Example, Sydney = "2:00", how do I call up that Sydney time as "Sydney *today*"... my indi seems to be referring to 2:00 yesterday, even though the Time[i] is past 2:00 today.

Trying to get the indi to refer to "sydney" most recent? 

 

ho, you problem is in the logic of the code

the time in tokyo is an hour earlier from sydney

so, your if statement...

if(Time[i]>=StrToTime(sydney) && Time[i]<StrToTime(tokyo))

is always false

 
qjol:

ho, you problem is in the logic of the code

the time in tokyo is an hour earlier from sydney

so, your if statement...

is always false


I've got the session times as external inputs:

extern string  sydney   = "2:00",              

tokyo    = "3:00",

                frankfurt= "9:00",

                london   = "10:00",

                newyork  = "15:00"; 

 

So when Time[i] is 2:30 for example, it's true? 

 

as you wish

if(TimeCurrent()>=StrToTime(sydney) && TimeCurrent()<StrToTime(tokyo))

or maybe

if(TimeLocal()>=StrToTime(sydney) && TimeLocal()<StrToTime(tokyo))
 

thanks qjol, I'll swtich Time[i] for TimeCurrent() and see how the indi performs today.

Thanks again for your help eh, a second or third time you've helped me out on mql4 forum. 

 
qjol:

as you wish

or maybe



Hi qjol,

It appears that the problem is in calling up:

iHigh(NULL,0,iBarShift(NULL,0,StrToTime(frankfurt)))

The price (frankfurt) is calling up yesterday's 9:00, not today's 9:00.

I'm wondering if there's a way for iBarShift to only look for "frankfurt" within the previous 8 hours or for it to look for the most "recent" occurrence of 9:00? 

 
 
qjol:


iHighest


I've started this thread fresh here https://forum.mql4.com/63521 qjol if you're still keen, just to iron out my problem exactly.
Reason: