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

Notification

Icon
Error

Options
Go to last post Go to first unread
Spicierboar  
#1 Posted : Friday, November 12, 2010 9:34:24 AM(UTC)
Spicierboar

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 5/28/2010(UTC)
Posts: 3

Hi I want to reference a 30 minute chart using expert advisor..e.g., the expert advisor generates a buy signal on a 5 minute chart based on a cross of moving averages, a white candle on 30 minute chart is required for confirmation. Please assist Thanks S
mstt  
#2 Posted : Saturday, November 13, 2010 7:13:09 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 S This is probably overkill for what you want but since all of the logic is already in place it’s simpler for me to use an adaptation of my "Multi-Frame I OHLC" indicator to produce a 30-minute White or Black candle indicators than trying to work out some simpler version. The following formulas generate 30-minute OPEN and CLOSE prices for intraday data of lower periodicity and compare those prices to decide if the candle is Black or White. You may need to change the default mode setting from static (0) to Delayed (2) but I’ll leave it up to you to figure out any timing issues. What these indicators will tell you at the end of each 30-minute period (frame) is whether the just completed period (bar or frame) was a White or a Black candle (TRUE or FALSE result for the subsequent frame). If you get confused about what these indicators are telling you try reducing the output line to just K. That variable will tell you the closing price for all historical 30-minute bars. You can confirm these values by jotting down the last few (different) frame prices and then after switching your chart to 30-minute periodicity verify the prices already jotted down. Once you’ve worked through any mental blocks, such as timing issues, you should easily be able to combine the "Multi-Frame I White Candle" indicator with your standard 5-minute code and come up with the required answer.
Code:

 {Multi-Frame I White Candle}
 {Requires Equis Forum DLL}
 {Roy Larsen, 2008-2010, 14/11/10}

 {User settings}
N:=Input("Multi-Frame I White Candle, Half Frame Offset",0,1,0);
J:=Input("Minutes per Frame (1-240)",1,240,30);
J:=If(Mod(J,5)=0 AND J<21 OR J=30 OR Mod(J,60)=0 OR J<5,J,5);
N:=N*J*(Mod(J,2)=0)/2;
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,0);
 {Update on last bar, new bar or new frame}

 {Timing} {Day counter by metastocktools.com}
D:=DayOfMonth();F:=Rnd(Life(291231));
Z:=Cum(1);D:=ValueWhen(1,Z=1,F+D)-F;
D:=N+D*1440+Minute()+Hour()*60;
I:=Int((D-1)/J);I:=I>ValueWhen(2,1,I);
G:=LastValue(Lowest(Sum(I>0,9))>7);
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)*(D/J=Int(D/J))*(Mod(D,1440)>0);
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}
Q:=ValueWhen(1,M+(Z=1),O);
Q:=ValueWhen(1,J,If(J=1,Q,ValueWhen(2-G,1,Q)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
K>Q {C>O for selected frame size - White candle}
Code:

 {Multi-Frame I Black Candle}
 {Requires Equis Forum DLL}
 {Roy Larsen, 2008-2010, 14/11/10}

 {User settings}
N:=Input("Multi-Frame I Black Candle, Half Frame Offset",0,1,0);
J:=Input("Minutes per Frame (1-240)",1,240,30);
J:=If(Mod(J,5)=0 AND J<21 OR J=30 OR Mod(J,60)=0 OR J<5,J,5);
N:=N*J*(Mod(J,2)=0)/2;
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,0);
 {Update on last bar, new bar or new frame}

 {Timing} {Day counter by metastocktools.com}
D:=DayOfMonth();F:=Rnd(Life(291231));
Z:=Cum(1);D:=ValueWhen(1,Z=1,F+D)-F;
D:=N+D*1440+Minute()+Hour()*60;
I:=Int((D-1)/J);I:=I>ValueWhen(2,1,I);
G:=LastValue(Lowest(Sum(I>0,9))>7);
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)*(D/J=Int(D/J))*(Mod(D,1440)>0);
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}
Q:=ValueWhen(1,M+(Z=1),O);
Q:=ValueWhen(1,J,If(J=1,Q,ValueWhen(2-G,1,Q)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
K<Q {C<O for selected frame size - Black candle}
Roy
mstt  
#3 Posted : Saturday, November 13, 2010 7:20:19 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)
Well that was fun. The last line of the second formula should have been virtually the same as the last line of the first formula except with the "greater than" signs replaced by "less than signs" (and Black candle instead of White candle). Wabbit, what went wrong? Roy
mstt  
#4 Posted : Saturday, November 13, 2010 8:40:09 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)
IK, it looks like I'll have to remove the "less than" signs and repost both formulas. Such is life. Roy
mstt  
#5 Posted : Saturday, November 13, 2010 11:04:15 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)
Try this for a 30-minute White candle. {Multi-Frame I White Candle} {Requires Equis Forum DLL} {Roy Larsen, 2008-2010, 14/11/10} {User settings} N:=Input("Multi-Frame I White Candle, Half Frame Offset",0,1,0); J:=Input("Minutes per Frame (1-240)",1,240,30); J:=If(Mod(J,5)=0 AND 21>J OR J=30 OR Mod(J,60)=0 OR 5>J,J,5); N:=N*J*(Mod(J,2)=0)/2; Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,0); {Update on last bar, new bar or new frame} {Timing} {Day counter by metastocktools.com} D:=DayOfMonth();F:=Rnd(Life(291231)); Z:=Cum(1);D:=ValueWhen(1,Z=1,F+D)-F; D:=N+D*1440+Minute()+Hour()*60; I:=Int((D-1)/J);I:=I>ValueWhen(2,1,I); G:=LastValue(Lowest(Sum(I>0,9))>7); 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)*(D/J=Int(D/J))*(Mod(D,1440)>0); 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} Q:=ValueWhen(1,M+(Z=1),O); Q:=ValueWhen(1,J,If(J=1,Q,ValueWhen(2-G,1,Q))); K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C))); K>Q {C>O for selected frame size - White candle} Roy
Spicierboar  
#6 Posted : Sunday, November 14, 2010 2:59:37 AM(UTC)
Spicierboar

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 5/28/2010(UTC)
Posts: 3

Thanks Roy, Could you also advise how to configure the DLL. I received the following error for the last case. "This DLL does not exist in the MSX DLL folder." Thanks once again..
mstt  
#7 Posted : Sunday, November 14, 2010 11:27:56 AM(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 S Go to the Files section of this website and download the item labelled "ForumDll 200" - this is a 188KB file. Save the file to the "External Function Dlls" folder and change it's name to "Forum.DLL". Restart MetaStock to register the DLL and the indicator will return the intended binary plot. 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.