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

Re: [amibroker] Re: Slow Stochastic moving buy-sell levels



PureBytes Links

Trading Reference Links


Hello,
 
One more thing - if you want to take a look at the 
low-level implementation
of EMA please check out <A 
href="">http://www.amibroker.com/docs/ab400.html
(Indicator example in JScript )
 
Best regards,
Tomasz Janeczko
amibroker.com
 
PS.

a) Indicator example - Exponential moving average:

EnableScript("jscript");<%close = VBArray( AFL( "close" ) 
).toArray();
output = new Array();
// initialize first elementoutput[ 0 ] = close[ 0 ];
// perform the loop that calculates exponential moving 
averagefactor = 0.05;for( i = 1; i < close.length; i++ 
){output[ i ] = factor * close[ i ] + (1 - factor) * output[ i - 1 
];}
AFL.Var("graph0") = close;AFL.Var("graph1") = 
output;
%>WriteVal( graph1 );
----- Original Message ----- 
<BLOCKQUOTE 
>
<DIV 
>From: 
Anthony Faragasso 

To: <A 
href="" 
title=amibroker@xxxxxxxxxxxxxxx>amibroker@xxxxxxxxxxxxxxx 
Sent: Monday, November 12, 2001 1:15 
PM
Subject: Re: [amibroker] Re: Slow 
Stochastic moving buy-sell levels
Tomasz; 
See the Attached Image, There seems to be some Difference, that is whyI 
questioned. When I placed the formula under your explanation, they appearto 
be the same. 
This is an 8 period EMA of the Close. graph0=EMA(c,8);  <FONT 
face=Arial>ema_today = factor * close + ( 1 - factor ) * 
ema_yesterday.   value1   
=(Smooth*Close)+(Decay*EMA.PREV) 
after you find value from above code, do you then continue with... 
graph0=EMA(value1,8); Possibly that is why there is a 
difference in custom EMA and Ami EMA. Because I continued with the above. 
Also, I know there was Discussion , but how do I satisfy the( EMA.Prev) 
Thanks Anthony    Tomasz Janeczko wrote: 


Anthony, <FONT 
face=Arial>This is NOTHING new. I mean EACH exponential moving 
average is calculated this way. <FONT 
size=-1>This Decay factor is in fact the STANDARD way of calculating 
EMA:ema_today = factor * close 
+ ( 1 - factor ) * 
ema_yesterday.                 
=(Smooth*Close)+(Decay*EMA.PREV)   
 your decay factor is 
(1-factor), when factor = 2/(Period+1). <FONT 
face=Arial>This is a STANDARD EMA. There is no magic 
here. AFL built in EMA 
works exactly like this.And as 
I wrote before AMA function that takes factor parameter 
allowsyou to create 
variable-period exponential moving averages that works<FONT 
face=Arial>again with the same 
scheme. Best 
regards,Tomasz 
Janeczko<FONT 
size=-1>amibroker.com  
<BLOCKQUOTE 
>
----- Original Message -----
<DIV 
>From: 
Anthony 
Faragasso
To: <A 
href="" 
title=amibroker@xxxxxxxxxxxxxxx>amibroker@xxxxxxxxxxxxxxx
Sent: Monday, November 12, 2001 12:32 
PM
Subject: Re: [amibroker] Re: Slow 
Stochastic moving buy-sell levels Dimitri; 
Thank you for the reply and direction. 
Question:  Have you heard of applying a Decay Factor to 
Exponential Moving Averages. 
Period(N)              
Smooth                       
Decay      8 
Formulas:             
=2/(Period+1)              
=1-Smooth 
 =(Smooth*Close)+(Decay*EMA.PREV) 
Glossary: 
SMA:n - Simple Moving Average of the last n values. The first 
n-1 value of the average are invalid because there are not enough values 
to produce an answer. EMA:n - Exponential Moving Average 
Period - (n) the number of days in the moving averages.  The 
period may be varied by changing the value in cell R2C6 - the graph and 
the results will change automatically. Smooth - Smoothing 
factor for an exponential moving average. Factor is dreived from the 
period of an equivalent simple moving average needed to achieve the same 
amount of lag. This factor is multiplied by the current source value (SPX 
in this case). Decay - the decay factor is the one's 
complement of the smoothing factor.  This factor is used to weight 
the previous exponential moving average value before they are combined. 
I have completed some code, maybe you could evaluate, to see if this 
warrants any discussion. Your opinions are valued. 
Anthony 
DIMITRIS TSOKAKIS wrote: 
Begin at 5119, 5120 and then at 5161 messages of 
this list. DT --- In amibroker@xxxx, Anthony Faragasso 
<ajf1111@xxxx> wrote: > Hi Dimitri; > > Could 
you explain how you arrived at the Dbuy and Dsell numbers in your 
> formula.Were they produced by doing some optimization, if so, 
could you > supply the optimization. > > 
> /*Slow Stochastic moving buy-sell levels*/ > > 
Dbuy=14; > Dsell=8; > X1=13; > MaxGraph=12; 
> ST3=StochK(X1); > ST33=StochD(X1); > Graph0=ST3; 
> Graph1=ST33; > AVST=MA(StochD(X1),100); > 
Graph9=AVST-Dbuy;Graph10=AVST+Dsell; > 
Graph8=avst;Graph8Style=8;Graph8BarColor=2; > 
Graph9Style=Graph10Style=8; > Graph9BarColor=Graph10BarColor=1; 
> > Thank you. > Anthony 
------------------------ Yahoo! Groups Sponsor 
---------------------~--> Universal Inkjet Refill Kit $29.95 
Refill any ink cartridge for less! Includes black and colorink. 
<A 
href="">http://us.click.yahoo.com/bAmslD/MkNDAA/ySSFAA/dkFolB/TM 
---------------------------------------------------------------------~-> 
    
Your use of Yahoo! Groups is subject to <A 
href="">http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service. 



/* Custom Exponential Moving Average */ /* with Decay Factor, 
coded by Anthony Faragasso*/ 
MaxGraph=8; 
pds=10; /* Custom EMA periods,and EMA standard, you can change period*/ 
pds2=10;/* Simple MA periods , you can change period*/ 
Smooth=(2/(pds+1)); Decay=(1-smooth); 
/* set the P variable: O,H,L,C , your average can be on any price 
variable */ P=C; 
P1=p; Avg2=(Smooth*p)+(Decay*p1);/* this line should read 
(smooth*p)+(decay*ema.prev)*/ 
Avg3=EMA(Avg2,pds); 
Avg4=(Smooth*p)+(Decay*Ref(Avg3,-1));/* have I satisfied that line 
Here*/ 
Graph0=EMA(Avg4,pds); Graph0Color=6; Graph0Style=1; /* blue 
line , Custom EMA with Decay*/ 
Graph2=C; Graph2Style=128; 
Graph3=MA(p,pds2); Graph3Color=4; /*red line , Simple MA */ 
Graph4=EMA(p,pds); Graph4Color=2; /* white line , EMA standard */ 
Title=Name()+"   Custom EMA with Decay :Blue 
"+"("+WriteVal(Graph0,format=1.2)+")"+"  EMA 
:White"+"("+WriteVal(Graph4,format=1.2)+")"+"  Simple MA :Red 
"+"("+WriteVal(Graph3,format=1.2)+")"+"  Close 
:"+"("+WriteVal(Graph2,format=1.2)+")";
Your use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of 
Service.





<IMG 
src="">