Quick confirmation

 

Are these two testings equivalent from the programming logic point of view?


1)

if( RAIN2>RAIN1 && RAIN3>RAIN2 && RAIN4>RAIN3 && RAIN5>RAIN4 && RAIN6>RAIN5 && RAIN7>RAIN6 && RAIN8>RAIN7 && RAIN9>RAIN8 )
if(!( RAINX2>RAINX1 && RAINX3>RAINX2 && RAINX4>RAINX3 && RAINX5>RAINX4 && RAINX6>RAINX5 && RAINX7>RAINX6 && RAINX8>RAINX7 && RAINX9>RAINX8 ))
Buy=true;


2)

if(RAIN2>RAIN1 || !RAINX2>RAINX1 )
if(RAIN3>RAIN2 || !RAINX3>RAINX2 )
if(RAIN4>RAIN3 || !RAINX4>RAINX3 )
if(RAIN5>RAIN4 || !RAINX5>RAINX4 )
if(RAIN6>RAIN5 || !RAINX6>RAINX5 )
if(RAIN7>RAIN6 || !RAINX7>RAINX6 )
if(RAIN8>RAIN7 || !RAINX8>RAINX7 )
if(RAIN9>RAIN8 || !RAINX9>RAINX8 )
Buy=true;

If not then how to make the second one equivalent to the first one by grouping each respective test from the first two ifs into separate ifs with 2 arguments

 
Proximus:

Are these two testings equivalent from the programming logic point of view?


1)


2)

If not then how to make the second one equivalent to the first one by grouping each respective test from the first two ifs into separate ifs with 2 arguments


Obviously not. Why do you need to write that in another way, your conditions in 1) are logically correct.
 
angevoyageur:
Obviously not. Why do you need to write that in another way, your conditions in 1) are logically correct.
I want to put them in separate ifs, grouping them respectively with their negated pair if possible, for backtesting quickly and its easier to modify them if they show bad results.
 
Proximus:
I want to put them in separate ifs, grouping them respectively with their negated pair if possible, for backtesting quickly and its easier to modify them if they show bad results.
Good luck.
 
Proximus:

Are these two testings equivalent from the programming logic point of view?

1)

2)

If not then how to make the second one equivalent to the first one by grouping each respective test from the first two ifs into separate ifs with 2 arguments

You may find it useful to group the data into a usable collection, such as an array. Then it becomes a little easier working with the data. See, for example, the following code:

int RAIN[9] = {1,2,3,4,5,6,7,8,9}, RAINX[9] = {49,48,47,46,45,44,43,42,41};
bool buy = true;
for (int i = 1; i < 9; i++) {
   if (RAIN[i] > RAIN[i-1] && !(RAINX[i] > RAINX[i-1]))
      continue;
   else {
      buy = false;
      break;
   }
}
if (buy)
   Print ("BUY!");
else
   Print ("Do Not Buy!");   
 
Thirteen:

You may find it useful to group the data into a usable collection, such as an array. Then it becomes a little easier working with the data. See, for example, the following code:


hMM that looks very useful ty
Reason: