Hi Greenhorn --
Here is an example of an afl program that does what you ask.
// MultipleConditions.afl
//
// Example of afl to buy when
// multiple conditions occur in sequence
//
// The first condition is a setup.
// The second condition is a trigger.
//
// The setup must occur between exactly 1 and 9 bars
// before the trigger, but not on the bar of the trigger.
//
Setup = StochD(14,3,3) <= 30;
Trigger = Cross(C,MA(C,5));
Buy = Trigger
AND NOT Setup
AND BarsSince(Setup) >=1
AND BarsSince(Setup) <= 9;
Sell = BarsSince(Buy) >=3;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Plot(C,"C",colorBlack,styleCandle);
Plot(Setup, "Setup", colorGreen, styleLine|styleOwnScale);
Plot(Trigger, "Trigger", colorBlue, styleLine|styleOwnScale);
PlotShapes(Buy * shapeUpArrow + Sell * shapeDownArrow,
IIf(Buy,colorGreen,colorRed));
Thanks,
Howard
www.quantitativetradingsystems.com