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

Re: EasyLanguage to Metastock conversion



PureBytes Links

Trading Reference Links

Jeff,

Could this be a case of single precision mangling?  I know there was a discussion on this list
several months ago about how Metastock handles precision in calculations.  By using PREV we are
compounding the issue every time we multiply it.  Perhaps changing every variable to double
precision just for comparison's sake will produce a closer number.

Dave
--- Jeff Haferman <haferman@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> Dave,
> Thanks, I tried your code in MS 6.52, and it plots, but
> does not seem correct.  The original EasyLanguage code is:
> 
>  Value1 = Close + 0.088*Value1[6];
>  Value2 = Value1 - Value1[6] + 1.2*Value2[6] - 0.7*Value2[12];
>  D = Value2[12] - 2*Value2[6] + Value2;
>  Plot1(D,"D");
> 
> So I modified yours to read
>   Value1:=0.088*Ref(PREV,-6)+CLOSE;
>   Value2:=(1.2*Ref(PREV,-6))-(0.7*Ref(PREV,-12));
>   V3:=ROC(Value1,6,$)+Value2;
>   D:=Ref(V3,-12)-2*Ref(V3,-6)+V3;
>   D;
> 
> This seems like it's correct, and it does plot, but I don't
> have any EasyLanguage numbers to compare to.  I wrote up
> a C program to perform the computation, and the shape of
> the resulting plot seems identical to what metastock gives,
> but the actual numbers are off.  Your line of thinking
> seems to me to be correct, however.  I'll try to do
> some more verfication.
> 
> Jeff
> 
> 
> Dave Nadeau wrote:
> >Try this one out:
> >
> >Value1:=0.88*Ref(PREV,-6)+Close;
> >Value2:=(1.2*Ref(PREV,-6))-(0.7*Ref(PREV,-12));
> >ROC(Value1,6,$)+Value2
> >
> >--------------------------------------
> >I can get away with the last statement because
> >ROC(Value1,6,$)=Value1-Ref(Value1,-6)
> >
> >The above plots on Metastock Pro 7.03.  
> >
> >Dave Nadeau
> >Fort Collins, CO
> >
> >3/5/2001 3:19:56 PM, "Brooke" <brookelise@xxxxxxxx> wrote:
> >
> >>Corey:
> >>
> >>I don't think that'll do the job, because the formulas are self-referential,
> >>or recursive. Did you get values with it? If so, you're working with a later
> >>version of Metastock than I am.
> >>
> >>I would have thought that you'd need to use PREV. I don't get anything with
> >>this in Metastock, for example:
> >>
> >>Value1:=Ref(Value1,-1) + C;
> >>Value1;
> >>
> >>What that formula would be trying to say is:
> >>
> >>Value1:=PREV +C;
> >>Value1;
> >>
> >>The first line in the formula would be this, I think:
> >>
> >>Value1:=0.088*ref(PREV,-6) +C;
> >>
> >>But the Easy Language formula requires two PREV's in this line:
> >>
> >>Value2 = Value1 - Value1[6] + 1.2*Value2[6] - 0.7*Value2[12];
> >>
> >>It might be translated as:
> >>
> >>Value2:= 1.2*ref(PREV,-6) - 0.7*ref(PREV,-12) + Value1 - ref(Value1,-6) ;
> >>
> >>Except that
> >>
> >>a) PREV now refers back to the other PREV in the line, I think, and
> >>
> >>b) I get an "Add Overflow" message with that formula.
> >>
> >>So it would have to be broken down in some way so that there was only one
> >>PREV in the line.
> >>
> >>Something like this, though this still won't do it. I'd have to have an
> >>EasyLanguage program to compare values.
> >>
> >>Value1:=0.088*ref(PREV,-6) +C;
> >>Value2a:= 1.2*ref(PREV,-6)+ (Value1 - ref(Value1,-6)) ;
> >>Value2b:= 0.7*ref(PREV,-12)+(Value1 - ref(Value1,-6)) ;
> >>Value2:=Value2a +Value2b;
> >>
> >>But who knows? Maybe I'm wrong, and newer versions of Metastock can do
> >>recursive formulas without PREV.
> >>
> >>----- Original Message -----
> >>From: "C.S." <csaxe@xxxxxxxxxxx>
> >>To: <metastock@xxxxxxxxxxxxx>
> >>Sent: Monday, March 05, 2001 4:55 PM
> >>Subject: Re: EasyLanguage to Metastock conversion
> >>
> >>
> >>> OK,
> >>>     I'll take a stab at this. Please chime in if I'm wrong, as I can learn
> >>> from this too.
> >>>
> >>> Value1:=C + 0.088 * Ref(Value1,-6);
> >>> Value2:=Value1 - Ref(Value1,-6) + 1.2*Ref(Value2,-6) -
> >>0.7*Ref(Value2,-12);
> >>> Ref(Value2,-12) - 2*Ref(Value2,-6) + Value2
> >>>
> >>> Although the PREV function could have been used, I didn't because it tends
> >>> to slow computation.
> >>> -Corey
> >>>
> >>> ----- Original Message -----
> >>> From: "Jeff Haferman" <haferman@xxxxxxxxxxxxxxxxxxxxxxx>
> >>> To: <metastock@xxxxxxxxxxxxx>
> >>> Sent: Sunday, March 04, 2001 5:03 PM
> >>> Subject: EasyLanguage to Metastock conversion
> >>>
> >>>
> >>> >
> >>> > I've got some code I'm trying to convert to Metastock...
> >>> > it's written in EasyLanguage.
> >>> >
> >>> > I've got:
> >>> >
> >>> > Value1 = Close + 0.088*Value1[6];
> >>> > Value2 = Value1 - Value1[6] + 1.2*Value2[6] - 0.7*Value2[12];
> >>> > D = Value2[12] - 2*Value2[6] + Value2;
> >>> > Plot1(D,"D");
> >>> >
> >>> > Is there an easy way to write this as a Metastock indicator?
> >>> > For example, Value1[6] means the value of Value1 6 bars ago.
> >>> > But Value1 is defined recursively, so I'm not sure
> >>> > how this can be done in Metastock.
> >>> >
> >>> >


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/