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

Notification

Icon
Error

2 Pages12>
Options
Go to last post Go to first unread
carriolan  
#1 Posted : Monday, November 8, 2004 11:54:21 AM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Hi, I am trying to build a custom indicator of the above using a modified moving average does anyone have the formula please? -- Carriolan
Patrick  
#2 Posted : Monday, November 8, 2004 2:16:57 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Hi Carrolian, You should try this formula : var1:=Mov(C,8.3896,E)-Mov(C,17.5185,E); DiNapoli:=Mov(var1,9.0503,E); (2*Mov(DiNapoli,21,E))-Mov(Mov(DiNapoli,21,E),21,E) Replace the 21's in the last line to adjust the time period and the E's of that same line to change from Exponential to Simple - S. Hope this helps
carriolan  
#3 Posted : Monday, November 8, 2004 2:32:10 PM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Hi Patrick Thanks for the formula, however the moving averaged used should be a 'modified' moving average. Do you know the formula for this? -- Carriolan
Patrick  
#4 Posted : Tuesday, November 9, 2004 10:44:08 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Sorry for not replying earlier, I have been quite busy. We could create a modified average the problem is that to be able to help you I need to know what specific time period you want to use. Since I will have to write each line of code we might run into a size limit problem. Anyways, let me know what time period you would like to use.
carriolan  
#5 Posted : Wednesday, November 10, 2004 9:14:11 AM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Hi Patrick - No problem. I'm just grateful for the help. The exponential inputs are period of 8, 17 and 9. Thanks. -- Carriolan
carriolan  
#6 Posted : Wednesday, November 10, 2004 9:32:11 AM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Hi, I have been scouring the web and have come up with these formulas - hope they help: THE MODIFIED MOVING AVERAGE (MAV) MAVt=MAVt - 1 + (Pt-MAVt - 1)/n where: MAVt is the current modified Moving Average value is the previous modified Moving Average value P, is the current price n is the number of "periods " MACD FORMULA EMA1t = EMA1t-1 + SFl(Pt-EMA1t-1 ) EMA2t = EMA2t-1 + SF2(Pt-EMA2t-1 ) MACD - EMA1-EMA2 SIGNAL LINE = MACDt-1 + SLSF(MACDt-MACDt-1 ) where: EMA It & EMA2t are the two exponential Moving Averages current values. EMAlt - 1 & EMA2t-1 are the previous values for these EMA SFI & SF2 are the smoothing factors for EMAIt & EMA2t, MACD, is the current MACD value MACDt-1 is the previous MACD value SLSF is the signal line smoothing factor Pt is the current price -- Carriolan
Patrick  
#7 Posted : Wednesday, November 10, 2004 11:30:08 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
I was working on the modified average and here is what I came up with. Unfortunately that does not seem to match with the codes you sent me. I will post this for now and I will look at the code you gave me more in details tomorrow. This is all one formula : {Modified Average 8 Exponential} MA8EP:=8; MA8ET:=Mov(C,MA8EP,E); MA8ES:= ((MA8EP-1)/2)*C+((MA8EP-3)/2)*Ref(C,-1)+((MA8EP-5)/2)*Ref(C,-2)+((MA8EP-7)/2)*Ref(C,-3)+((MA8EP-9)/2)*Ref(C,-4)+((MA8EP-11)/2)*Ref(C,-5)+((MA8EP-13)/2)*Ref(C,-6)+((MA8EP-15)/2)*Ref(C,-7);MA8EPF:=MA8ET+(6*MA8ES)/((MA8EP+1)*MA8EP); {Modified Average 17 Exponential} MA17EP:=17; MA17ET:=Mov(C,MA17EP,E); MA17ES:= ((MA17EP-1)/2)*C+((MA17EP-3)/2)*Ref(C,-1)+((MA17EP-5)/2)*Ref(C,-2)+((MA17EP-7)/2)*Ref(C,-3)+((MA17EP-9)/2)*Ref(C,-4) +((MA17EP-11)/2)*Ref(C,-5)+((MA17EP-13)/2)*Ref(C,-6) +((MA17EP-15)/2)*Ref(C,-7)+((MA17EP-17)/2)*Ref(C,-8)+((MA17EP-19)/2)*Ref(C,-9)+((MA17EP-21)/2)*Ref(C,-10)+((MA17EP-23)/2)*Ref(C,-11)+((MA17EP-25)/2)*Ref(C,-12)+((MA17EP-27)/2)*Ref(C,-13)+((MA17EP-29)/2)*Ref(C,-14)+((MA17EP-31)/2)*Ref(C,-15)+((MA17EP-33)/2)*Ref(C,-16); MA17EPF:=MA17ET+(6*MA17ES)/((MA17EP+1)*MA17EP); {MACD Calculation using Modified Average} MMACDP:=9; MMACDT:=Mov(MA8EPF-MA17EPF,MMACDP,E); MMACDS:= ((MMACDP-1)/2)*(MA8EPF-MA17EPF) +((MMACDP-3)/2)*Ref((MA8EPF-MA17EPF),-1)+((MMACDP-5)/2)*Ref((MA8EPF-MA17EPF),-2)+((MMACDP-7)/2)*Ref((MA8EPF-MA17EPF),-3)+((MMACDP-9)/2)*Ref((MA8EPF-MA17EPF),-4)+((MMACDP-11)/2)*Ref((MA8EPF-MA17EPF),-5)+((MMACDP-13)/2)*Ref((MA8EPF-MA17EPF),-6)+((MMACDP-15)/2)*Ref((MA8EPF-MA17EPF),-7)+((MMACDP-17)/2)*Ref((MA8EPF-MA17EPF),-8); {Indicator Final Code} MMACDT+(6*MMACDS)/((MMACDP+1)*MMACDP)
carriolan  
#8 Posted : Thursday, November 11, 2004 3:07:03 PM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Hi Patrick - just got back from work - will get my head around your formula tonight - thanks. -- Carriolan
henry1224  
#9 Posted : Friday, November 12, 2004 1:10:08 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
the use of decimals in Moving averages is redundant in Metastock var1:=Mov(C,8.3896,E)-Mov(C,17.5185,E); DiNapoli:=Mov(var1,9.0503,E); (2*Mov(DiNapoli,21,E))-Mov(Mov(DiNapoli,21,E),21,E) will plot the same as var1:=Mov(C,8,E)-Mov(C,17,E); DiNapoli:=Mov(var1,9,E); (2*Mov(DiNapoli,21,E))-Mov(Mov(DiNapoli,21,E),21,E)
Patrick  
#10 Posted : Friday, November 12, 2004 5:24:20 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Henry1224 : I had this formula in my system I only copied and pasted it. :wink: But you are right :oops: carriolan: I forgot to include the signal line in the previous indicator but I guess I will wait for your comments before doing anything else :)
pumrysh  
#11 Posted : Friday, November 12, 2004 5:36:37 PM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

carriolan, Couldn't help but interject a few points here. You asked for a DiNapoli DEMA Smoothed MACD formula. To better understand I thought maybe an explanation of DEMA and MACD would be useful. DEMA is a unique smoothing indicator developed by Patrick Mulloy. It was originally introduced in the February 1994 issue of Technical Analysis of Stocks & Commodities magazine. As Mr. Mulloy explains in the article: "Moving averages have a detrimental lag time that increases as the moving average length increases. The solution is a modified version of exponential smoothing with less lag time." DEMA is an acronym that stands for Double Exponential Moving Average. However, the name of this smoothing technique is a bit misleading in that it is not simply a moving average of a moving average. It is a unique composite of a single exponential moving average and a double exponential moving average that provides less lag than either of the two components individually. {21 Day DEMA} (2*Mov(C,21,E))-Mov(Mov(C,21,E),21,E) or Dema(Data Array, Periods) The Moving Average Convergence/Divergence indicator (MACD) is calculated by subtracting the value of a 0.075 (26-period) exponential moving average from a 0.15 (12-period) exponential moving average. A 9-period dotted exponential moving average (the "signal line") is automatically displayed on top of the MACD indicator line. {MACD} mov( close, 12, E) - mov( close, 26, E) or in simple metastock lanquage macd() The MACD's trigger (which is a 9-day exponential moving average of the MACD indicator) can be calculated as shown below: mov( macd(), 9, E) The formula you provided for the Dinapoli Dema Smoothed MACD was: MACD FORMULA EMA1t = EMA1t-1 + SFl(Pt-EMA1t-1 ) EMA2t = EMA2t-1 + SF2(Pt-EMA2t-1 ) MACD - EMA1-EMA2 SIGNAL LINE = MACDt-1 + SLSF(MACDt-MACDt-1 ) Let's now ask what makes DiNapoli what it is. Is it the smoothing periods of 8, 17 and 9 or is it more a matter of when the smoothing occurs? From the fromula that you provided it appears that the MACD and its signal are dema smoothed so let's assume that it is both. We can write the 8 day dema as (2*Mov(C,8,E))-Mov(Mov(C,8,E),8,E) or Dema(Close,8) I like the latter but the choice is really up to you. Our fromula thus becomes: {DiNapoli DEMA Smoothed MACD} Dinap:= Dema(close,8) - Dema(close,17); Signal:= Dema(Dinap,9); Dinap;Signal; {end} Hope this helps, Preston
pumrysh  
#12 Posted : Friday, November 12, 2004 5:43:34 PM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

Sorry, Should have turned off those happy little guys! The last lines should be: Dema(Close,8) I like the latter but the choice is really up to you. Our fromula thus becomes: {DiNapoli DEMA Smoothed MACD} Dinap:= Dema(close,8) - Dema(close,17); Signal:= Dema(Dinap,9); Dinap;Signal; {end}
Patrick  
#13 Posted : Tuesday, November 16, 2004 5:58:20 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
[quote=modified" moving average. Carrolian can you confirm that you do want to use Modified averages ?
pumrysh  
#14 Posted : Tuesday, November 16, 2004 6:56:47 PM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

Patrick, You are right. The subject was A Dema Smoothed Macd which is what I posted and as you point out it does not use the modified moving average. Once again let me muddy the water a bit more by noting that the modified moving average looks very much like another popular indicator. I'll post them below. In the meantime guess we'll have to wait on carriolin's reply. Preston THE MODIFIED MOVING AVERAGE (MAV) MAVt=MAVt - 1 + (Pt-MAVt - 1)/n where: MAVt is the current modified Moving Average value is the previous modified Moving Average value P, is the current price n is the number of "periods " {Moving Average - 10 Day/Zero Lag} N:=10; TN:=Mov(CLOSE,N,S); s1:=((n-1)/2) * C+((n-3)/2) * Ref(C,-1)+((n-5)/2) * Ref(C,-2)+((n-7)/2) * Ref(C,-3)+((n-9)/2) * Ref(C,-4)+((n-11)/2) * Ref(C,-5)+((n-13)/2) * Ref(C,-6)+((n-15)/2) * Ref(C,-7)+((n-17)/2) * Ref(C,-8)+((n-19)/2) * Ref(C,-9); y2:=TN+(6*S1)/((n+1)*n); y2{end} {Zero Lag EMA} Period:= Input("What Period",1,250,10); EMA1:= Mov(P,Period,E); EMA2:= Mov(EMA1,Period,E); Difference:= EMA1 - EMA2; ZeroLagEMA:= EMA1 + Difference; ZeroLagEMA {end}
carriolan  
#15 Posted : Tuesday, November 23, 2004 6:36:42 PM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Apologies guys fell down a black hole! Thanks for all your help. This is where I think I have got too. I would very much appreciate your feedback: Modified Moving Average – 8 Day Period MMA8 N:=8; TN8:=Mov(C,N,S); s8:=((n-1)/2)* C+((n-3)/2)* Ref(C,-1)+((n-5)/2)* Ref(C,-2)+((n-7)/2)* Ref(C,-3)+((n-9)/2)* Ref(C,-4)+((n-11)/2)* Ref(C,-5)+((n-13)/2)* Ref(C,-6)+((n-15)/2)* Ref(C,-7), MMA8:=TN8+(6*S8)/((n+1)*n); MMA8 Modified Moving Average – 9 Day Period MMA9 N:=9; TN9:=Mov(C,N,S); s9:=((n-1)/2)* C+((n-3)/2)* Ref(C,-1)+((n-5)/2)* Ref(C,-2)+((n-7)/2)* Ref(C,-3)+((n-9)/2)* Ref(C,-4)+((n-11)/2)* Ref(C,-5)+((n-13)/2)* Ref(C,-6)+((n-15)/2)* Ref(C,-7)+((n-17)/2)* Ref(C,-8), MMA9:=TN9+(6*S9)/((n+1)*n); MMA9 Modified Moving Average – 17 Day Period MMA17 N:=17; TN17:=Mov(C,N,S); s17:=((n-1)/2)* C+((n-3)/2)* Ref(C,-1)+((n-5)/2)* Ref(C,-2)+((n-7)/2)* Ref(C,-3)+((n-9)/2)* Ref(C,-4)+((n-11)/2)* Ref(C,-5)+((n-13)/2)* Ref(C,-6)+((n-15)/2)* Ref(C,-7)+((n-17)/2)* Ref(C,-8)+((n-19)/2)* Ref(C,-9)+((n-21)/2)* Ref(C,-10)+((n-23)/2)* Ref(C,-11)+((n-25)/2)* Ref(C,-12)+((n-27)/2)* Ref(C,-13)+((n-29)/2)* Ref(C,-14)+((n-31)/2)* Ref(C,-15)+((n-33)/2)* Ref(C,-16), MMA17:=TN17+(6*S17)/((n+1)*n); MMA17 Substituting the above into this standard MACD formula: Standard MACD shortperiods:=Input("Enter the shorter MOV periods: ",8); longperiods:=Input("Enter the longer MOV periods: ",17); signal:=Input("Enter the number of signal line periods: ",9); MOV(C,shortperiods)-MOV(C,longperiods); MOV(MOV(C,shortperiods,E)-MOV(C,longperiods,E),signal,E) Should give the following: N:=8; TN8:=Mov(C,N,E); s8:=((n-1)/2)* C+((n-3)/2)* Ref(C,-1)+((n-5)/2)* Ref(C,-2)+((n-7)/2)* Ref(C,-3)+((n-9)/2)* Ref(C,-4)+((n-11)/2)* Ref(C,-5)+((n-13)/2)* Ref(C,-6)+((n-15)/2)* Ref(C,-7), MMA8:=TN8+(6*S8)/((n+1)*n); N:=17; TN17:=Mov(C,N,E); s17:=((n-1)/2)* C+((n-3)/2)* Ref(C,-1)+((n-5)/2)* Ref(C,-2)+((n-7)/2)* Ref(C,-3)+((n-9)/2)* Ref(C,-4)+((n-11)/2)* Ref(C,-5)+((n-13)/2)* Ref(C,-6)+((n-15)/2)* Ref(C,-7)+((n-17)/2)* Ref(C,-8)+((n-19)/2)* Ref(C,-9)+((n-21)/2)* Ref(C,-10)+((n-23)/2)* Ref(C,-11)+((n-25)/2)* Ref(C,-12)+((n-27)/2)* Ref(C,-13)+((n-29)/2)* Ref(C,-14)+((n-31)/2)* Ref(C,-15)+((n-33)/2)* Ref(C,-16), MMA17:=TN17+(6*S17)/((n+1)*n); MMA8-MMA17 N:=9; TN9:=Mov((MMA8-MMA17),N,E); s9:=((n-1)/2)* (MMA8-MMA17)+((n-3)/2)* Ref((MMA8-MMA17),-1)+((n-5)/2)* Ref((MMA8-MMA17),-2)+((n-7)/2)* Ref((MMA8-MMA17),-3)+((n-9)/2)* Ref((MMA8-MMA17),-4)+((n-11)/2)* Ref((MMA8-MMA17),-5)+((n-13)/2)* Ref((MMA8-MMA17),-6)+((n-15)/2)* Ref((MMA8-MMA17),-7)+((n-17)/2)* Ref((MMA8-MMA17),-8), MMA9:=TN9+(6*S9)/((n+1)*n); I have the following questions regarding the above: 1. I have made all the formulae exponential even though some people use simple moving averages – Is this correct for a strict interpretation of DiNapoli. 2. Does everyone agree with the logic? 3. Is this syntactically correct (me never having coded an indicator before – probably shows too!)? Ideally I would like to cut and paste it directly into Metastock. For instance should I be using different ‘N’ and ‘n’ in each section? 4. Lastly, pumrysh I do not understand the purpose / necessity for this section of your coding: {Zero Lag EMA} Period:= Input("What Period",1,250,10); EMA1:= Mov(P,Period,E); EMA2:= Mov(EMA1,Period,E); Difference:= EMA1 - EMA2; ZeroLagEMA:= EMA1 + Difference; ZeroLagEMA {end} -- Carriolan
Patrick  
#16 Posted : Tuesday, November 23, 2004 6:55:18 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
1. Since the original formula uses Exponential average, you should also use exponential. My bad :oops: 2. The logic is good. 3. it's wrong but I will write the code below. And I would avoid using the same variable names 4. He was just suggesting that the formula you wanted was similar to the Zero Lag Moving Average and gave you the code for it in case you wanted to take a look at it.
Patrick  
#17 Posted : Tuesday, November 23, 2004 7:05:58 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
N1:=8; TN8:=Mov(C,N1,E); S8:=((n1-1)/2)* C+((n1-3)/2)* Ref(C,-1)+((n1-5)/2)* Ref(C,-2)+((n1-7)/2)* Ref(C,-3)+((n1-9)/2)* Ref(C,-4)+((n1-11)/2)* Ref(C,-5)+((n1-13)/2)* Ref(C,-6)+((n1-15)/2)* Ref(C,-7); MMA8:=TN8+(6*S8)/((n1+1)*n1); N2:=17; TN17:=Mov(C,N2,E); S17:=((n2-1)/2)* C+((n2-3)/2)* Ref(C,-1)+((n2-5)/2)* Ref(C,-2)+((n2-7)/2)* Ref(C,-3)+((n2-9)/2)* Ref(C,-4)+((n2-11)/2)* Ref(C,-5)+((n2-13)/2)* Ref(C,-6)+((n2-15)/2)* Ref(C,-7)+((n2-17)/2)* Ref(C,-8)+((n2-19)/2)* Ref(C,-9)+((n2-21)/2)* Ref(C,-10)+((n2-23)/2)* Ref(C,-11)+((n2-25)/2)* Ref(C,-12)+((n2-27)/2)* Ref(C,-13)+((n2-29)/2)* Ref(C,-14)+((n2-31)/2)* Ref(C,-15)+((n2-33)/2)* Ref(C,-16); MMA17:=TN17+(6*S17)/((n2+1)*n2); VALUE:=MMA8-MMA17 ; n3:=9; TN9:=Mov((VALUE),n3,E); s9:=((n3-1)/2)* (VALUE)+((n3-3)/2)* Ref((VALUE),-1)+((n3-5)/2)* Ref((VALUE),-2)+((n3-7)/2)* Ref((VALUE),-3)+((n3-9)/2)* Ref((VALUE),-4)+((n3-11)/2)* Ref((VALUE),-5)+((n3-13)/2)* Ref((VALUE),-6)+((n3-15)/2)* Ref((VALUE),-7)+((n3-17)/2)* Ref((VALUE),-8); SIGNAL:=TN9+(6*S9)/((n3+1)*n3); VALUE; SIGNAL You should be able to copy and paste that.
carriolan  
#18 Posted : Tuesday, November 23, 2004 7:37:39 PM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Hi Patrick On reflection it is meant to be a DEMA smoothed MACD using modified moving averages. I do not know whether I have achieved this; the DEMA bit, I mean. -- Carriolan
Patrick  
#19 Posted : Tuesday, November 23, 2004 7:42:19 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
No this is simply a MACD using modified average with DiNapoli's Values
carriolan  
#20 Posted : Tuesday, November 23, 2004 7:43:30 PM(UTC)
carriolan

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/28/2004(UTC)
Posts: 9

Patrick Didn't see that you had already sorted out my coding - thanks -- Carriolan
Users browsing this topic
2 Pages12>
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.