I want to write short code

 
TimeDay(TimeCurrent())!=1&&TimeDay(TimeCurrent())!=2&&TimeDay(TimeCurrent())!=3&&TimeDay(TimeCurrent())!=4&&TimeDay(TimeCurrent())!=5

TimeDay(TimeCurrent())!=(1||2||3||4||5)

I want to write a code that does not entry date of 1, 2, 3, 4, 5, but the codes becomes long. I want to put it all together smartly, do you have any good ideas? I thought the first codes and the second codes had the same meaning, but when I started the strategy tester, they had different meanings. By the way, the first code is correct and I want to write.

 
Kosei S:

I want to write a code that does not entry date of 1, 2, 3, 4, 5, but the codes becomes long. I want to put it all together smartly, do you have any good ideas? I thought the first codes and the second codes had the same meaning, but when I started the strategy tester, they had different meanings. By the way, the first code is correct and I want to write.

if(TimeDay(TimeCurrent())<6)
{
}
 
Keith Watford #:

Thank you

But if date of 1,4,7,20,26. What shoud I do?

 
Kosei S #:

Thank you

But if date of 1,4,7,20,26. What shoud I do?

Create an array and loop through the array to check.

 
Kosei S #: But if date of What shoud I do?
  1. You should learn to code.
  2. Not complied, not tested, just typed.
    /** Linear search an _array_ for a specific _value_. @returns INDEX
     * of the first element found with _value_ or WRONG_VALUE if not found.          */
    template<typename Ti1, typename Ti2>
    int find(const Ti1& value, const Ti2& inp[], int iBeg=0, int iEnd=WHOLE_ARRAY){
       if(iEnd == WHOLE_ARRAY) iEnd = ArraySize(inp);
       while(iBeg <= --iEnd) if(inp[iEnd] == value)break;
       return iEnd;
    }
    /////////////////////////////////////////////////////////////////
    int date[]={ 1,4,7,20,26 };
    int day=TimeDay(TimeCurrent());
    if( find(day, date) >= 0) found(…);
    Not complied, not tested, just typed.
 
Kosei S #:

Thank you

But if date of 1,4,7,20,26. What shoud I do?

What do you mean by that? 1 and 4 will be caught inside the IF expression, then do whatever you had planned them to do. Then the rest of values will go thru the ELSE.

if(TimeDay(TimeCurrent()) < 6) {
        // 1 thru 5
}
else {
        // 6 and above
}

EDIT: If you don't have any special instructions for 1 thru 5, then "move" the ELSE up by asking the contrary in the IF:

if(TimeDay(TimeCurrent()) > 5) {
        // work with dates starting on the 6
}

EDIT2: By the way, you can't ask:

if(TimeDay(TimeCurrent()) != (1 || 2 || 3 || 4 || 5))

This, in plain English means "if the day in the current day is not equal to... (1 is true OR 2 is true OR 3 is true OR 4 is true OR 5 is true)". It doesn't matter what the first condition is, because all numbers inside the parenthesis are always true (they're different from zero). Actually since you have an OR "1 is true" already makes the whole expression within parenthesis true. Then you come back outside the parenthesis and you ask basically at this point...

if(TimeDay(TimeCurrent()) != true)

...and that's not gonna happen unless "TimeDay(TimeCurrent())" is zero so... it's not gonna happen.