Due to the way array maths works, you can't normally use operations of the form:
<exitCondition> = BarsSince(<entryCondition>); This is because the entry array will likely have more signals than will ultimately be used once the exit array is defined (ie. there will likely be entry signals ignored because there's already a trade in progress), and BarsSince() will always be from the most-recent entry signal, even if it's one that's ultimately ignored. The first thought is usually to remove the excess entries with ExRem(), but you can't do that until after the exit array has been defined, so you have a Catch-22 situation. For iterative operations like this, you need to use a loop and work through the arrays bar by bar, so that you can both create the exit array and remove excess entry signals at the same time. So you don't need to use the CBT, just a loop. GP --- In [email protected], "trustdnb" <[EMAIL PROTECTED]> wrote: > > Is there a way to exit unprofitable trades after a certain number of > bars without using the CBT? Essentially what I want is an Nbar stop > that only triggers on unprofitable trades, without stopping winners. > > My weak attempt did not work: > > Short = /*short fomula */; > ShortExit = BarsSince(Short) > 12 AND C >= ValueWhen(Short, C); > Cover = ShortExit; >
