How to test if candle is green and has broken the open of the previous red candle

I want to run an exploration where the filter would be true under two conditions:

  1. Today is a green candle that has closed above the open of the previous red candle (not necessarily the immediate prior candle).
  2. Today is a red candle that has closed below the open of the previous green candle (not necessarily the immediate prior candle).

If possible, I'd want to have some kind of output that differentiates between which of the two conditions triggered the filter.

@TheNutz, what have you got so far?

Most of the advanced users here want to see what you are doing, and then you tell us where you are having a problem.

Show us you code, in addition to the explanation you have, and show us what isn't working the way you are thinking it should. Then we can hopefully help you out.

As a start, how about defining the conditions you want and show that in your exploration that you can then use later as your filter. (Use a small watchlist or just a single item and track daily status of the conditions.)

Hope this helps to get you started.

1 Like
a = C>O;
b = C<O;
aa = valuewhen(a,O,1);
aaa = cross(c,aa);
Buy = a and aaa;