title: Ninjatrader drawing dots based on a condition
body: <p>I am new to coding in NinjaTrader. I am trying to draw a dot beneath bars based on a condition being true.</p>
  
  <p>if I make my condition as simple as possible, like this:</p>
  
  <pre><code>if (Close[0] &lt; Open[0]) 
  </code></pre>
  
  <p>-- I can get the dots to display correctly.</p>
  
  <p>But, if I try to refer to previous bars, like this: </p>
  
  <pre><code>if (Close[0] &lt; Open[1]) 
  </code></pre>
  
  <p>-- the code does not work. So, I assume it is the condition itself which I am getting wrong.</p>
  
  <p>Can anybody explain why this change would stop the code working, and how I would correctly refer to previous bars?</p>
  
  <p>Any help appreciated.</p>
  
  <p>Here's the rest of the code.</p>
  
  <pre><code>protected override void OnBarUpdate()
      {
  
          {   
  
              //if (Close[0] &lt; Open[0]) 
              if (Close[1] &gt; Open[1])
              //if(Close[1] &lt; Close[0] &amp;&amp; Close[1] &lt; Close[2])
  
                  { 
                      myBarCloses=1;
                  } else {
                      myBarCloses=0;
                  }
  
                  if (myBarCloses==1) 
                  {
                      DrawDot(CurrentBar.ToString() +"BarCloseDot",true, 0, Low[0]*0.997, Color.Magenta);
                  }
  
          }      
  
      }
  </code></pre>