PureBytes Links
Trading Reference Links
|
While you're at it, you might want to consider declaring variables used within the function as local so that they do not inadvertently overwrite global variables.
e.g.
function Fast_EMA( period ) {
local i;
local EMA_fast;
...
}
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "Markus Witzler" <funnybiz@xxx> wrote:
>
> Thanks, Mike!
>
>
> ----- Original Message -----
> From: Mike
> To: amibroker@xxxxxxxxxxxxxxx
> Sent: Thursday, November 19, 2009 8:26 PM
> Subject: [amibroker] Re: Referencing values of a function and optimizing it
>
>
>
> If you want to reference an element, within the resulting array, outside of the function, then simply assign the result to a variable first.
>
> fast = fast_EMA(period);
> value = fast[i]; // where i is the desired element index
>
> And yes, your usage of Optimize is correct.
>
> Mike
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Markus Witzler" <funnybiz@> wrote:
> >
> > Hello,
> >
> > I designed the following function which creates an exponential moving average:
> >
> > function Fast_EMA( period )
> > {
> > EMA_fast[ 0 ] = close[ 0 ]; seed value is being set
> >
> > for( i = 1; i < BarCount; i++ )
> > {
> > EMA_fast[ i ] =EMA_fast[i-1]+(close[i]-EMA_fast[i-1])*2/(period+1);
> > }
> >
> > return EMA_fast;
> > }
> >
> >
> > Now, when I later want to reference a value of the function, do I use this: EMA_fast[i]
> >
> > And when want to optimize the length of my exp. moving average, do I use this:
> >
> > period=Optimize ("Fast EMA length", 50, 10, 150, 10);
> >
> > fast_EMA( period );
> >
> >
> > Thanks for clarifying
> >
> > Markus
> >
>
>
>
>
>
> __________ Information from ESET Smart Security, version of virus signature database 4623 (20091119) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
amibroker-digest@xxxxxxxxxxxxxxx
amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|