Thanks for the clarification. The reason there's no sell on the 4th bar is as follows.
Normally, when CrossUnder/Over is being evaluated against
two DataSeries (i.e.
public bool CrossUnder(int bar, DataSeries ds1, DataSeries ds2)), the method takes
four values: a CrossUnder happens when the current value should be below the target value at the specified bar + the previous value had been greater than or equal to the target value at the previous bar.
However, this Rule is programmed in a way that it is based on a different CrossUnder overload method which evaluates only
three data items: the current and the previous value and the single target value:
CODE:
Please log in to see this code.
This overloaded call is widely used to detect crossings with oscillator thresholds e.g. RSI 30/70. So, your condition is "Close crosses below Low 3 days ago". On 12/3/2013:
Current value i.e. Close[bar] = 37.97
Target value i.e. Low>>3[bar] =
38.40Is the current value below?
YESPrevious value i.e. Close[bar-1] = 38.28
Previous target value =
38.40Is the previous value (38.28) greater than or equal to the target value at the previous bar?
NOThe point is, in this case the function accepts only the single fixed value and therefore the Rule behaves unexpectedly. This is somewhat counterintuitive but this how it works. I don't know why the rule has been code like this, maybe the developers had a reason.
Anticipating your question re: how to make this strategy work as you designed, convert the system to code and make this little change for the exit to trigger on 12/03/2013:
CODE:
Please log in to see this code.