View Single Post
  #2 (permalink)  
Old 08-23-2006, 07:29 AM
cubesteak's Avatar
cubesteak cubesteak is offline
Senior Member
 
Join Date: Jul 2006
Location: Southern California
Posts: 163
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("");
}
Reply With Quote