logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
perfecttip  
#1 Posted : Monday, October 5, 2009 1:07:36 PM(UTC)
perfecttip

Rank: Member

Groups: Registered, Registered Users
Joined: 9/20/2009(UTC)
Posts: 15

I have a few equations which take the weekly HIGH, LOW and CLOSE as inputs and will give certain values. These values should be plotted on daily charts. Please help on how to go about it. Thanks.
mstt  
#2 Posted : Tuesday, October 6, 2009 4:36:40 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Hi PT

Accurate weekly values can be derived from my Multi-Frame D OHLC indicator (the D indicates it’s for use on daily charts or data). There are a number of ways you can derive weekly values with simpler formulas but the sad truth is that virtually all simpler methods return inaccurate prices under some circumstances.

With this formula and the Forum DLL installed you could either add your formula onto the end of this one, or else you could call the three required prices into your own indicator (Hm, Lm and K) and use them that way. If you were to add your own code onto mine you’d probably need to reuse some of the existing variable names as most of the allowable 20 are already taken.

Hw:=FmlVar("Multi-Frame D OHLC ","Hm");

Lw:=FmlVar("Multi-Frame D OHLC ","Lm");

K:=FmlVar("Multi-Frame D OHLC ","K");

J:=FmlVar("Multi-Frame D OHLC ","J")>0;

Calling the required weekly prices is as simple as using the first three lines above to define weekly High, Low and Close. The J variable signals the bar on which the weekly prices were sampled. This will usually be a Friday but could be Monday under certain circumstances. You probably don’t need this signal but at times it can be useful to synchronize with weekly price updates.

An older version of Multi-Frame D OHLC can be found at http://www.metastocktips.co.nz/multi_frame_d_ohlc.txt

Roy

{Multi-Frame D OHLC}

{Requires Equis Forum DLL}

{Roy Larsen, 2008-2009, 15/9/09}

{User settings}

N:=Input("Multi-Frame D OHLC",0,0,0);

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);

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

{Update on last bar, new bar or new frame}

{Timing signals}

{Day counter by metastocktools.com}

D:=DayOfWeek();M:=Month();Y:=Year();

Z:=Cum(1);F:=Rnd(Life(291231));

M:=If(J=0,ValueWhen(1,Z=1,F+D)-F,

(Y-ValueWhen(1,Z=1,Y))*12+M);

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+I;

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

B:=LastValue(Z);A:=B-1=Z;B:=B=Z;

F:=F+B*(Q=0)*(J=0)*(D=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+(Z=1),O);

Hm:=HighestSince(1,M+(Z=1),H);

Lm:=LowestSince(1,M+(Z=1),L);

Om:=ValueWhen(1,J,If(J=1,Om,ValueWhen(2-G,1,Om))); {O}

Hm:=ValueWhen(1,J,If(J=1,Hm,ValueWhen(2-G,1,Hm))); {H}

Lm:=ValueWhen(1,J,If(J=1,Lm,ValueWhen(2-G,1,Lm))); {L}

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

Om; Hm; Lm; K;
perfecttip  
#3 Posted : Wednesday, October 7, 2009 6:04:01 AM(UTC)
perfecttip

Rank: Member

Groups: Registered, Registered Users
Joined: 9/20/2009(UTC)
Posts: 15

Does this take care of the errors caused by holidays on certain weeks ?
perfecttip  
#4 Posted : Wednesday, October 7, 2009 6:14:30 AM(UTC)
perfecttip

Rank: Member

Groups: Registered, Registered Users
Joined: 9/20/2009(UTC)
Posts: 15

What I am basically trying to do is plot weekly camarilla levels and daily camarilla levels on intraday charts. The plots should show only the last values of these levels, i.e. weekly values after calculation on friday end should be displayed till next friday and as for daily levels , those calculated after todays market close should be displayed till tomorow close. They will just be a few horizontal lines on the chart with some sort of visual difference between weekly and daily levels so that they can be easily noticed. Better still, if such an expert advisor and/or an exploration could be developed to constantly display those stocks that are tradable as per camarilla rules.
mstt  
#5 Posted : Wednesday, October 7, 2009 9:01:13 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Hi PT

Yes, my formula does take care of potential errors caused by holidays on certain weeks. It also takes care of missing days or data gaps for any other reason.

Weekly Camarilla levels can easily be calculated from the weekly prices, assuming that you have the formulas for these levels (the way you calculate Camarilla levels might be different from the way I do). Setting the Q variable default to 2 would hold the previous week’s levels until the first intraday bar of the new trading week begins to form. Outputs can easily be forced to plot values relating just to the previous week by wrapping each price definition in LastValue().

The formula for weekly Camarilla levels is shown below with all 8 levels restricted to plotting on 25 bars only. This limitation can be easily changed by adjusting the last definition of "Z". The indicator should plot on intraday charts as well as EOD charts, still returning weekly levels of course.

Daily levels could be based on my "Multi-Frame X OHLC" formula but I can’t show that here as it’s only available to MSTT subscribers or owners of the Multi-Frame Intraday kit. However, something quite simple (but adequate for the task) could be put together using DayOfWeek()<>Ref(DayOfWeek(),-1) as a start-of-new-week trigger for sampling daily prices.

Roy

{Multi-Frame D Camarilla Levels}

{Requires Equis Forum DLL}

{Roy Larsen, 2009, 8/10/09}

{User settings}

N:=Input("Multi-Frame D Camarilla Levels",0,0,0);

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);

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

{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)));

Z:=LastValue(Z)-25=Z;

{Camarilla levels}

ValueWhen(1,Z,LastValue(K+(Hm-Lm)*1.1/2)); {R4}

ValueWhen(1,Z,LastValue(K+(Hm-Lm)*1.1/4)); {R3}

ValueWhen(1,Z,LastValue(K+(Hm-Lm)*1.1/6)); {R2}

ValueWhen(1,Z,LastValue(K+(Hm-Lm)*1.1/12));{R1}

ValueWhen(1,Z,LastValue(K-(Hm-Lm)*1.1/12));{S1}

ValueWhen(1,Z,LastValue(K-(Hm-Lm)*1.1/6)); {S2}

ValueWhen(1,Z,LastValue(K-(Hm-Lm)*1.1/4)); {S3}

ValueWhen(1,Z,LastValue(K-(Hm-Lm)*1.1/2)); {S4}

perfecttip  
#6 Posted : Thursday, October 8, 2009 12:32:46 PM(UTC)
perfecttip

Rank: Member

Groups: Registered, Registered Users
Joined: 9/20/2009(UTC)
Posts: 15

i have downloaded teh forum dll. where should i paste it ?
mstt  
#7 Posted : Thursday, October 8, 2009 1:10:24 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Save the Forum DLL to the "External Function DLLs" folder (under the "MetaStock" folder) and then restart MetaStock.

Roy

perfecttip  
#8 Posted : Thursday, October 8, 2009 4:30:56 PM(UTC)
perfecttip

Rank: Member

Groups: Registered, Registered Users
Joined: 9/20/2009(UTC)
Posts: 15

Yes, it worked. Thanks a ton. I am posting the formulae I use. Please check with the ones you use and confirm if they are the same. H5 = (H/L)*C H4 = [1.1*(H-L)/2]+C H3 = [1.1*(H-L)/4]+C H2 = [1.1*(H-L)/6]+C H1 = [1.1*(H-L)/12]+C L1 = C-[1.1*(H-L)/12] L2 = C-[1.1*(H-L)/6] L3 = C-[1.1*(H-L)/4] L4 = C-[1.1*(H-L)/2] L5 = C-(H5-C) 1.It would be great if you could add the coding ifor H5 and L5 levels into your code. 2. Can you please post the codes for h1 to h5 and l1 to l5 for daily and monthly timeframes as well ? 3. Is there an expert advisor and/or explorer coding for this system ? Thanks.
mstt  
#9 Posted : Thursday, October 8, 2009 5:12:40 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Hi PT

1. Apart from H5 and L5 I think my definitions agree with yours. A MetaStock-syntax version of your code is shown at the bottom of this post.

2. Once added to the formula already posted you’ll be able to plot either weekly or monthly Camarilla levels merely by changing the "Months per Frame" default value to 1 (month). To plot both weekly and monthly values at the same time make a duplicate copy of my indicator, then change the name and the default input value of the copy. I’ll look at setting up a daily version and the additional outputs later on today.

3. I’m not aware of an expert or exploration for a Camarilla levels based system. My understanding is that such a system would be discretionary and so any system would vary from one individual to another. Explorations and experts are not that difficult to build but to source various levels from my indicator with FmlVar() functions the various levels would need to be assigned names (as below for example). The merging of daily, weekly and monthly indicators is not really practical as Metastock does not permit 30 named outputs (10 per each timeframe). Leaving outputs unnamed is fine when an indicator is used for display purposes only, but it’s useless if the outputs have to be available to other formulas.

Roy

H5:=(H/L)*C;

H4:=C+1.1*(H-L)/2;

H3:=C+1.1*(H-L)/4;

H2:=C+1.1*(H-L)/6;

H1:=C+1.1*(H-L)/12;

L1:=C-1.1*(H-L)/12;

L2:=C-1.1*(H-L)/6;

L3:=C-1.1*(H-L)/4;

L4:=C-1.1*(H-L)/2;

L5:=C-(H5-C);

H5; H4; H3; H2; H1; L1; L2; L3; L4; L5;

perfecttip  
#10 Posted : Thursday, October 8, 2009 11:53:52 PM(UTC)
perfecttip

Rank: Member

Groups: Registered, Registered Users
Joined: 9/20/2009(UTC)
Posts: 15

The objective is to keep 50 (say) RT charts open and with the Camarilla expert advisor running within each of them. Whenever a stock touches the preset levels, Metstock should alert me as to which stock is exhibiting such activity. Its nothing but trying to automate the stock picking process to the greatest extent. Kindly help. Also please do advise me on how to password protect custom indicators, experts and explorations. Thanks.
perfecttip  
#11 Posted : Saturday, October 10, 2009 12:34:06 PM(UTC)
perfecttip

Rank: Member

Groups: Registered, Registered Users
Joined: 9/20/2009(UTC)
Posts: 15

Is this possible ? What I am looking for is automation of the stock picking process. Please allow me to discuss in detail the aspects I am looking for. 1. Camarilla levels shall be calculated as per the following equations : H5 = (H/L)*C H4 = [1.1*(H-L)/2]+C H3 = [1.1*(H-L)/4]+C H2 = [1.1*(H-L)/6]+C H1 = [1.1*(H-L)/12]+C L1 = C-[1.1*(H-L)/12] L2 = C-[1.1*(H-L)/6] L3 = C-[1.1*(H-L)/4] L4 = C-[1.1*(H-L)/2] L5 = C-(H5-C) 2.These levels must be used to develop a Custom Indicator, a Custom Exploration and a Custom Expert Advisor. 3.All of the above must take care of trading holidays even those which fall within the week. 4.Custom Indicator : An integrated indicator which will display the weekly and daily Camarilla levels when plotted on any chart irrespective of whether it is an RealTime intraday chart, a daily chart or a weekly chart with easily recognisable colour coding. Also a seperate indicator for monthly Camarilla levels. 5.Custom Exploration : Three seperate explorations (daily, weekly and monthly) to find out which stocks are trading near any of the Camarila levels. 6.Custom Expert Advisor : An advisor which when attached to a chart, whether its an RT intraday chart, a weekly chart or a monthly chart, alerts with a visual and audio alert when the stock trades near any of the Daily, Weekly or Monthly Camarilla levels. 7.Changes necessary in the coding if the numbers (2,4,6,12) in the equations are to me modified. 8.System tester. 9.Passowrd protection (of course should be know to me) for all of the above.
mstt  
#12 Posted : Saturday, October 10, 2009 10:37:57 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Hi PT

My understanding is that an alert will only be signalled on the active chart (not those in the background). If I'm right then the only thing I see happening with 50 open charts is MetaStock grinding to a halt. A better way to go might be to set up an exploration, using a modified version of the Camarilla indicator that I've already shown you, and running that at regular intervals. Developing my formula(s) further and setting up an exploration to use it/them would take time that I'm not prepared to give to an open-ended project. At this point I suggest you contact a reputable MetaStock programmer with a view to paying for their time to follow through on your project. It would also be to your advantage to start reading the MetaStock User Manual and learn the basics of the formul language, and how to use the program.

Roy

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.