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

[amibroker] Re: Can someone explain variables inside and outside of loops



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "Ken Close" <ken45140@xxx> wrote:
>
> Very basic but I need some confirmation and an explanation why I need to
> repeat calculations inside and outside of loops in order to achieve
what I
> need.

Since the only place you are initializing Var3 is inside the loop, I
would guess that you are not entering the loop.  Check the loop condition.

However, before Thomasz's head explodes ( :) ), you should post the
full AFL (or a small snippet that can reproduce your issue) so the
problem can be seen.  


Tuzo


> Simplified pseudocode to illustrate my problem
> 
> First:
> -----------------------
> Initialize a set of variables
>   Var 1 = Var2 = 100000;///some quantity
>   Var 1[0] = Var2[0] = 0; initialize
> 
> For loop
>   {
>     Var 3 = Var 1 * Var 2;
>     . . . 
>     Other calculations
>   }
> 
> Filter = 1;
> Addcolumn(Var3, "Var1"); < < < Produces error "Var3 not initialized"
> Etc
> 
> Do this:
> Second:
> -------------------------------
> Initialize a set of variables
>   Var 1 = Var2 = 100000;///some quantity
>   Var 1[0] = Var2[0] = 0; initialize
> 
> For loop
>   {
>     Var 3 = Var 1 * Var 2;
>     . . . 
>     Other calculations
>   }
> 
> Var 3 = Var 1 * Var 2;  < < < Repeat calculation done above inside loop
> solely to be able to execute Addcolumn statement
> 
> Filter = 1;
> Addcolumn(Var3, "Var1"); < < < NO ERROR PRODUCED
> Etc
> 
> All of these are AFL statements, all have been processed in memory.  
> Key question:
> *************************
> Why do I have to repeat the calculation statements outside of the
loop in
> order to avoid the "initialize" error?
> *************************
> 
> Basic question, probably dumb.  Yes, I have read the associated help
pages
> on this but I do not see the answer to the above if it is there.
> 
> Can someone please educate me on this basic issue.  In some code I
have, I
> have a LOT of the calculations that have to be done both inside the
loop as
> well as outside and I right now have a significant time penalty as I am
> trying to process 9800 symbols in a single exploration.  I am
looking for
> anything I can find to reduce the processing time.
> 
> Thanks,
> 
> Ken
>



------------------------------------

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/