|
|
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
|
 |
|
|

08-23-2006, 12:20 AM
|
 |
Senior Member
|
|
Join Date: May 2006
Location: Houston
Posts: 398
|
|
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??
|

08-23-2006, 07:29 AM
|
 |
Senior Member
|
|
Join Date: Jul 2006
Location: Southern California
Posts: 160
|
|
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("");
}
|

08-23-2006, 07:56 AM
|
 |
Senior Member
|
|
Join Date: Jul 2006
Location: Southern California
Posts: 160
|
|
|
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
|

08-24-2006, 04:02 AM
|
 |
Senior Member
|
|
Join Date: May 2006
Location: Houston
Posts: 398
|
|
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.
|

08-24-2006, 04:09 AM
|
 |
Senior Member
|
|
Join Date: Jul 2006
Location: Southern California
Posts: 160
|
|
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
<><<<
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 03:36 AM.
|