By The Cringe,

As requested I have started a new thread as the existing one (referenced above) is closed.

In the solution on your spreadheet (column N of the attached spreadsheet) in your last post you used the function

=IF(AND(K7,J7=0),1,IF(J7,0,N6)) for cell N7.

This provided the solution I needed.

Now I want to take the model further and I need to amend the function but I don't understand it well enough. I have looked in Excel help and on the web but without success.

Specifically, I have inserted two new columns containing additional criteria and need to incorporate these in the above function in column N.

I have attached a sample spreadsheet showing the existing formulae and have highlighted the new columns in red. I have also put in red one sample additional trade the function needs to generate, cell O18.

Currently, the "buy" in column O arises as the buy signal in column J occurs after a sell signal in column K, e.g. J10. J14 does not trigger a "buy" as it follows a buy signal and the trade already exists.

Now that I am testing a different close out for trades, column L and M, cell J18 needs to trigger a buy as it follows a sell signal in cell M17.

Please let me know if I need to provide more information.