Rank:: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/26/2009(UTC) Posts: 76 Location: Toronto, Canada
|
Hi everyone.. is there a way to somehow get around with the issue of using non-constant data for specific data arrays which do require constant data.. if seen that this is feasible with other platforms so it should not be impossible.. Any insight will be helpful.. Thanks
VT
|
|
|
|
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 VT
The use of LastValue(N+PREV-PREV) (as used in the adaptive functions of MS11) will generally give you this capability. However it's a resource-intensive method and not totally accurate . My March special issue of MSTT gives replacement code for around 75% of the adaptive functions, mostly without speed or accuracy issues. I have yet to work though one or two issues with another three or four adaptive functions but already have solutions for many other functions not included in the MS11 adaptive group.
Roy
|
|
|
|
Rank:: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/26/2009(UTC) Posts: 76 Location: Toronto, Canada
|
Thanks Roy, I will try it out.
VT
|
|
|
|
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 VT
Adding a non-PREV variable Periods capability to some functions such as most of those included in the Forum DLL is quite easy. For example, ExtFml("Forum.MOV",Data,Periods,Method) works pretty much as expected when supplied with a variable Periods parameter. However the Aroon function doesn’t get it quite right so assuming "N" is your Periods parameter you might instead try this.
{Aroon Up / Aroon Down}
N:=N+(N=0); {prevents an illegal Periods value of zero}
U:=100*(N-ExtFml("Forum.HHVBars",H, N+1))/N;
D:=100*(N-ExtFml("Forum.LLVBars",L, N+1))/N;
ValueWhen(1,N>0,U); ValueWhen(1,N>0,D);
This code also uses the Forum DLL but not its Aroon function which is "slightly off".
Roy
|
|
|
|
Rank:: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/26/2009(UTC) Posts: 76 Location: Toronto, Canada
|
Thanks Roy. I have this moving average type which uses the square root of the period input. Originally, it gave me a problem with the constant data. After I read your post i substituted it with Lastvalue(rnd(sqrt(pds))+PREV-PREV) and it worked. Then however, I went and removed both PREV functions and it still worked. What are the implications of this? Is it necessary to have the +PREV-PREV? THanks again.
VT
|
|
|
|
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 VT
What's happening here is that your formula takes a constant, presumably a periods value entered via an Input() function, and then converts it to a variable (as far as MetaStock is concerned) when calculating the square root. The LastValue() fction converts the "variable" back to a constant which is why your formula still works when +PREV-PREV is removed.
It doesn't matter where the LastValue() function is applied to the offending variable. It can be in the line that performs the square root or it can be placed inside the Mov() function.
Not only does LastValue() supply the last value of any data array, it also converts any calculated fixed value so that it can be recognised as a constant by MetaStock. Once you perform any calulation on a constant it will be considered as a variable by MetaStock. Perhaps an exception to this is where two constants are added or multiplied - an example being that 10+3 will be trated as a legitimate constant of 13 if used as a Periods parameter in any function.
When LastValue() is used in conjunction with a variable and +PREV-PREV, the PREV component is self-cancelling (zero) but the presence of PREV forces the variable result to be recalculated on every bar, and LastValue() forces that recalculated result to be returned to MetaStock as a "constant", albeit a constant that can change on each bar. As it turns out LastValue(N+PREV-PREV) is not necessary for your formula because N is always the same value and just using LastValue() has the desired effect of making MetaStock accept it as a constant. Where N is a changing or adaptive value you would need to use the +PREV-PREV element for Mov() to accept the "variable" parameter.
Roy
|
|
|
|
Rank:: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/26/2009(UTC) Posts: 76 Location: Toronto, Canada
|
Yes, yes I had a similar thought about why the +PREV-PREV is within but I was not sure. Thanks again for your enormous help.
VT
|
|
|
|
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.