[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Using 2 sets of Buy/Sell rules



PureBytes Links

Trading Reference Links

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 < haders2003@xxxxxxxxx> 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


__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___