title: Linear function with live data
body: <p>I am an absolute newbie on the programming thing and really desperate. I picked up a high end task to solve as it seems to me...</p>
  
  <p>I know there are tons of explanations for solving y = mx + b with python but they're all for the situation with "solid" data. I am trying to realize it with live data.</p>
  
  <p>So far, i have two data streams, which I successful directed into two lists - please see code below.</p>
  
  <pre><code>for graph in basis_graph:
  
      high_1 = float(graph.high)
      low_1 = float(graph.low)
  
      if high_1 &gt; 0:
          graph_high.append([high_1])
      if low_1 &gt; 0:
          graph_low.append([low_1])
  
  </code></pre>
  
  <p>Now comes the tricky part and I DON`T GET IT. I need a function that calculates me "m". Something like that:</p>
  
  <pre><code>def function_signal():
      if graph_high[-1] &lt; graph_high[-2]:
         please, mr. computer, calculate me "m"
  </code></pre>
  
  <p>I tried something like</p>
  
  <pre><code>    def signal():
          if graph_low[-1] &lt; graph_low[-2]:
              print("a")
              ay1 = graph_low[-1]
              by1 = graph_low[-2]
              m = ay1 - by1
              return m
          print(m(ay1, ay2))
  </code></pre>
  
  <p>Two days I tried EVERYTHING from what I know so far but the only thing I earned was a cascade of Tracebacks. From "I can't divide two list objects" to " "m" is not defined" and so on and so on...</p>
  
  <p>In the case above for example NOTHING happens. Sometimes he says "m is not defined"...</p>
  
  <p>Please, if there's someone out there who is willing to help me than I would really appreciate it.</p>
  
  <p>Thanks in advance.</p>