Backtest - general question

I am trying to write a program that has 3 possible trade exists. The basic structure is:

Buy = buy code
SellOrder1 = Sell condition 1 (profit target - such as High > Bollinger band)
SellOrder2 = Sell condition 2 (based on some indicator such as CCI slope < 0)
Sell order3 = Sell condition3 (Trailing stop)

SellOrder 1 and sell order 2 may use ApplyStop() function

I want to have a result of the earliest exit signal to be the one that takes effect and closes the trade.

Question:
Sell = SellOrder1 OR SellOrder2 OR SellOrder3;

Is the above appropriate code to achieve my objective or do I need to use CBT and process signals bar by bar and test for each condition sequensially?

Any other options?

Thanks
Ara

Neither SellOrder1 nor SellOrder2 need to use ApplyStop(). Therefore, just code your indicator logic, set the SellPrice variable correctly, and use:

Sell = SellOrder1 OR SellOrder2;

The trailing stop will be easiest to code with ApplyStop(). Do this as a separate step. You do not need to add this logic to the Sell variable. AmiBroker should enforce the first exit signal that it encounters.