-2

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?

enter image description here

Many thanks in advance.

Bugsy
  • 49
  • 2
  • 8
  • 1
    please post your code as formatted text, not as images – Sembei Norimaki Aug 18 '23 at 10:31
  • ***Do not include pictures of your code or data. Copy and paste the code into your question, and include your data by running `df.to_dict()` or `df.head().to_dict()`***. See: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Mark Aug 18 '23 at 10:59

0 Answers0