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

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



PureBytes Links

Trading Reference Links

Hi Howard

Thanks for the suggestions.  I've tried this but the difficult part 
comes with the sell signals.

How can I make sure that a position entered with BuySig1 is only sold 
with SellSig1 and not SellSig 2, even if Cond6>Cond7 is no longer 
valid (ie Cond6<Cond7)?

Is it possible to relate Buy and Sell signals? eg

if buy=BuySig1, sell=SellSig 1

Regards

Haders

Ps I note and am aware that the examples are not impulse signals.


--- In amibroker@xxxxxxxxxxxxxxx, "Howard B" <howardbandy@xxx> wrote:
>
> 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@xxx> 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
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/