Problems using StrToTime, doesn't include CurrentDay - How to refer to a specific time for the current day

 

Hi folks,

I've got a signal indi which refers to each session open, and then flashes red or green, based on whether price is below or above the session open.

Eg; trading during the Asian session, my MT4 platform time is Time[i] = 3:30 and the Tokyo Session started at 3:00.

I've got each session as an external string:

extern string   sydney   = "2:00",

              tokyo    = "3:00",

                frankfurt= "9:00",

                london   = "10:00",

                newyork  = "15:00"; 

At the moment to call up the high of the opening 5 minute bar (5m timeframe chart) and the low of the first 5m bar I'm using:

if(Time[i]>=StrToTime(tokyo) && Time[i]<StrToTime(frankfurt))    // if we're within the Asian Session 

Price>iHigh(NULL,0,iBarShift(NULL,0,StrToTime(tokyo))) // for the highest price

and

Price<iLow(NULL,0,iBarShift(NULL,0,StrToTime(tokyo))) // for the lowest price

-----

For some reason MT4 doesn't always co-operate, and uses iHigh and iLow prices that I wouldn't expect, either from the previous day's Tokyo Open 3:00 or another random time to look up the iHigh and iLow, does anyone have any suggestions where I could include StrToTime(session) and CurrentDay() (or "most recent (session)"?

Any help greatly appreciated!

Cheers,

Andrew 

 

already told you

iBarShift is wrong you have to use iHighest and iLowest

something like that: (i didn't tested it)

int Shift_Start_Tokyo = iBarShift(Symbol(), Period(), StrToTime(tokyo));
int Shift_Tokyo_Highest = iHighest(Symbol(), Period(), MODE_HIGH, Shift_Start_Tokyo);
double Price_High_Tokyo = iHigh(Symbol(), Period(), Shift_Tokyo_Highest);
 
qjol:

already told you

iBarShift is wrong you have to use iHighest and iLowest

something like that: (i didn't tested it)


Hi qjol,

I appreciate your answering my forum queries, but they haven't helped, and as you've mentioned your suggestions are untested.

You've not suggested how or where I use iHighest or iLowest, I've tried them in place of iHigh and iLow and it did not work.

 
of course i didn't fixed your code i just gave the idea, and i left something for you too
 
qjol:
of course i didn't fixed your code i just gave the idea, and i left something for you too


Hi qjol, I aks on MQL4/forum because I've exhausted all of my attempts at searching the mql4 site, I've tried all of the options; high, ihighest, iHigh etc..

I think the answer might lie in using TimeHour that I've seen in another indicator, I'll keep trying. 

 

remember, most of the time it's the code

i'll try to check it later