title: Detect sign changes in an array
body: <p>I need to put an order when the values change from positive to negative, for example (print &quot;sell&quot;),
  and when they change from negative to positive, for example (print &quot;buy&quot;).  For indexes where there is not a sign change, I want to print &quot;ok&quot;.</p>
  <p>How should I code this with python?</p>
  <hr />
  <p><strong>Example input</strong></p>
  <pre><code>list = [ 1, 2, 6, -3, -2, -5, 6, 7, 1, -1, -3] 
  </code></pre>
  <p>First three values (1, 2, 6)  are positive values, but when it becomes minus, I want to <code>print('sell')</code></p>
  <p>And for -3, -2, -5, there are negative values, when it becomes positive, I want to <code>print('buy')</code></p>
  <p>Otherwise, (when the values keep the same sign) <code>print('ok')</code></p>
  <p><strong>Example output</strong></p>
  <pre class="lang-none prettyprint-override"><code>ok ok ok sell ok ok buy ok ok sell ok 
  </code></pre>