Maybe I just haven't thought it through well enough. This is my thought process...
Pipeline is very easy to use to rank/score and mask stocks based on current data, but it's not immediately apparent to me how to use it on more dynamically-timed strategies.
Lets say, for the sake of example, we have a basic strategy where we enter a stock once it is under RSI 20 and then exit once it is over RSI 80. Inside of an algorithm one could simply return the RSI from Pipeline and add/remove stocks from a context.
list depending on the criteria. However, purely within pipeline I'm not aware of any way to remember a state from days previous. So my solution is to basically recreate history each day to determine the current state.
So you start at the furthest you can be bothered to look back, say 100 days. So you check what the RSI was 100 days ago: if it was under 20, then you'd be "in" the stock unless any day 99 days ago through today it was over 80 (because then you would have already exited as well, and thus no longer "in" the stock). Then you'd do the same for 99 days ago, etc.
I guess efficiency-wise, it'd be best to reverse it (start checking today's RSI, then yesterday's, etc.).
I'm a visual thinker, so this helps me:
days ago: 10 9 8 7 6 5 4 3 2 1 0
RSI: 50 10 50 90 50 10 50 50 90 10 50
action: - B - S - B - - S B -
are we in: N Y Y N N Y Y Y N Y Y
So you basically traverse backwards through the action columns (via chain of or
ed together clauses) . If you hit a -
you keep going until you hit a S
(in which case you not in the stock any longer, if you ever were) or a B
(currently in).