|
|||||||
| 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 | Display Modes |
|
||||
|
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("");
}
|
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
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:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Point and Figure Charting for MT4 | omrangassan | Indicators - Metatrader 4 | 25 | 05-30-2008 07:46 AM |
| 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 |