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)
{
}
- You should learn to code.
- 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.
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.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.