PureBytes Links
Trading Reference Links
|
The following Indicator Builder code will calculate the sqrt(2) in
4143 steps.
y0=0; k0=0;
for(z=1;z<2;z=z+0.0001)
{
if(z^2>2)
{
y0=z;
z=2;
}
k0=k0+1;
}
Title="Sqrt(2)="+WriteVal(y0,1.4)+" [ "+WriteVal(k0,1.0)+" steps]";
z is equal to 1 and has an increment of 0.0001 in every step.
If z^2>2 then
a. the respective z is calculated and
b. the loop is terminated
If z^2<=2, then k0 [the counter] is increased by +1 for every step.
We may have the same result with less steps [faster], but the code
should be more complicated.
Dimitris
--- In amibroker@xxxxxxxxxxxxxxx, "kubikconcepts"
<kubikconcepts@xxxx> wrote:
>
> Hello,
> Can somebody post an example of how to use the for loop in AFL?
>
> Thanks.
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/
|