title: MQL4 "undeclared identifier" - how can I fix this issue?
body: <p>I'm currently trying to learn a programming language called <strong><code>MQL4</code></strong>, which is used to write trading algorithms. It is very closely based on <code>C++/C/C#</code>, so anyone with knowledge of these languages should be able to help me out with this one.</p>
  
  <p>I'm trying to create a very simple program which tells me the length of the upper and lower shadows (wicks) of the last periods candlestick. To do this, I've tried using the following code:</p>
  
  <pre><code>  double    bod1 = Close[1] - Open[1];
    double absbod1 = MathAbs( bod1 );
  
    if( bod1 &gt;= 0 )
    {
    double uwick1 = High[1] - Close[1];
    double lwick1 = Open[1] - Low[  1];
    }
    else
    {
    double uwick1 = High[ 1] - Open[1];
    double lwick1 = Close[1] - Low[ 1];
    }
  
    Alert( "Lower Wick: " , lwick1 , " Upper Wick: " , uwick1 );
  </code></pre>
  
  <p><strong>Q1:</strong> Why does this give the following error message?</p>
  
  <p><a href="https://i.stack.imgur.com/GZ4MD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GZ4MD.png" alt="error"></a></p>
  
  <p><strong>Q2:</strong> Can you not define variables within an <strong><code>if(){...}</code></strong> statement?</p>
  
  <p><strong>Q3:</strong> If not, how can I define a variable which depends on some other factor?</p>
  
  <p>I mean, suppose that I wanted to define the variable <strong><em>var</em></strong> such that <strong><em>var = a</em></strong> OR <strong><em>var = b</em></strong> depending on whether <code>a &gt; b</code> or not.</p>
  
  <p><strong>Q4:</strong> How would I do this, if not by using <code>if(){...}</code> statements, as shown above?</p>