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

Re: [amibroker] Re: Help with an indicator...



PureBytes Links

Trading Reference Links

Hi,

You are right - EMA does not currently supports adaptivity.
But... I am just working on improvements to AFL that will
allow that. I will release soon a new beta that will
feature a new function(s) that will enable adaptive moving averages.

Best regards,
Tomasz Janeczko

----- Original Message ----- 
From: <jmjames@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, March 14, 2001 03:46
Subject: [amibroker] Re: Help with an indicator...


> Tomasz,
> 
> Thanks for your "other point of view" on how to look at the math 
> involved (being an electrical engineer, I should have seen that! :)
> 
> However, I have run into another problem. sc (the smoothing constant 
> here is a moving target....it changes based on the stock's movement 
> (adapative). Below is the entire code:
> 
> fast = 2/(2+1);
> slow = 2/(30+1);
> dir=abs(close-ref(close,-10));
> vol=sum(abs(close-ref(close,-1)),10);
> ER=dir/vol;
> sc =( ER*(fast-slow)+slow)^2;
> graph1=sc;
> x =-1 + round(2/sc);
> AMA = ema(close,x); 
> 
> And the error is:
> 
> AMA = ema(close,round(2/sc))
> ^
> 
> Bad args
> 
> 
> which leds me to believe that this adaptive moving average can not be 
> done. But prehaps you have a better idea on how to get this to work.
> 
> Once again, thanks for all your help, and keep up the great work!! :)
> 
> Regards,
> 
> Jared James
> jjames@xxxx
> 
> --- In amibroker@xxxx, "Tomasz Janeczko" <tjaneczk@xxxx> wrote:
> > Hi,
> > 
> > Sometimes things look more complicated than they should :-)
> > 
> > Your formula:
> > 
> > AMA = ref(AMA,-1)+sc*(close-ref(AMA,-1)); 
> > 
> > Is the same as:
> > 
> > AMA = sc * close + ( 1 - sc ) * Previous( AMA );
> > 
> > This one is in fact the formula for exponential moving average
> > sc is simply smoothing constant = 2 / (periods + 1)
> > 
> > So periods = -1 + 2/sc
> > 
> > So you final AFL code for your AMA is:
> > 
> > AMA = ema( close, -1 + 2/sc ); 
> > 
> > It is not only faster to execute but also does not have any self-
> references.
> > 
> > In AFL you can reference the same variable in the assignment 
> statement 
> > (you must initialize it however):
> > 
> > testvar = 0;
> > testvar = testvar + close;
> > 
> > But... AFL is a vector (or array) based language performing 
> operations on array
> > in one run (that's why it is so fast) - so you can not iterate thru 
> elements
> > of the array. Statements like variable = ref( variable, -1 ) + 
> something 
> > will not work correctly.
> > To overcome this problem functions like cum(), sum(), ema() should 
> be used.
> > 
> > Best regards,
> > Tomasz Janeczko
> > 
> > 
> > ----- Original Message ----- 
> > From: <jmjames@xxxx>
> > To: <amibroker@xxxx>
> > Sent: Tuesday, March 13, 2001 05:34
> > Subject: [amibroker] Help with an indicator...
> > 
> > 
> > > Hi!
> > > 
> > > I have had trouble getting an indicator to work. More specific, 
> I 
> > > have had trouble with the following line:
> > > 
> > > AMA = ref(AMA,-1)+sc*(close-ref(AMA,-1)); 
> > > 
> > > It comes back with an error of:
> > > 
> > > AMA = ref(AMA,
> > > ^
> > > 
> > > Unknown identifier
> > > 
> > > Am I doing something wrong, or will AmiBroker not handel a ref to 
> > > itself?
> > > 
> > > Thank for your time and effort on my questions!!
> > > 
> > > Regards,
> > > 
> > > Jared James
> > > jjames@xxxx
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> > > 
> > >
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
>