title: how to retrospectively adjust columns in Pandas so it loops through and adjusts the subsquent columns
body: <p>thanks in advance. apologies for the awful title i couldnt work out how to put it into words</p>
  
  <p>i currently have a program writtin in python with Pandas that goes through stock data and tests my trading strategy. i was looking to expand on the complexity but i have hit a road block. i ahve it set up to return a 1 in the purchase column after my buy signal is generated. it returns a 1 in the sell column when a sell signal is generated. absed on these numbers the hold cumn tracks how long i've held the share for and gives a -1 when the share sells. the changes column keeps track of the fluctation in share price while trades are active. </p>
  
  <p>which brings me to my question. i would like the sell signal to return a 1 when the sum of the changes during a trade exceeds 2*ATR. i currently cant work out how to get a rolling sum of the changes column over just the active periods and i dont know how to retrospectively adjust the sell column the then properly assess the strategy.</p>
  
  <p>tldr: how do i get a rolling sum over a variable period and how can i feed this into a previously generated column to re-adjust the trade</p>
  
  <pre><code>       Date      Purchase  Sell_Check  Hold     ATR   Changes
  162  20190821         0           1     0  0.050429  0.000000
  163  20190822         1           0     0  0.048834  0.000000
  164  20190823         0           0     1  0.048686 -0.010484
  165  20190826         0           1     1  0.050159 -0.022005
  166  20190827         1           0    -1  0.048226 -0.027083
  167  20190828         0           0     1  0.046424  0.093158
  168  20190829         0           0     1  0.046783  0.047383
  169  20190830         0           0     1  0.044983  0.045915
  170  20190902         0           0     1  0.043924  0.012912
  171  20190903         0           0     1  0.041378  0.017527
  172  20190904         0           0     1  0.039872 -0.003758
  173  20190905         0           0     1  0.039173  0.023577
  174  20190906         0           0     1  0.038237  0.040541
  175  20190909         0           0     1  0.037025 -0.000295
  176  20190910         0           0     1  0.039986 -0.041335
  177  20190911         0           1     1  0.041945 -0.011395
  178  20190912         0           0    -1  0.042984 -0.014953
  179  20190913         0           0     0  0.041245  0.000000
  180  20190916         0           0     0  0.041138  0.000000
  181  20190917         0           1     0  0.041588  0.000000
  182  20190918         0           0     0  0.041113  0.000000
  183  20190919         0           0     0  0.039908  0.000000
  184  20190920         0           0     0  0.039572  0.000000
  </code></pre>