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

Re: [amibroker] Re: looping



PureBytes Links

Trading Reference Links

depending on how you want the calculation to default if period becomes
null, try this
   factor = Nz(2/(period[ i ] + 1));

or
   factor = 2/(Nz(period[ i ]) + 1);


you can also set the deafult valu8e of NZ other than zero, see help
files for this


-- 
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com


On 09/09/2007, gp_sydney <gp.investment@xxxxxxxxx> wrote:
> John,
>
> Put a _TRACE statement at the end of your loop (ie. just before the
> closing brace) for variables period[i], factor[i], and Vaexp[i], and
> you will see what the problem is if you look at the output in DebugView.
>
> _TRACE(StrFormat("period = %1.3f, factor = %1.3f, vaexp = %1.3f",
> period[i], factor[i], Vaexp[i]));
>
> Essentially it's an issue of propogating Nulls through the loop, since
> ATR(50) starts off as Null and every operation involving Null gives a
> Null result. Basing the value of Vaexp[i] on Vaexp[i-1] then
> propogates the Null value through the whole array.
>
> Regards,
> GP
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, <jaramdenee-trading@xxx> wrote:
> >
> > Hello,
> >
> > i am trying to teach myself how to use teh looping statements in AFL.
> > So i have used teh code example:
> >
> > _SECTION_BEGIN("Looptest");
> >
> > Period=10*ATR(50);
> >
> > Vaexp[ 0 ] = Close[ 0 ]; // initialise first value
> >
> > for( i = 1; i < BarCount; i++)
> > {
> >     //calculate the value of the smoothing factor
> >     factor = 2/(period[ i ] + 1);
> >
> >     //calculate the value of the i-th element of the array
> >     //using this bars close (close [ i ]) and the previous average
> value ( vaexp{ i - 1])
> >     Vaexp[ i ] = factor * Close[ i ] + (1 - factor) * Vaexp[ i - 1 ];
> > }
> > _SECTION_END();
> >
> > ...
> >
> > now i want to know how i plot VAexp as an indicator on a chart (i am
> getting a few strange outputs with the code i have been trying -
> including using PLOT within the loop. When i use PLOT outside the loop
> i get an empty chart)
> >
> > Think its probably a simple answer, but i cant get to it..
> >
> > J
> >
> >
> >
> > John Ramdenee


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
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:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto: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/