PureBytes Links
Trading Reference Links
|
Owen,
Here is the formula with some changes....Stephane's was not exactly right as to what it should do..from my point of view / indicator description....
This is the first part of the indicator....there will be more added to it..
Anthony
//Optimize Your Moving average
period=Param("period",19,5,28,1);//Higher the period,more lag
Buy=Cross(C,EMA(C,period));
Sell=Cross(EMA(C,period),C) ;
CumCSt=0;
poslong=0;posshort=0;
for (i=1; i<BarCount; i++)
{
if( Buy[i])
{
poslong=1;posshort=0;
}
if(Sell[i])
{
poslong=0;posshort=1;
}
//Rlong[i]=poslong;
//RShort[i]=posshort;
if(poslong==1)
{
if(Buy[i])
CumCSt[i]=2/(period+1);
else
{
if(C[i]>C[i-1])
CumCSt[i]=Cumcst[i-1] + 0.003;
else
CumCSt[i]=Cumcst[i-1];
}
}
else
{
if(Sell[i])
CumCSt[i]=2/(period+1);
else
{
if(L[i]<L[i-1])
CumCSt[i]=Cumcst[i-1] + 0.003;
else
CumCst[i]=Cumcst[i-1];
}
}
if(CumCst[i]>0.13)
CumCst[i]=0.13;
}
Smth=CumCSt;
MovAvg=AMA(C,Smth);
Plot(MovAvg,"Opt_MovAvg",colorBlue,styleLine);
Plot(C,"Close",colorBlack,styleCandle);
Plot(smth,"smth_constant",colorGreen,styleNoLabel|styleNoDraw|styleOwnScale);
PlotShapes(Buy*shapeUpArrow,colorBrightGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Filter=1;
AddColumn(Buy,"buy",1);
AddColumn(Sell,"sell",1);
AddColumn(Cumcst,"cumcst",1.3);
AddColumn(smth,"smth",1.3);
AddColumn(C,"close");
----- Original Message -----
From: Owen Davies
To: amibroker@xxxxxxxxxxxxxxx
Sent: Friday, October 29, 2004 10:16 AM
Subject: Re: [amibroker] Re: Optimizing your Moving average
Anthony Faragasso wrote:
>Thank you Stephane, I made some minor changes to this last formula...it is working as expected.
>I appreciate the help...
>
I just became curious enough to try Stephane's formula. Interestingly
enough, after a convergence period it becomes virtually
indistinguishable from EMA(Val,9).
Owen Davies
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
Get unlimited calls to
U.S./Canada
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
b.. To unsubscribe from this group, send an email to:
amibroker-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 --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|