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

Notification

Icon
Error

Options
Go to last post Go to first unread
Jose  
#1 Posted : Friday, November 11, 2005 10:34:46 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Below is a relatively new type of Exponential Moving Average (EMA), based on price and modulated by price peaks/troughs. Basically, the Pivotal EMA (PEMA) generally hugs the price closer as it approaches market turning points. This can be useful as a possible improvement to the standard EMA in crossover stops. The first PEMA version uses the standard PREV functions to construct the EMA. The second plots much faster thanks to the use of variable-period DLLs. [code:1:3339936fc1] MetaStock -> Tools -> Indicator Builder -> New -> Copy and paste complete formulae between "---8<---" lines. ============= EMA - pivotal ============= ---8<------------------------------------ { Pivotal Exponential Moving Average v1.0 } { PEMA based on trough/peak support/resistance. Options: [1] Composite EMA: (Upper+Lower)/2; [2] Upper EMA band based on peaks; Lower EMA band based on troughs; [3] EMA shifts to Upper/Lower on crossovers } { ©Copyright 2004~2005 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com } { User inputs } pds:=Input("EMA periods",1,2520,21)/2; plot:=Input("EMA: [1]Composite, [2]Upper+Lower, [3]Long/Short",1,3,1); spread:=Input("Upper/Lower EMA bands shift %", 0,100,2)/200; x:=Input("use: [1]Close, [2]High/Low",1,2,1); { Peak/Troughs } xpk:=If(x=1,C,H); pk:=xpk<Ref(xpk,-1) AND Ref(xpk,-1)>Ref(xpk,-2); pkVal:=ValueWhen(1,pk,Ref(xpk,-1)); xtr:=If(x=1,C,L); tr:=xtr>Ref(xtr,-1) AND Ref(xtr,-1)<Ref(xtr,-2); trVal:=ValueWhen(1,tr,Ref(xtr,-1)); { Peak-based EMA } pkpds:=If(pds>Cum(pk),Cum(pk),pds); pkpds:=If(pkpds<1,1,pkpds); pkEma:=pkVal*2/(pkpds+1)+PREV*(1-2/(pkpds+1)); pkEma:=pkEma*(1+spread); { Trough-based EMA } trpds:=If(pds>Cum(tr),Cum(tr),pds); trpds:=If(trpds<1,1,trpds); trEma:=trVal*2/(trpds+1)+PREV*(1-2/(trpds+1)); trEma:=trEma*(1-spread); { Composite EMA } Ema:=(pkEma+trEma)/2; LngShtEma:=If(C>=Ema,trEma,pkEma); { Plot on price chart } If(plot=1,Ema,If(plot=2,trEma,LngShtEma)); If(plot=1,Ema,If(plot=2,pkEma,LngShtEma)) ---8<------------------------------------ [/code:1:3339936fc1] jose '-)
Jose  
#2 Posted : Friday, November 11, 2005 10:39:11 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
As mentioned above, this version of the PEMA plots much faster, thanks to the use of variable-period DLLs which circumvent the very slow PREV functions. [code:1:ef3bb517da] MetaStock -> Tools -> Indicator Builder -> New -> Copy and paste complete formulae between "---8<---" lines. ========================== EMA - pivotal, dll version ========================== ---8<------------------------------------ { Pivotal Exponential Moving Average v.dll - Plots much faster than PREV-based version.} { PEMA based on trough/peak support/resistance. Options: [1] Composite EMA: (Upper+Lower)/2; [2] Upper EMA band based on peaks; Lower EMA band based on troughs; [3] EMA shifts to Upper/Lower on crossovers } { Forum.dll from http://forum.equis.com or ASI.dll from http://www.thedml.com must be in: ...\\MetaStock\\External Function DLLs\\ folder.} { ©Copyright 2004~2005 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com } { User inputs } pds:=Input("EMA periods",1,2520,21)/2; plot:=Input("EMA: [1]Composite, [2]Upper+Lower, [3]Long/Short",1,3,1); spread:=Input("Upper/Lower EMA bands shift %", 0,100,2)/200; x:=Input("use: [1]Close, [2]High/Low",1,2,1); { Peak/Troughs } xpk:=If(x=1,C,H); pk:=xpk<Ref(xpk,-1) AND Ref(xpk,-1)>Ref(xpk,-2); pkVal:=ValueWhen(1,pk,Ref(xpk,-1)); xtr:=If(x=1,C,L); tr:=xtr>Ref(xtr,-1) AND Ref(xtr,-1)<Ref(xtr,-2); trVal:=ValueWhen(1,tr,Ref(xtr,-1)); { Peak-based EMA } pkpds:=If(pds>Cum(pk),Cum(pk),pds); pkpds:=If(pkpds<1,1,pkpds); {pkEma:=ExtFml("Forum.VarMOV",pkVal,pds,e);} pkEma:=ExtFml("ASI.EMA",pkVal,pds); pkEma:=pkEma*(1+spread); { Trough-based EMA } trpds:=If(pds>Cum(tr),Cum(tr),pds); trpds:=If(trpds<1,1,trpds); {trEma:=ExtFml("Forum.VarMOV",trVal,pds,e);} trEma:=ExtFml("ASI.EMA",trVal,pds); trEma:=trEma*(1-spread); { Composite EMA } Ema:=(pkEma+trEma)/2; LngShtEma:=If(C>=Ema,trEma,pkEma); { Plot on price chart } If(plot=1,Ema,If(plot=2,trEma,LngShtEma)); If(plot=1,Ema,If(plot=2,pkEma,LngShtEma)) ---8<------------------------------------ [/code:1:ef3bb517da] jose '-)
George  
#3 Posted : Sunday, November 13, 2005 10:36:14 AM(UTC)
George

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/2/2005(UTC)
Posts: 45
Location: Australia, NSW

Jose, Do I have to have something extra, or Metastock 9 is enough to handle this formula?
Jose  
#4 Posted : Sunday, November 13, 2005 1:29:44 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
George, for the first formula you won't need anything but the standard MetaStock v6.5 and up. For the 2nd and faster version of the pivotal EMA, you will need either of the free DLLs (Forum.dll or ASI.dll) to be placed in your ...\\MetaStock\\External Function DLLs\\ folder, before firing up MetaStock. jose '-)
George  
#5 Posted : Sunday, November 13, 2005 11:37:59 PM(UTC)
George

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/2/2005(UTC)
Posts: 45
Location: Australia, NSW

Jose, is there an easy way to load that extra program and is there anywhere a step by step procedure for the below average computer user? If not I will probably have to use the first version as I fear of doing something wrong while loading extra program.
sportrider  
#6 Posted : Monday, November 14, 2005 12:04:32 AM(UTC)
sportrider

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/12/2005(UTC)
Posts: 141
Location: Brooklyn,NY

Hi George, I feel the same way about the dll's, I really don't understand them and I'm afrid that I will mess somthing up. I hope maybe one day I could put my fears aside.
Jose  
#7 Posted : Monday, November 14, 2005 12:42:16 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
George, SportRider, there is an easier way to install and setup formulae/dll sets into MetaStock, such as automatic setups, but I reserve this process for clients. Anyway, copy & paste of formulae can't do much harm to MetaStock. jose '-)
naren.orbit  
#8 Posted : Thursday, June 2, 2011 11:39:19 AM(UTC)
naren.orbit

Rank: Member

Groups: Registered, Registered Users
Joined: 4/26/2011(UTC)
Posts: 14
Location: india

hi sir, i can't find ASI.dll file.
mstt  
#9 Posted : Thursday, June 2, 2011 1:45:44 PM(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)
Hi Naren I have the DLL and if you write to me at rlarsen@quik.co.nz I'll send you a copy. Roy www.metastocktips.co.nz
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.