Hi Haders --

Here is a code snippet that combines two signals.

Beware -- Perhaps you intentionally chose examples with very little meaning,
but your examples are computing levels or states,
rather than impulses.

Compare these two statements:
C>MA(C,5);   gives a state -- it is true on every bar where C is > MA(C,5)
Cross(C,MA(C,5));   gives an impulse -- it is true on those few bars where C
is > MA(C,5), but C was <= MA(C,5) on the previous bar.

//    TwoBuyConditions.afl
//

Cond6 = LinearReg( Foreign( "^RUT", "Close" ),100);
Cond7 = Ref( LinearReg(Foreign( "^RUT", "Close" ),100),-1);

BuySig1 = C>EMA(Close,100);
BuySig2 = RSI(2)<2;

//Essentially,if Cond6>Cond7 I wish to use Buy/Sell Signal #1.
//if not use Buy/Sell Signal 2.

Buy=IIf(Cond6>Cond7,BuySig1,BuySig2);

Thanks,
Howard
www.quantitativetradingsystems.com


On 11/6/07, haders2003 <[EMAIL PROTECTED]> wrote:
>
>   Hi
>
> I'm trying to implement a system which uses different Buy/Sell rules
> depending on the condition of a certain indicator. I'm using a 100
> period linear regression of the Russell 2000 as this indicator.
>
> Cond6 = LinearReg( Foreign( "^RUT", "Close" ),100);
> Cond7 = Ref( LinearReg(Foreign( "^RUT", "Close" ),100),-1);
>
> Buy=C>EMA(Close,100);//Buy signal 1
> Sell=C<EMA(Close,100);//Sell signal 1
>
> Buy=RSI(2)<2;Buy signal 2
> ApplyStop( stopTypeNBar, stopModeBars,4 );//Sell signal 2
>
> Essentially,if Cond6>Cond7 I wish to use buy/sell signal #1. If not
> use Buy/Sell signal 2.
>
> Have tried IIF Function as well as if-else loop, but no luck so far.
>
> Any help would be appreciated
>
> Regards
>
> Haders
>
>  
>

Reply via email to