[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing an exit signal after x bars up?



PureBytes Links

Trading Reference Links

I'm trying to write an ExitLong rule that will exit after a minimum number of  bars up (for
starters, an up bar defined as the close higher than the prev close) and if the current bars low is
lower than the prev bars low.  I can write it for a fixed number of bars but I'd like the rule to
stay long as long as the up bars continue to occur, and to be able to vary the minimum number of
bars.

Here's what I have for a fixed number of bars after the entry bar, 4 in this example:

==================
Inputs: Length(5);


If BarsSinceEntry = Length and C[1]>C[2] and C[2]>C[3] and C[3]>C[4] and C[4]>C[5] and C[5]>C[6]
                    and L<L[1] Then
      ExitLong("4barRun") This Bar On Close;

==================

How can this be changed, or rewritten, to make it more flexible?


John