PureBytes Links
Trading Reference Links
|
As a general rule I use loops when
1. Existing AB functions cannot fulfil requirements.
eg use of AMA, Zig, Cum, or ApplyStop functions, or one of the
many others available
2. The current bar value of a variable is calculated using the
previous bar value of that same variable.
eg EMA if that was not already a built in function in AB
3. The value of a variable is determined from a specific occurrence of
a true condition, where that condition can have true values after that
specific occurrence.
eg trail stop value after Buy signal, that is not one of the
existing ApplyStop function possibilities.
This could be one that if could write simply would be
HighestSince( Buy, H - ATR( 10 ) ), but this gets reset by any
subsequent buy signals that you may not want to remove
AB Applystop (ModePoint) currently has 2 possibilities if
my memory is correct, they are
A: Non-Volatile HighestSince( Buy, H ) - ValueWhen(
buy, ATR( 10 ) ); and
B: Volatile HighestSince( Buy, H ) - ATR( 10 );
These bits of code would vary if you have a entry delay after signal.
4. Loop through a set number series that have no direct relation to
bar array identification as normally used in bar loops
eg for( n=1; n<=5; n=n+2 )
5. Probably some others as well, but have written so many cannot
always remember everything.
Hopefully my examples of code above are correct, I just typed them
into here from my poor memory
--
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com
2009/2/20 richpach2 <richpach2@xxxxxxxxx>:
> Hello,
>
> Can some please expain use of loop (if, while etc) expression in AFL?
> When do one need to use a loop and when can one just rely on
> processing of the array bar-by-bar. I am still learining AFL language
> and this area is a bit grey.
>
> I noticed many Stop processing AFL use "for" loop but I don't
> understand why.
> Also, if I can use this statement toi define EMA;
>
> P = ParamField("Price field",-1);
> Periods = Param("Periods", 15, 2, 300, 1, 10 );
> Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
> colorCycle ), ParamStyle("Style") );
>
> why would I try this AFL doc example;
>
> myema[ 0 ] = Close[ 0 ];
> for( i = 1; i < BarCount; i++ )
> {
> myema[ i ] = 0.1 * Close[ i ] + 0.9 * myema[ i - 1 ];
> }
> This example iterates all bars of close array to calculate
> exponential moving average.
>
> Regards
> Richard
>
>
>
> ------------------------------------
>
> **** 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
>
>
>
>
------------------------------------
**** 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:
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/
|