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

Re: [amibroker] Help with delaying a buy signal



PureBytes Links

Trading Reference Links

If I understand correct you want to buy when the line has been above
the trigger line for 2 consecutive bars
Buy = sum(  (ml-sl) > 0.03,  2  )  ==  2;

--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm



On 1/31/06, Keith Osborne <kosborn3@xxxxxxxxxxxxxx> wrote:
> Hi, the following code is taken from the standard MACD indicator which I
> am using to understand AFL a little more. I have added a simple buy/sell
> condition.
>
> What I would like to do is delay the buy decision to ensure the buy
> signal is above the trigger level for 2 (or more) periods before the buy
> is actioned. Could someone assist please.
>
> TIA.....Keith
>
>
> // Simple MACD system //
>
> r1 = Param( "Fast avg", 12, 2, 200, 1 );
> r2 = Param( "Slow avg", 26, 2, 200, 1 );
> r3 = Param( "Signal avg", 9, 2, 200, 1 );
>
> ml = MACD(r1, r2);
> sl = Signal(r1,r2,r3);
>
> Buy = (ml-sl) > 0.03;
> Sell = Cross(sl,ml);
> Buy = ExRem(Buy,Sell);
> Sell = ExRem(Sell,Buy);
>
> Plot(0.03,"",colorBlack,styleDashed);
> Plot( ml, StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD
> color", colorRed ), ParamStyle("MACD style") );
> Plot( sl, "Signal" + _PARAM_VALUES(), ParamColor("Signal color",
> colorBlue ), ParamStyle("Signal style") );
> Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorBlack
> ), styleNoTitle | ParamStyle("Histogram style", styleHistogram |
> styleNoLabel, maskHistogram ) );
>
>
> PlotShapes(shapeUpArrow*Buy+shapeDownArrow*Sell,
> IIf(Buy,colorBrightGreen,colorYellow));
>
>
>
> 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 other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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 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/

<*> 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/