Download MetaTrader 5
To add comments, please log in or register
Write articles and earn money. We pay 200 USD for them!
Andrew
71
Andrew 2014.06.12 00:02 

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);
}
qjol
3243
qjol 2014.06.12 00:36  
Time[0];
iTime(Symbol(), PERIOD_D1, 0);
TimeCurrent();
TimeHour(TimeCurrent());


pick one

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

Andrew
71
Andrew 2014.06.12 01:56  



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? 

qjol
3243
qjol 2014.06.12 02:18  

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

Andrew
71
Andrew 2014.06.12 03:02  
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? 

qjol
3243
qjol 2014.06.12 03:32  

as you wish

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

or maybe

if(TimeLocal()>=StrToTime(sydney) && TimeLocal()<StrToTime(tokyo))
Andrew
71
Andrew 2014.06.12 04:27  

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. 

Andrew
71
Andrew 2014.06.12 06:22  
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
3243
qjol 2014.06.12 06:57  
Andrew
71
Andrew 2014.06.12 07:42  
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.
/
To add comments, please log in or register