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

Re: [amibroker] afl coding problem - buy signal when 2 conditions - one and then the other



PureBytes Links

Trading Reference Links

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


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/