in Search

Backtesting Weekly and Daily signals simultaneously

Last post 11-15-2007, 19:17 by blueboy65. 7 replies.
Sort Posts: Previous Next
  •  11-13-2007, 18:19 25779

    Backtesting Weekly and Daily signals simultaneously

    G'day all - is there a way to backtest for Weekly AND Daily signals on the same stock simultaneously ? As an example I would like to test the following:'

    1. RSI oversold on Daily chart  AND

    2. Weekly MA is rising

    Any help would be greatly appreciated.

    blueboy65

  •  11-13-2007, 18:59 25784 in reply to 25779

    Re: Backtesting Weekly and Daily signals simultaneously

    Hi Blueboy

     

     

    You could use my "Weekly SMA" indicator for EOD charts as part of your system test on daily data. Setting it up for your specific job shouldn't be too difficult. My "Weekly EMA" formula has to use PREV so would slow a system test down significantly. There are also DLL-based formulas around that allow you to plot weekly values on daily data. However, I'm not sure where you'd get the information you'd need for those, and I can't speak for their accuracy.

     

     

    Roy

    MetaStock Tips & Tools

     

     

     {Weekly SMA}

     {This indicator uses the Equis Forum DLL}

     {Roy Larsen, 2004-2007}

     

     {User settings}

    N:=Input("Weekly SMA, Periods",1,99,10);

    Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,0);

     {0, update at last bar of current frame}

     {1, update on each new bar}

     {2, update on first bar of new frame}

     

     {Weekly frame timing}

     {* Day counter from metastock@wabbit.com.au}

    M:=Month();A:=Int((14-M)/12);D:=DayOfMonth();

    Y:=Year()+4800-A;B:=M+(12*A)-3;

    M:=D+Int((2+153*B)/5)+(365*Y)+Int(Y/4)-Int(Y/100)+Int(Y/400)-32045;

     {*}I:=Int(M/7);

    I:=I-ValueWhen(2,1,I);

    G:=LastValue(Lowest(Sum(I>0,5))=5);M:=G+I;

    F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1);

    A:=LastValue(Cum(1)-1)=Cum(1);

    B:=Alert(A,2)*(A=0);

    J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));

    J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);

    J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));

     

     {Calculate and plot a Weekly SMA of CLOSE}

    K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));

    J:=J>0; X:=Cum(J*K);

    (X-ValueWhen(N+1,J,X))/N;

  •  11-13-2007, 19:08 25786 in reply to 25779

    Re: Backtesting Weekly and Daily signals simultaneously

    hey blue.... roy has done alot of work in the week vs daily ..... some of his indicators could possibly help you.....

    looking at your exact 1 and 2 conditions brings to mind something i use quite often when testing against daily and weekly together.....  you can divide your weekly ma by 5 and get roughly the same value .... in other words the weekly 50 ma is similar to the daily 10 ma.....   so if the daily 50 is rising , often times the weekly 10 is rising also..... it's just an approximation however.....

    roy's method is far better for precise work.....h

  •  11-13-2007, 19:12 25787 in reply to 25786

    Re: Backtesting Weekly and Daily signals simultaneously

    dangit roy..... you beat me by seconds....... aren't you suppose to be sleeping now.....

     

    oh btw, your hieken ashi indicator ought to be real handy.... thanks.....h

  •  11-13-2007, 19:42 25788 in reply to 25779

    Re: Backtesting Weekly and Daily signals simultaneously

    Hi H

    It's the middle of the afternoon here in NZ so I'd better not be sleeping (it's just after 3pm). I didn't mean to steal your thunder - haven't been visiting this site quite so often of late but dropped in today and thought perhaps I should add a couple of thoughts. Take care.

    Regards

    Roy

     

  •  11-13-2007, 20:26 25789 in reply to 25788

    Re: Backtesting Weekly and Daily signals simultaneously

    Roy - thanks heaps for the quick response !

    Just one question however, I'm assuming the Weekly SMA formula above plost the Weekly SMA on the Daily chart ? If this is so, then how would I determine whether the Weekly Close price is > the Weekly SMA (or would it be implied as long as the Weekly SMA was rising) ?

    Sorry for the dumb simple questions but as you can tell I'm just picking this up and have a lot of learning to do.

    blueboy65

  •  11-13-2007, 21:10 25790 in reply to 25789

    Re: Backtesting Weekly and Daily signals simultaneously

    Hi Blueboy

     

    You can assume that the weekly CLOSE is above a rising EMA (no matter what the direction of price an EMA always moves towards it), but you CANNOT assume the same thing with an SMA. I think the trick might be to alter the indicator slightly so that it outputs the condition you want instead of the weekly SMA. The weekly price (CLOSE) is developed within the indicator (K variable) as a prerequisite to creating the SMA. To plot a binary on a chart or call for an exploration or system test, change the last two lines from:

     

    J:=J>0; X:=Cum(J*K);

    (X-ValueWhen(N+1,J,X))/N;

    to:

    J:=J>0; X:=Cum(J*K);

    X:=(X-ValueWhen(N+1,J,X))/N; K>X;

     

    Or you could call FmlVar("Weekly SMA","K") - the weekly price - and test that for being greater than Fml("Weekly SMA") - the weekly SMA.

     

    FmlVar("Weekly SMA","K") > Fml("Weekly SMA");

     

    To use the indicator to plot both the weekly CLOSE and the weekly SMA, change the last line to:

     

    K; (X-ValueWhen(N+1,J,X))/N;

     

    This last option still allows you to call the Weekly SMA indicator value for an exploration or system test using Fml("Weekly SMA"). Hope this helps.

     

    Regards

     

    Roy

  •  11-15-2007, 19:17 25799 in reply to 25790

    Re: Backtesting Weekly and Daily signals simultaneously

    Roy - thanks once again ! I'll give these a try and let you know if I'm having any problems.

    blueboy65

View as RSS news feed in XML