BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Plotting weekly indicators on daily charts
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Plotting weekly indicators on daily charts

 Post Reply Post Reply
Author
Message / View First Unread Post
jhubbard View Drop Down
Newbie
Newbie
Avatar

Joined: 17 Sep 2009
Location: Sydney
Posts: 10
Post Options Post Options   Quote jhubbard Quote  Post ReplyReply Direct Link To This Post Topic: Plotting weekly indicators on daily charts
    Posted: 12 Oct 2009 at 12:40pm
The Metastock Tips and Tools site (http://www.metastocktips.co.nz/) has a range of multi-frame indicators.  These let you plot weekly indicators on a daily chart. 

I would love to be able to use some of these in bullcharts but have been unable to successfully port them to bullscript.  Ideally I would like to use these in some of my tradesim scans.

Below is one of the metastock scans that plots a weekly SMA on a daily chart.  I would really appreciate it if someone was able to convert this to bullscript.  If I had this as a starting point I might be able to convert some more of their scans.

=================
Multi-Frame D SMA
=================

"Multi-Frame D SMA" plots a weekly or higher periodicity SMA signal on any EOD
or higher periodicity chart with sufficient open data. A prerequisite is the
Equis Forum DLL, available on this site or from http://forum.equis.com/

==============================

 {Multi-Frame D SMA}
 {Simple Moving Average}
 {Requires Equis Forum DLL}
 {Roy Larsen, 2008-2009}

 {User settings}
N:=Input("Multi-Frame D SMA, Periods",1,99,10);
J:=Input("Months per Frame, 0=Weekly",0,12,0);
J:=If(J<5 OR Mod(J,3)=0 AND (J<>9),Int(J),-1);
U:=Input("Price, 1=O 2=H 3=L 4=C 5=MP 6=WC 7=Typical",1,7,4);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
 {Update on last bar, new bar or new frame}

 {Timing signals}
{Day counter courtesy metastock@wabbit.com.au}
M:=Month();A:=Int((14-M)/12);D:=DayOfMonth();
Y:=Year();X:=Y+4800-A;B:=M+(12*A)-3;Z:=Cum(1);
M:=If(J=0,D+Int((2+153*B)/5)+(365*X)+Int(X/4)-
Int(X/100)+Int(X/400)-32045,{day counter}
(Y-ValueWhen(1,Z=1,Y))*12+M){month counter};
I:=If(J=0,Int(M/7),Int((M-1)/Max(1,J)));
I:=I<>ValueWhen(2,1,I);
G:=LastValue(J<0 OR Lowest(Sum(I>0,5))=5);
I:=ExtFml("Forum.Sum",I,1);M:=G OR I;
F:=G OR (M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Z-1)=Z;B:=LastValue(Z)=Z;
F:=F+B*(Q=0)*(J=0)*(DayOfWeek()=5);
J:=If(F,1,(Alert(F,2)=0)*M*2*(Z>1));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2,M*2,J));

 {Frame prices}
Om:=ValueWhen(1,M OR Z=1,O);
Om:=ValueWhen(1,J,If(J=1,Om,ValueWhen(2-G,1,Om)));
Hm:=HighestSince(1,M OR Z=1,H);
Hm:=ValueWhen(1,J,If(J=1,Hm,ValueWhen(2-G,1,Hm)));
Lm:=LowestSince(1,M OR Z=1,L);
Lm:=ValueWhen(1,J,If(J=1,Lm,ValueWhen(2-G,1,Lm)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
A:=(Hm+Lm)/2; B:=(Hm+Lm+K)/3; D:=(Hm+Lm+2*K)/4;
K:=If(U=1,Om,If(U=2,Hm,If(U=3,Lm,If(U=5,A,If(U=6,D,If(U=7,B,K))))));

 {Calculate/plot SMA}
J:=J>0; A:=Cum(J);
Z:=Z-ValueWhen(N+1,J,Z);
Z:=ExtFml("Forum.Sum",J*K,Z);
ValueWhen(1,J,Z)/Min(N,A);

==============================

Back to Top
rcameron View Drop Down
Moderator Group
Moderator Group


Joined: 04 Aug 2008
Posts: 21
Post Options Post Options   Quote rcameron Quote  Post ReplyReply Direct Link To This Post Posted: 22 Oct 2009 at 8:09pm
There are a couple of ways to do what you want. The simplest is to simply plot the SMA on the chart and then open up the indicator properties and select the "Advanced" tab. Under the tick box for Convert period: select Weekly. You now have a daily chart with a weekly moving average plotted on the chart. Cheers Rod
Back to Top
jhubbard View Drop Down
Newbie
Newbie
Avatar

Joined: 17 Sep 2009
Location: Sydney
Posts: 10
Post Options Post Options   Quote jhubbard Quote  Post ReplyReply Direct Link To This Post Posted: 23 Oct 2009 at 10:01am
Thanks for the reply Rod.  Not sure how I missed this feature in the manual - very handy.

Is it possible to use this in a Scan?
Back to Top
rcameron View Drop Down
Moderator Group
Moderator Group


Joined: 04 Aug 2008
Posts: 21
Post Options Post Options   Quote rcameron Quote  Post ReplyReply Direct Link To This Post Posted: 08 Nov 2009 at 4:08pm
I have not been able to work out how to combine different time frames within the same scan. Only way I could think of was to convert parameters to a common period. Eg 100 day MA = 20 week MA. Cheers Rod

Edited by rcameron - 14 Nov 2009 at 4:01pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz