I have a dataframe with open, high, low, close, 8DayMovingAverge, 21DayMovingAverage, and when the 8dma turns higher (1 or 0). For 'entry' I want the trade entry level to be the closing price when the 8ma turns higher. All good.
But, then I want to keep that same entry level in the 'entry' column until 8ma turns lower. So for 'entry' on date 2013-10-11 how do I take the value in the 'entry' row above. On this date I want 1692.96 from cell above, instead of 1703.2. And I want to keep that 1692.96 level until the 8dma turns lower.
Obviously my code is wrong (line 286) and takes the current close, instead I want the previous 'entry' level from the row above. Can I use iloc? or is there a better way?
Many thanks in advance.