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

RE: [EquisMetaStock Group] Re: Coding problem



PureBytes Links

Trading Reference Links

So by extension I can create the following, truly ugly 12 PREV piece of code
to project the 9-bar centered triangular average up to the current bar. 

{9 bar projected centered triangular average , thanks to Jose and Roy}

P1:=9;
MA:=Mov(C,P1,TRI);
Shift:=Round(p1/2);
center:=LastValue(Shift);
CMA:=Ref(MA,center);
y:=LastValue(CMA+PREV-PREV);
CMA:=If(y>0,y,C);
CMA1:=Ref(Mov(C,P1-1,TRI),center-1);
y:=LastValue(CMA1+PREV-PREV);
CMA1:=If(y>0,y,C);
CMA2:=Ref(Mov(C,P1-2,TRI),center-2);
y:=LastValue(CMA2+PREV-PREV);
CMA2:=If(y>0,y,C);
CMA3:=Ref(Mov(C,P1-3,TRI),center-3);
y:=LastValue(CMA3+PREV-PREV);
CMA3:=If(y>0,y,C);
CMA4:=Ref(Mov(C,P1-4,TRI),center-4);
y:=LastValue(CMA4+PREV-PREV);
CMA4:=If(y>0,y,C);
CMA5:=Ref(Mov(C,P1-5,TRI),center-5);
y:=LastValue(CMA5+PREV-PREV);
CMA5:=If(y>0,y,C);

CMAP:=
If(Cum(1)=LastValue(Cum(1)-center+1),CMA1,
If(Cum(1)=LastValue(Cum(1)-center+2),CMA2,
If(Cum(1)=LastValue(Cum(1)-center+3),CMA3,
If(Cum(1)=LastValue(Cum(1)-center+4),CMA4,
If(Cum(1)=LastValue(Cum(1)-center+5),CMA5,CMA)))));CMAP;

I can then use the same technique to eyeball other projection methods.

Thanks again, guys.
Andrew


-----Original Message-----
From: equismetastock@xxxxxxxxxxxxxxx [mailto:equismetastock@xxxxxxxxxxxxxxx]
On Behalf Of Andrew Tomlinson
Sent: Wednesday, May 25, 2005 3:27 PM
To: equismetastock@xxxxxxxxxxxxxxx
Subject: RE: [EquisMetaStock Group] Re: Coding problem



Thanks guys - I'd forgotten the LastValue(x+PREV-PREV)fix - I think the last
time I saw it was in the Equis DCF formula (isn't desktop google
wonderful...)

Name: Distant Coefficient Ehlers Filter
Formula:
ti:= 15;
pr:= MP(); coef:=Sum(Power(Ref(LastValue(pr+PREV-PREV)-pr,-1),2),ti);
Sum(coef*pr,ti)/Sum(coef,ti)

Not exactly system friendly, but it may solve the problem. I'm working on
it.

Best
Andrew

-----Original Message-----
From: equismetastock@xxxxxxxxxxxxxxx [mailto:equismetastock@xxxxxxxxxxxxxxx]
On Behalf Of Jose Silva
Sent: Wednesday, May 25, 2005 2:27 PM
To: equismetastock@xxxxxxxxxxxxxxx
Subject: [EquisMetaStock Group] Re: Coding problem


Andrew, here's one way to get around the MetaStock null (or N/A) 
limitation introduced by the forward-plotting Ref(x,+y) function:


===========
Centered MA
===========
---8<--------------------

{ http://www.metastocktools.com }

pds:=Input("MA periods",1,260,9);
type:=Input("MA type:  [1]SMA,  [2]EMA",1,2,1);

sma:=If(type=1,Mov(C,pds,S),Mov(C,pds,E));
center:=LastValue(Int(pds/2));

x:=Ref(sma,center);
y:=LastValue(x+PREV-PREV);

If(y>0,y,C)

---8<--------------------


jose '-)
http://www.metastocktools.com



--- In equismetastock@xxxxxxxxxxxxxxx, "Andrew Tomlinson" 
<andrew_tomlinson@xxxx> wrote:
> Hi guys,
> 
> I am playing with a number of different ways of projecting a centered
> moving average up to the current bar. For example, here I have a 9-day 
> moving average which is centered and therefore plots 5 days prior 
> (i.e. the value for a particular bar is the SMA that would normally 
> plot 5 bars later). In> this case I am trying to continue the line 
> plot using the result of successively shorter centered moving 
> averages.
> 
> The problem is that the following just plots the original centered
> moving average (CMA). If I replace the CMA1, CMA2...etc. in the CMAP 
> code with numbers, they all plot, so the basic mechanism seems ok. I 
> suspect I'm making some kind of elementary mistake - can anyone see 
> what I'm missing?
> 
> (I know there are forward references - try coding a centered MA
> without)
> 
> P1:=Input("Odd # of bars:",1,1001,9);
> MA:=Mov(C,P1,S);
> CMA:=Ref(MA,(p1+1)/2);
> CMA1:=Ref(Mov(C,P1-1,S),(p1+1)/2-1);
> CMA2:=Ref(Mov(C,P1-2,S),(p1+1)/2-2);
> CMA3:=Ref(Mov(C,P1-3,S),(p1+1)/2-3);
> CMA4:=Ref(Mov(C,P1-4,S),(p1+1)/2-4);
> CMA5:=Ref(Mov(C,P1-5,S),(p1+1)/2-5);
> 
> CMAP:=
> If(Cum(1)=LastValue(Cum(1)-(p1+1)/2+1),CMA1,
> If(Cum(1)=LastValue(Cum(1)-(p1+1)/2+2),CMA2,
> If(Cum(1)=LastValue(Cum(1)-(p1+1)/2+3),CMA3,
> If(Cum(1)=LastValue(Cum(1)-(p1+1)/2+4),CMA4,
> If(Cum(1)=LastValue(Cum(1)-(p1+1)/2+5),CMA5,CMA)))));CMAP;
> 
> Best
> Andrew





 
Yahoo! Groups Links



 








 
Yahoo! Groups Links



 






------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/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/