Follow us on
Forgot your password?
Forex Forum Register More recent Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 08-23-2006, 12:20 AM
iscuba11's Avatar
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 398
iscuba11 is on a distinguished road
Question Can anyone figure out why this will not work right??

if (UseHourTrade)

{

if(!(Hour()>=FromHourTrade1 && Hour()<=ToHourTrade1)) a=1;

if(!(Hour()>=FromHourTrade2 && Hour()<=ToHourTrade2)) b=1;

if(!(Hour()>=FromHourTrade3 && Hour()<=ToHourTrade3)) c=1;

if(a==1 || b==1 || c==1)

{

Comment(
"\n"," * SOLAR WIND EXPERT ADVISOR *",
"\n",
"\n", " - PROGRAM IN SLEEP CYCLE - ",
"\n",
"\n"," > NON-TRADING HOURS! <");

return(0);
}
}

It compiles ok, but even if the program is active during one of the sessions, it displays the PROGRAM IN SLEEP message. I do not know what to do to correct this??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!Share this post on Twitter!
Reply With Quote
  #2 (permalink)  
Old 08-23-2006, 07:29 AM
cubesteak's Avatar
Senior Member
 
Join Date: Jul 2006
Location: Southern California
Posts: 160
cubesteak is on a distinguished road
Talking Try this...

Hello,

I've seen MT4 be really funky in how it reads multiple if conditions, with !'s in there, etc. So, give this a try. I basically changed the logic to "positive" logic and spread out the If's a bit to make sure they are really ballanced. You also needed to zero out the comment when your conditions aren't met, else it stays there.

HAHA! It could be as simple as your original logic works, but the comment just needed to be zeroed out when the condition wasn't met.

Anyway, I also removed the "return (0)" since its not a function, so you don't need to "return" anything... Its probably left over from the rest of your code, so you'll probably need to add it back in.


Seems to work fine for me now.

If any of the hours inclusive of the range in the From and To variables are met, there is no comment.

Outside of those hours, the comment is there.

I'm assuming that's what you wanted?

Cheers,
Cubesteak



Code:
if (UseHourTrade)
{
   int now = Hour();
   if (

         ( (now>=FromHourTrade1) ) &&
         ( (now<=ToHourTrade1) )
         
      ) a=1;

   
   if (

         ( (now>=FromHourTrade2) ) &&
         ( (now<=ToHourTrade2) )
         
      ) b=1;


   if (

         ( (now>=FromHourTrade3) ) &&
         ( (now<=ToHourTrade3) )
         
      ) c=1;

   if (
         (a!=1) &&
         (b!=1) &&
         (c!=1)
      )
   {
   Comment(
   "\n"," * SOLAR WIND EXPERT ADVISOR *",
   "\n",
   "\n", " - PROGRAM IN SLEEP CYCLE - ",
   "\n",
   "\n"," > NON-TRADING HOURS! <");
   }
   else Comment("");
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!Share this post on Twitter!
Reply With Quote
  #3 (permalink)  
Old 08-23-2006, 07:56 AM
cubesteak's Avatar
Senior Member
 
Join Date: Jul 2006
Location: Southern California
Posts: 160
cubesteak is on a distinguished road
Some more goodies...

I've been meaning to make something like this for quite some time, and your question gave me the impetus.

Here's an indicator based on the above code. Hours can be set in the code, or by the indicator settings window.

I tried to make one that would use a separate window, but I forgot that comments only work on the main charts.

If people are interested in that, I can make one that uses objects, rather than comments.



Enjoy!

-Cubesteak
Attached Files
File Type: mq4 3FoldTradingHours.mq4 (2.7 KB, 32 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!Share this post on Twitter!
Reply With Quote
  #4 (permalink)  
Old 08-24-2006, 04:02 AM
iscuba11's Avatar
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 398
iscuba11 is on a distinguished road
Smile A Friend coded this for me - Works great!!!

if (UseHourTrade)

{
int a=0;
int b=0;
int c=0;

if(!(Hour()>=FromHourTrade1 && Hour()<=ToHourTrade1)) a=1;

if(!(Hour()>=FromHourTrade2 && Hour()<=ToHourTrade2)) b=1;

if(!(Hour()>=FromHourTrade3 && Hour()<=ToHourTrade3)) c=1;

if(a==1 && b==1 && c==1)

{

Comment(
"\n"," * SOLAR WIND EXPERT ADVISOR *",
"\n",
"\n", " - PROGRAM IN SLEEP CYCLE - ",
"\n",
"\n"," > NON-TRADING HOURS! <");

return(0);
}
}

Note: Unfortunately, the solarwind indicator is useless to write an EA from - It repaints itself! All indicators that have ++ used in the logic loop are virtually useless to try to write an EA for, because they all repaint themselves and that messes up the EA timing and optimization. They may be ok visually, but they don't work well in an EA. Most indicators do repaint themselves. You must use an indicator that has -- in the logic loop, and even then other conditions can mess up a EA. This is why so many EA's end up not working!!!

Dave
<><<<

Last edited by iscuba11; 08-24-2006 at 04:08 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!Share this post on Twitter!
Reply With Quote
  #5 (permalink)  
Old 08-24-2006, 04:09 AM
cubesteak's Avatar
Senior Member
 
Join Date: Jul 2006
Location: Southern California
Posts: 160
cubesteak is on a distinguished road
Hmm.. You'll still need to do the Comment (""); or else the comment will never go away, unless you've reset it somewhere else.


Quote:
Originally Posted by iscuba11
if (UseHourTrade)

{
int a=0;
int b=0;
int c=0;

if(!(Hour()>=FromHourTrade1 && Hour()<=ToHourTrade1)) a=1;

if(!(Hour()>=FromHourTrade2 && Hour()<=ToHourTrade2)) b=1;

if(!(Hour()>=FromHourTrade3 && Hour()<=ToHourTrade3)) c=1;

if(a==1 && b==1 && c==1)

{

Comment(
"\n"," * SOLAR WIND EXPERT ADVISOR *",
"\n",
"\n", " - PROGRAM IN SLEEP CYCLE - ",
"\n",
"\n"," > NON-TRADING HOURS! <");

return(0);
}
}

Note: Unfortunately, the solarwind indicator is useless to write an EA from - It repaints itself! All indicators that have ++ used in the logic loop are virtually useless to try to write an EA for, because they all repaint themselves and that messes up the EA timing and optimization. They may be ok visually, but they don't work well in an EA. Most indicators do repaint themselves. You must use an indicator that has -- in the logic loop, and even then other conditions can mess up a EA. This is why so many EA's end up not working!!!

Dave
<><<<
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!Share this post on Twitter!
Reply With Quote
Reply

Bookmarks

Tags
Point and Figure


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Point and Figure Charting for MT4 omrangassan Indicators - Metatrader 4 66 08-14-2010 01:23 PM
Point & Figure charts Marbo Indicators - Metatrader 4 1 02-14-2007 11:06 AM
Figure it out jarcrocker Expert Advisors - Metatrader 4 1 01-24-2007 02:24 PM
Point and Figure charts hua Metatrader 4 2 04-03-2006 04:51 PM


All times are GMT. The time now is 03:36 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.