Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions
Forex Forum FAQ Members List Calendar Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

 
 
LinkBack Thread Tools
 
Old 12-24-2005, 11:16 AM
Maury74's Avatar
Maury74 Maury74 is offline
Member
 
Join Date: Dec 2005
Posts: 46
Maury74 is on a distinguished road
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
Attached Images
File Type: gif screenshot.gif (22.7 KB, 125 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 12-24-2005, 08:59 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Hour!

Quote:
Originally Posted by 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:

PHP Code:
int start()
  {
//---- 

         
for (int x=0;x<=Bars;x++) 
         {
            if(
TimeHour(Time[x])>&& TimeHour(Time[x])<19)
            {
               
ExtMapBuffer[x]=High[x]+5*Point;
            
            }
         }
 
//----
   
return(0);
  } 
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 12-28-2005, 08:07 AM
Maury74's Avatar
Maury74 Maury74 is offline
Member
 
Join Date: Dec 2005
Posts: 46
Maury74 is on a distinguished road
Now it works...thank you ver much coders' guru...you are always the best!!!!

Maury
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 12-28-2005, 01:35 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Talking You're welcome!

Quote:
Originally Posted by Maury74
Now it works...thank you ver much coders' guru...you are always the best!!!!

Maury
You're welcome Maury!
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Market hour svirgo Metatrader 4 2 05-14-2007 05:48 AM
Hour buy and sell EA jyrik Expert Advisors - Metatrader 4 0 12-12-2006 02:40 PM
How to add hour to hour trade on an ea? jyrik Expert Advisors - Metatrader 4 6 08-05-2006 01:46 PM
4 hour data fxdk Metatrader 4 2 05-02-2006 02:22 PM


All times are GMT. The time now is 02:23 PM.