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)
|
Diesel
Here's one example, though possibly not a good one as far as you're concerned. Both ATR and ADX use Wilders Smoothing internally, and that means they require PREVs when recreated for a longer timeframes. ADX actually needs 3 PREVs (replicating 3 Wilders Smoothing functions), and ATR just 1as far as I can recall. PREVs make life difficult when large amounts of history are involved, so such functions/indicators are not good candidates for converting to longer time frames for intraday charts. If EMAs can be avoided (and therefore PREVs also) then the overheads are not so bad. Unless, that is, you're creating a function such as Standard Deviation, where an intermediate value has to be created for each frame of the periods-parameter range.
I've quickly made up an SMA for any one of the OHLC prices. This method of creating an SMA tends to lose accuracy a little when large numbers of bars are used, so again, 1-minute charts aren't great. A weekly SMA on EOD charts shouldn't be a problem, though the third and fourth decimal places tend to be off nearer the right side of the chart.
There are solutions for this problem too. One of them requires the same sort of approach as for Standard Deviation, and I'm sitting on the other one until after the November issue of MSTT is out.
The timing module for 5, 10 and 15 minute frames each have two or three minor but critical differences to this one. The J variable (times 3) needs a rework but it functions exactly as intended in all my "longer time frame" indicators as far as I'm aware.
I know this does not have the 60 minute timing module you're probably looking for, but I think it can probably be adapted. However I don't think that converting it to 60 minutes is quite as easy as converting to 5, 10 and 15 is, something I have already done.
{30 Minute SMA}
{©2005 Roy Larsen, www.metastocktips.co.nz}
{for use on 1/5/10/15 minute charts}
{user options}
N:=Input("Plot 30 Minute SMA",1,99,5);
R:=Input("Price, 1=O 2=H 3=L 4=C",1,4,4);
Q:=Input("User Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
{timing module for longer time frames}
A:=Minute(); B:=Hour()*60+A-1; J:=Int(B/30);
G:=LastValue(Highest(A)<=30);
D:=DayOfWeek()<>ValueWhen(2,1,DayOfWeek());
M:=J<>ValueWhen(2,1,J) OR D OR G;
F:=J-ValueWhen(2,1,J)>1 OR (Frac(A/30)=0)*(D=0) OR G;
A:=LastValue(Cum(1)-1)=Cum(1);
B:=ValueWhen(2,1,A);
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));
{Prices for longer time frames}
Oo:=ValueWhen(1,M,O);
Oo:=ValueWhen(1,J,If(J=1,Oo,ValueWhen(2-G,1,Oo)));
Hh:=HighestSince(1,M,H);
Hh:=ValueWhen(1,J,If(J=1,Hh,ValueWhen(2-G,1,Hh)));
Ll:=LowestSince(1,M,L);
Ll:=ValueWhen(1,J,If(J=1,Ll,ValueWhen(2-G,1,Ll)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Oo:=ValueWhen(1,Oo>0,Oo);
Hh:=ValueWhen(1,Hh>0,Hh);
Ll:=ValueWhen(1,Ll>0,Ll);
{Build function for longer timeframe}
{Plot Simple Moving Average}
K:=If(R=1,O,If(R=2,H,If(R=3,L,C)));
M:=(Cum((J>0)*K)-ValueWhen(N+1,J,Cum((J>0)*K)))/N;
M;
mstt (Roy)
|