How to use Hour() function

 

Hi all,

at first I want to thanks coders' guru for his great MQL4 course!!!

I'm new in this language and after coders' guru lessons I'm tryng to develop my own indicator and surely, after it, I will try to automated its signal in a EA.

I would like the indicator to plot its signal (green and red arrows) between 7 GMT and 19 GMT...I tried this code:

int start()

{

if(Hour()>7 && Hour()<19)

{

for (int x=0;x<=Bars;x++) {

if (CheckforOpen(x)==-100)

ExtMapBufferSell[x]=High[x]+5*Point;

if (CheckforOpen(x)==100)

ExtMapBufferBuy[x]=Low[x]-5*Point;

}

}

return(0);

}

but it doesn't work...if I use && it doesn't plot anything and if I use || it plots all the signal...can you help me???

Attached my graph...I want no signal between the two vertical red line...

Thanks and Merry Chrismast

Files:
screenshot.gif  23 kb
 

Hour!

Maury74:
Hi all,

at first I want to thanks coders' guru for his great MQL4 course!!!

I'm new in this language and after coders' guru lessons I'm tryng to develop my own indicator and surely, after it, I will try to automated its signal in a EA.

I would like the indicator to plot its signal (green and red arrows) between 7 GMT and 19 GMT...I tried this code:

int start()

{

if(Hour()>7 && Hour()<19)

{

for (int x=0;x<=Bars;x++) {

if (CheckforOpen(x)==-100)

ExtMapBufferSell[x]=High[x]+5*Point;

if (CheckforOpen(x)==100)

ExtMapBufferBuy[x]=Low[x]-5*Point;

}

}

return(0);

}

but it doesn't work...if I use && it doesn't plot anything and if I use || it plots all the signal...can you help me???

Attached my graph...I want no signal between the two vertical red line...

Thanks and Merry Chrismast

Maury74,

Happy new year!

Please try this code:

int start()

{

//----

for (int x=0;x<=Bars;x++)

{

if(TimeHour(Time[x])>7 && TimeHour(Time[x])<19)

{

ExtMapBuffer[x]=High[x]+5*Point;

}

}

//----

return(0);

}
 

Now it works...thank you ver much coders' guru...you are always the best!!!!

Maury

 

You're welcome!

Maury74:
Now it works...thank you ver much coders' guru...you are always the best!!!! Maury

You're welcome Maury!

Reason: