in Search

Help making EMA backtest formula

Last post 09-15-2009, 19:37 by mstt. 1 replies.
Sort Posts: Previous Next
  •  09-14-2009, 13:08 30720

    Help making EMA backtest formula

    Hi,

    I would like to make a formula to use for backtesting that makes this:

    1)  Buy when weekly 13 EMA is going up, and daily candle closes above daily 13 EMA;

    2) Sell when daily candle closes bellow daily 13 EMA;

    3) Sell short when weekly 13 EMA is going down, and daily candle closes bellow daily 13 EMA;

    4) Buy to close when daily candle closes above daily 13 EMA;

    Can anyone help please?

    regards,
    BBCTrader



  •  09-15-2009, 19:37 30732 in reply to 30720

    Re: Help making EMA backtest formula

    Hi BBCTrader

    If you have the "Multi-Frame D EMA" indicator installed and set with the appropriate options (13 weeks etc.) then the following code should provide you with a starting point. Each block of signals is truncated and only the first TRUE is allowed to pass. You can get this indicator at...

    http://www.metastocktips.co.nz/multi_frame_d_ema.txt

    {Buy}

    K:=Fml("Multi-Frame D EMA");

    J:=FmlVar("Multi-Frame D EMA","J");

    Buy:=K>ValueWhen(2,J,K) AND C>Mov(C,13,E);

    Buy AND Alert(Buy=0,2);

     {Sell}

    Sell:=C<Mov(C,13,E);

    Sell AND Alert(Sell=0,2);

     {Sell Short}

    K:=Fml("Multi-Frame D EMA");

    J:=FmlVar("Multi-Frame D EMA","J");

    Short:=K<ValueWhen(2,J,K) AND C<Mov(C,13,E);

    Short AND Alert(Short=0,2);

     {Buy to Cover}

    Cover:=C>Mov(C,13,E);

    Cover AND Alert(Cover=0,2);

    Regards, Roy

View as RSS news feed in XML