logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
fredcom2  
#1 Posted : Thursday, September 14, 2006 1:49:08 AM(UTC)
fredcom2

Rank: Newbie

Groups: Registered, Registered Users
Joined: 8/9/2006(UTC)
Posts: 3

Hi,

I'd like to understand how to use the GV function...

I tried several formulas to implemente, for example, a basic EMA.

With PREV, I've this basic:

alph:=2/(20+1);
mme:=If(Cum(1)=1,C,PREV*(1-alph)+C*alph);
mme

But I didn't find anything well with the GV functions!!!

I tried things like that:


alph:=2/(20+1);
mme:=extfml("gv.setvar","mme",if(cum(1)=1,
ExtFml("Gv.SetVar","mme",C),
ref(ExtFml("Gv.GetVar","mme"),-1)*(1-alph)+C*alph));
mme

Is there a way to do that?

Thanks

fred

mstt  
#2 Posted : Thursday, September 14, 2006 2:53:37 AM(UTC)
mstt

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)

Fred

The GlobalVar DLL (usually shortened to GV.DLL) can help overcome some of MetaStock’s limitations but PREV is not one of them.

In the case of PREV, GV cannot help because the sequence in which MS code must be set out means that there’s no practical way to initialize a GV data array without repeating an unwanted initialization on every subsequent bar (which destroys the previous bars data that one would want to access, I think).

What else would you like to know about GV?

Roy

MetaStock Tips & Tools

fredcom2  
#3 Posted : Thursday, September 14, 2006 4:57:38 AM(UTC)
fredcom2

Rank: Newbie

Groups: Registered, Registered Users
Joined: 8/9/2006(UTC)
Posts: 3

Thanks Roy,

In fact, I'm limited with MS for self-reference formula.

For example, I've this code:

if tendance[ 1 ] = 1 then
extreme = max( extreme[ 1 ], high )

if tmpSAR[1] > low then
tendance = -1
facteur = 0.02
tmpSAR = extreme
extreme = low
else
if extreme > extreme[1] and facteur <0.2 then
facteur = min( 0.2, facteur + 0.02 )
endif
tmpSAR = tmpSAR[1]+facteur*(extreme-tmpSAR[1])
tmpSAR = min(tmpSAR,min(low,low[1]))
endif
elsif tendance[1] = -1 then
extreme = min( extreme[ 1 ], low )

if tmpSAR[1] <high then
tendance = 1
facteur = 0.02
tmpSAR = extreme
extreme = high
else
if extreme < extreme[1] and facteur <0.2 then
facteur = min( 0.2, facteur + 0.02 )
endif
tmpSAR = tmpSAR[1]+facteur*(extreme-tmpSAR[1])
tmpSAR = max(tmpSAR,max(high,high[1]))
endif
else
facteur = 0.02
tmpSAR = low
extreme = high
tendance = 1
endif

tmpSAR[1]

It's a modified parabolic, but it's just for example... As you can see, there are several self-references ( extreme, tmpSAR), and it seems impossible to implement this with MS language.

I can translate this in VisualBasic to use it in Excel, but I'm not able to do the same with MS.

At first sight, I thought that GV.DLL was a way to implement self-referencement, but as you said, there is a problem with repeating initilalisation of a GV variable.

Is there a way to implement this sample in MS?

fred

fredcom2  
#4 Posted : Thursday, September 14, 2006 9:49:24 AM(UTC)
fredcom2

Rank: Newbie

Groups: Registered, Registered Users
Joined: 8/9/2006(UTC)
Posts: 3

I've an other example of self-referencing...

I found it in Technical Analysis of Stock of Commodities - january 2006.

The indicator is called "Swiss Army Knife" and has been designed by John Elhers.

So the final code of the indicator is (in easylanguage, but there is the equivalent for WealthLab, Amibroker, esignal,...) :

Filt= c0*(b0*Price + b1*Price[1]+b2*Price[2]) + a1*Filt[1] + a2*Filt[2] - c1*Price[ N]

In MS language, I can code Price[1] --> ref(Price,-1); and Price[ N] --> ref(Price,-N); and Filt[1] --> PREV; but I didn't find a way for Filt[2] ... [:$]

fred

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.