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

[amibroker] Re: Looping Problem using Array Variables



PureBytes Links

Trading Reference Links

Graham,
Thank you for trying to help with this.  I guess I didn't get far 
enough to discover the mixed variable issue in the for statement.  
However, I think that can be easily remedied.  The main problem seems 
to be how to get any loop statement to work using this criteria for 
exiting the loop: Value3 <= 0.002, where Value3 is calculated from 
Array values.

I actually rewrote the code using the "for( i = Start; i < BarCount; 
i++)" approach, but having this loop nested within the main loop 
resulted in a inordinate amount of calculation time (although it did 
produce the desired result).  So, I was hoping that someone has a 
better solution.

The original code that I modified was taken from the S&C Trader's 
Tips - Issue 3, 2005 (the AmiBroker code for Ehler's Median-Average 
Adaptive Filter).  However, that original code deviates slightly from 
the algorithm presented in the S&C magazine article, shown in Easy 
Language format.  The Amibroker code results in a substantially 
different adaptive moving average, so I was hoping to get closer to 
Ehler's version, which determines the Length value used to calculate 
alpha by exiting this loop when Value3 is less than or equal to the 
specified threshold of 0.002.

pakay



--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx> wrote:
> to start with compare the basic statement construction with those in
> the help files
> 
> for( Value3 = 0.2; Value3 > 0.002; Length = Length - 2 )
> This should have the same variable in each part
> you cannot mix Value3 and length, so which one should it be?
> 
> Then insode the loop the variables need to be identified against the
> basic for variable
> 
> Perhaps you should explain what exactly you are trying to achieve 
with
> the code so we can help with creating it
> 
> On 7/4/05, pakaypakay <pakaypakay@xxxx> wrote:
> > Does anyone know how to work around this problem? Since the loop
> > statement does not allow array type variables (Value3), this code
> > will not work.
> > 
> > 
> > Price = ( H + L ) /2;
> > Smooth = (Price + 2 * Ref( Price, -1 ) + 2 * Ref( Price, -2 ) + 
Ref(
> > Price, -3 ) )/6;
> > 
> > 
> > Length = 39;
> > 
> > for( Value3 = 0.2; Value3 > 0.002; Length = Length - 2 )
> > {
> > alpha = 2 / ( Length + 1 );
> > 
> > Value1 = Median( Smooth, Length );
> > Value2 = AMA( Smooth, alpha );
> > 
> > Value3 = Nz( abs( Value1 - Value2 )/Value1 );
> > 
> > }
> > 
> > AvgLength = IIf( Length < 3, 3, Length );
> > AvgAlpha = 2 / (AvgLength + 1);
> > 
> > Filt = AMA( Smooth, AvgAlpha);
> > 
> > Plot( C, "Price", colorBlack, styleBar );
> > Plot( Filt, "Filt", colorRed, styleThick );[/code]
> > 
> > 
> > 
> > 
> > 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 other support material please check also:
> > http://www.amibroker.com/support.html
> > 
> > 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> 
> 
> -- 
> Cheers
> Graham
> http://e-wire.net.au/~eb_kavan/





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 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/

<*> 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/