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

Re: [EquisMetaStock Group] EMA indicator code



PureBytes Links

Trading Reference Links

Hi Mano


Here are my versions of these indicators. The critical aspect of getting these formulas to plot correctly in the early bars is "seeding", i.e. the starting value used. An EMA starts from the target data array on bar one. Wilders Smoothing starts with the equivalent Simple Moving Average on bar "N", where "N" is periods.

{Exponential Moving Average}
N:=Input("Periods",1,999,3);  
R:=2/(N+1); 
If(Cum(1)=1,C,PREV*(1-R)+C*R);

{Wilders Smoothing}
N:=Input("Periods",1,99,15);  
R:=1/N;
If(Cum(1)<=N,Mov(C,N,S),PREV*(1-R)+C*R);
 

Regards

Roy
www.metastocktips.co.nz


----- Original Message ----- 
From: mano.rm 
To: equismetastock@xxxxxxxxxxxxxxx 
Sent: Sunday, March 26, 2006 9:30 PM
Subject: [EquisMetaStock Group] EMA indicator code


Hi,

I'm reinventing the wheel trying to develop an EMA indicator identical
to that used in Metastock.

Now the indicator code below almost works, but when compared to a
default Mov(P,Periods,E) plot it does not plot/calc exactly the same
at the start of the data array but given about 3*Period the values end
up identical. For all intents and purposes with enough data I'll get
the same results, but I would like to get the calc perfect.

So far I have the developed the ffg:

{Metastock exponential moving average}
Periods := Input("Time Periods",1,1000,3);
Constant:= 2/(Periods+1);
MEMA := If(Cum(1) = Periods,
(Ref(Mov(P,Periods-1,S),-1)*Constant)+Constant*P, If(Cum(1) = Periods
+1,(P*Constant)+Mov(P,Periods,S)*(1-Constant), PREV + Constant * (P -
PREV)));
MEMA;

My problem appears to be with what code to put after the first If, or
if that bit is correct then how to feed the value from there into the
2nd If statement or how to do everything differently and simply
achieve the Metastock identical end result.

The method behind this madness is once I have EMA worked out then to
simply change

Constant:=1/Periods;

This I hope will give me the formula Metastock uses for Wilders
smoothing, i.e. its function Wilders()

Is seems to but obviously because of the error at the beginning of my
code it takes some periods to plot correctly

Why all this you may ask. Nothing to do with Metastock except for my
own interest in how to do it there. Omnitrader Pro doesn't have a
Wilder's smoothing indicator so once I can do all the maths correctly
in Metastock I'm hopeful I can programme it elsewhere too. Of course I
don't have a Cum() or PREV function there either but with a For Next
or Do Until or Do While loop in OT/VB code I'm hoping to achieve this
functionality. If none of that works then its return to sender and
demand my $ back.

Can anyone suggest some code corrections/pointers.

Thanks









--------------------------------------------------------------------------------
YAHOO! GROUPS LINKS 

  a..  Visit your group "equismetastock" on the web.
    
  b..  To unsubscribe from this group, send an email to:
   equismetastock-unsubscribe@xxxxxxxxxxxxxxx
    
  c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


--------------------------------------------------------------------------------



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/