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
|