[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Free Mmath code



PureBytes Links

Trading Reference Links

Has anyone familiar with Metastock code been able to convert this for use in
TradeStation? See code below. Sure would appreciate a copy if you have done
so.
Karl


Subject: Free Mmath code


>Free code for murrey math
>this code is made for metastock but can be adapted for
>
>TS
>> >Murrey Mathers Who Use MetaStock
>> >
>> >There has been considerable discussion lately on
>this
>> >list regarding which is the correct square. A
>square
>> >is not done until its done. All you can know at any
>> >point in time is what the most recently COMPLETED
>> >64 day, 32 day, 16 day, etc... (e.g. a completed 64
>> >day square is one that has moved through all 64
>days).
>> >
>> >This can be more easily seen by showing all of the
>> >squares (64, 32, 16, 8, and 4) simultaneously
>(Murrey's
>> >so called 3rd dimension). To this end I am providing
>you
>> >with an indicator that will run under the current
>version
>> >of MetaStock (6.5.2 EOD). The text of this
>indicator
>> >appears below. You may cut and paste it from this
>e-mail
>> >to the MetaStock indicator editor. Give it whatever
>name
>> >you want. You may then drop it into your charts. I
>have
>> >also attached a GIF file of the OEX cash index that
>shows
>> >the end result. The labels I added manually for
>clarity
>> >(match the color to the square). The Waist indicator
>is a
>> >separate indicator
>> >
>> >Waist:=(O+C)*0.5;
>> >Waist;
>> >
>> >The indicator I am providing here must be applied
>> >separately for each square in your chart. So, you
>will
>> >drag it into your chart once for each of the 64, 32,
>16,
>> >8 and 4 day squares. That means the chart will
>contain 5
>> >copies of this indicator. This indicator is already
>set
>> >up with the start of the current Murrey Math year
>> >(10/5/98). You will want to assign a unique color
>to
>> >each copy of the indicator so that each square may
>be
>> >easily recognized.
>> >
>> >The vertical lines are created by using the CYCLE
>LINES
>> >function built into MetaStock. I have created 3 sets
>of
>> >lines (4 day, 8 day, and 16 day). Each set of lines
>was
>> >given a different line thickness to distinguish
>them.
>> >Each set of vertical lines was given a start date
>of
>> >10/5/98. That way they are aligned with the
>indicator.
>> >
>> >Once you have created your squares and time lines
>you can
>> >save this as a template file. Then you can bring up
>any
>> >other time series and apply this template. The
>squares are
>> >created automatically. If you save this as the
>default
>> >template, it is applied automatically to any new
>charts.
>> >
>> >To create a square of witdh N, this indicator
>identifies
>> >the highest and lowest values in the most recently
>> >COMPLETED square of width N. The appropriate MM
>lines
>> >are calculated and displayed. The lines are
>displayed from
>> >the start of the square to the end of the chart.
>> >
>> >Due to certain limitations in the MetaStock
>programming
>> >language there are three restrictions.
>> >
>> >1) The indicator will not correctly calculate the
>case
>> >   when price trades through a range from 0 to
>> >   approximately 2 x its perfect square (e.g. 2 x
>100).
>> >   For stock traders this will restrict its use for
>> >   internet stocks which trade through a large
>range.
>> >   For the conservative traders among you this will
>not
>> >   present a problem. Most stocks and indices DOW,
>SP's
>> >   will be calculated correctly.
>> >
>> >2) The indicator will not correctly calculate the
>transition
>> >   square (e.g. when price trades across 2.5 x the
>perfect
>> >   square). Again this will not be a restriction for
>most
>> >   users.
>> >
>> >3) The circles are not applied automatically. These
>must be
>> >   drawn in manually.
>> >
>> >Assuming that MetaStock expands its programming
>language to
>> >accept a greater number of variables and characters
>in an
>> >indicator, restrictions 1 and 2 will be eliminated.
>> >
>> >The positives are that you have all of the other
>capabilities
>> >of MetaStock at your disposal. You can apply Gann
>Fans,
>> >Speedlines, Gann Grids, Fib levels etc. You also
>have access
>> >to the programming language which will allow the
>ambitious
>> >among you to create explorations so that you may
>search a
>> >large universe of stocks for trading opportunities
>(e.g. is
>> >price > 8/8th's line for a square of width N?).
>MetaStock
>> >also supports candlestick recognition that could
>also be
>> >used in your explorations.
>> >
>> >Naturally, I take no responsibility for any
>investment
>> >decisions that may be made as a result of using
>this
>> >indicator. You assume full responsibilty when using
>this
>> >indicator. I am giving this indicator to you at no
>cost.
>> >Assume that it is worth what you paid for it.
>> >
>> >Regards,
>> >Tim
>> >
>> >INDICATOR:
>> >
>> >
>> >
>> >SqW:=Input("Square Width (Days)",4,256,64);
>> >MM:=Input("Start Date Month",1,12,10);
>> >DD:=Input("Start Date Day  ",1,31, 5);
>> >YY:=Input("Start Date Year ",1700,2100,1998);
>> >
>> >T0:=LastValue(ValueWhen(1,DayOfMonth()=DD AND
>> >                          Month()=MM      AND
>> >                          Year()=YY,Cum(1)));
>> >
>> >Sqrs:=Int((LastValue(Cum(1))-T0)/SqW)-1;
>> >
>> >S0:=T0+(Sqrs*SqW);
>> >
>> >Lo:=LastValue(ValueWhen(1,Cum(1)=S0+SqW-1,
>> >                          LLV(Min(H,L),SqW)));
>> >
>> >Hi:=LastValue(ValueWhen(1,Cum(1)=S0+SqW-1,
>> >                          HHV(Max(H,L),SqW)));
>> >
>> >Sf:=
>> >If(Hi>25,If(Log(0.4*Hi)/Log(10)-
>> >         Int(Log(0.4*Hi)/Log(10))>0,
>> >Exp(Log(10)*(Int(Log(0.4*Hi)/Log(10))+1)),
>> >Exp(Log(10)*(Int(Log(0.4*Hi)/Log(10))))),
>> >100*Exp(Log(8)*(Int(Log(0.005*Hi)/Log(8)))));
>> >
>> >N:=
>> >If(Log(Sf/(Hi-Lo))/Log(8)<=0,0,
>> >   If(Frac(Log(Sf/(Hi-Lo))/Log(8))=0,
>> >      Int(Log(Sf/(Hi-Lo))/Log(8)),
>> >      Int(Log(Sf/(Hi-Lo))/Log(8))+1));
>> >
>> >Si:=Sf*Exp(-N*Log(8));
>> >
>> >M:=Int(((1/Log(2))*Log((Hi-Lo)/Si))+.00001);
>> >
>> >I:=Round(((Hi+Lo)*.5)/(Si*Exp((M-1)*Log(2))));
>> >
>> >B:=(I-1)*Si*Exp((M-1)*Log(2));
>> >TT:=(I+1)*Si*Exp((M-1)*Log(2));
>> >
>> >Er:=If(Hi-TT>0.25*(TT-B) OR
>> >       B-Lo>0.25*(TT-B),1,0);
>> >
>> >MM:=If(Er=0,M,If(Er=1 AND M<2,M+1,0));
>> >NN:=If(Er=0,N,If(Er=1 AND M<2,N,N-1));
>> >
>> >Si:=Sf*Exp(-NN*Log(8));
>> >
>> >I:=Round(((Hi+Lo)*.5)/
>> >          (Si*Exp((MM-1)*Log(2))));
>> >
>> >B:=ValueWhen(1,Cum(1)>=S0,
>> >            (I-1)*Si*Exp((MM-1)*Log(2)));
>> >
>> >TT:=ValueWhen(1,Cum(1)>=S0,
>> >             (I+1)*Si*Exp((MM-1)*Log(2)));
>> >
>> >B;
>> >
>> >{L1:=}ValueWhen(1,Cum(1)>=S0,
>> >                B+(0.125*(TT-B)));
>> >
>> >{L2:=}ValueWhen(1,Cum(1)>=S0,
>> >                B+(2.0*(0.125*(TT-B))));
>> >
>> >{L3:=}ValueWhen(1,Cum(1)>=S0,
>> >                B+(3.0*(0.125*(TT-B))));
>> >
>> >{L4:=}ValueWhen(1,Cum(1)>=S0,
>> >                B+(4.0*(0.125*(TT-B))));
>> >
>> >{L5:=}ValueWhen(1,Cum(1)>=S0,
>> >                B+(5.0*(0.125*(TT-B))));
>> >
>> >{L6:=}ValueWhen(1,Cum(1)>=S0,
>> >                B+(6.0*(0.125*(TT-B))));
>> >
>> >{L7:=}ValueWhen(1,Cum(1)>=S0,
>> >                B+(7.0*(0.125*(TT-B))));