title: Java : if condition : using a variable inside the if as a condition of the if
body: <p>As a beginner, I'm trying to code something like that. For sure, the wrong way, because it doesn't work at all.
  What I'm trying to do is :
  use the results i can get when I do something inside a if loop and use these results to calculate conditions the next time I enter the if...
  To be more understanable, I want to do the same thing if cond1 &amp;&amp; cond2 are TRUE but not to early even if the situation occurs (delay of 1000) and not at a value under the previous one...</p>
  <p>I don't know how to code this, for the first time I enter the if and for the others...
  Can you help me please???
  Thanks a lot.</p>
  <pre><code>boolean cond_1 = a &lt; 10;
  boolean cond_2 = b &lt; 15;
  boolean cond_delay = (time_now - time_i_have_done_something) &gt; 1000;
  boolean cond_value = value_now &gt; value_i_have_done_something;
  
  if (cond_A1 == true &amp;&amp; cond_A2 == true &amp;&amp; cond_delay == true) {
   do something;
   long time_i_have_done_something = do_something.gettime();
   double value_i_have_done_something = do_something.getvalue();
  }
  </code></pre>
  <p>Example of the logic I want to implement :</p>
  <pre><code>if (cond_A1 == true) { // firt occurence at 7 h 30 min 00 sec 000 ms
  time = gettime();
  value = getvalue();
  IOrder order = engine.submitOrder(&quot;EURUSD&quot;, instrument, orderCommand, 1); 
  }
  if (cond_A1 == true) { // second occurence at 7 h 30 min 00 sec 190 ms
  // do nothing because time between occurence#1 and occurence#2 &lt; 1000 ms  
  }
  if (cond_A1 == true) { // firt occurence at 7 h 30 min 01 sec 050 ms
  // execute this because time between occurence#1 and occurence#3 &gt; 1000 ms 
  time = gettime();
  value = getvalue();
  IOrder order = engine.submitOrder(&quot;EURUSD&quot;, instrument, orderCommand, 1); 
  }
  </code></pre>