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

[amibroker] AFL, Loops and Objects---was: Re: General query about cumulating values for indicators


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: [amibroker] AFL, Loops and Objects---was: Re: General query about cumulating values for indicators
  • From: Ken Close <ken45140@xxxxxxxxx>
  • Date: Thu, 22 May 2008 18:21:01 -0400

PureBytes Links

Trading Reference Links

Extending this thread . . . . Tomasz, can you offer some explanation about
variables transferred among Objects and AFL statements.  I understand the
concept of arrays and using the subscript to access elements in the array
and in using loops, but what happens when you write a SINGLE "AFL file", and
have a COM "section" or "object" (I am not sure I am using the right term)
to calculate some data, and then you want to use that information to perform
some "standard AFL" function like an AddColumn or Plot?

Recently, Fred showed me some code to rank a set of symbols by determining
their "ordinal value" based on a defined indicator value. I was successful
in using and modifying this code, including displaying the ordinal values
with AddColumn statements.  But then I wanted to Plot the ordinal value of
one of the symbols over time, and could not get away from the "Variable not
defined" error statement.  In short, I did not understand how the arrays I
created in an "analysis object" could be passed to something that could Plot
them over time.  

If this brief description helps, here is some pseudocode (mine) that may
show what I am asking:

Create Analysis Object

Ranking procedure

Loop through symbols in Watch List
	SetForeign
	Get and calculate parameters (like RSIa)
	etc
	RestorePriceArrays

	Rank symbols by technical parameters

		Loop to set Static Variables
Finish loops

Retrieve Static Variables
Perform AFL actions like sum variables

Filter and AddColumns

I tried adding my Plot statements here at the end and got Undefined errors.
How do you pass data from Analysis Object to AFL code?  (Answer:
StaticVariable perhaps?)
  

I truly looked for something to explain all this and could not find
anything.

Can you give a short teaching lecture on this extended topic?

Thanks for all the help you provide.

Ken 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Tomasz Janeczko
Sent: Thursday, May 22, 2008 5:07 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Re: General query about cumulating values for
indicators

No, you are making assumptions instead of reading the manual.
AFL does NOT work on bar-by-bar basis. It works on WHOLE ARRAYS, unless you
tell it NOT to do so by using a loop.

User's Guide: Understanding AFL:
http://www.amibroker.com/guide/h_understandafl.html

(THIS IS MUST READ FOR EVERYONE)
===============================

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "sidhartha70" <sidhartha70@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, May 22, 2008 10:56 PM
Subject: [amibroker] Re: General query about cumulating values for
indicators


> Mike,
> 
> you seem to know your onions... While I'm here can I ask you another
> question...
> 
> Can you clear up for me exactly 'how' AFL executes it's code...
> 
> When I say 'how', this is what I mean. Coming from C# world, it's
> pretty clear that trading type software tends to work on a bar by bar
> basis... i.e. you have an event driven call, of the like,
> OnNewBar()... in that event call you place the code that you want
> executed on each bar...
> 
> It's not clear to me 'how' AFL is called. If I'm applying an
> indicator, how many times is that indicator code called...??
> 
> The reason I ask is, generally the way AFL works with arrays seems
> very efficient... until perhaps you start having to loop through
> arrays as part of your code... for example,
> 
> for(i=1;i<BarCount;i++)
> {
>
Value9[i]=IIf(Value7[i]!=Value8[i],((Value6[i]-Value8[i])/(Value7[i]-Value8[
i])-0.5)+0.5*Value9[i-1],Value9[i]);
> Value9[i]=IIf(Value9[i]>0.9999,0.9999,Value9[i]);
> Value9[i]=IIf(Value9[i]<-0.9999,-0.9999,Value9[i]);
>
Value10[i]=IIf(Value9[i]!=1,0.25*log((1+Value9[i])/(1-Value9[i]))+0.5*Value1
0[i-1],Value10[i]);
> }
> 
> I have recently added this code to one of my indicators and it does
> seem very slow when scrolling through graphs. Perhaps my code is
> inefficient...??
> 
> I'm running a beast of a machine here, so speed should not be an issue.
> 
> If I can understand 'how' AFL excutes... it might help me understand
> bottlenecks.
> 
> Many Thanks
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>>
>> Nope, you're not alone.
>> 
>> The topic pops up, in one form or another, every couple of weeks or 
>> so. Sounds like you understand the concept now.
>> 
>> Good luck.
>> 
>> Mike
>> 
>> --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@> 
>> wrote:
>> >
>> > Thanks Mike.
>> > 
>> > So it seems I'm not the only one coming from more 'traditional'
>> > languages to struggle with this concept.
>> > 
>> > The bottom line it seems is that you cannot recursively alter the
>> > value of any array by referencing other values of that array... at
>> > least not directly.
>> > 
>> > 
>> > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
>> > >
>> > > Read thread #122034 for a similar discussion, including 
>> explanation. 
>> > > 
>> > > Mike
>> > > 
>> > > --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@> 
>> > > wrote:
>> > > >
>> > > > Hi All,
>> > > > 
>> > > > Can someone clear this up for me... I am simply trying to 
>> cumulate 
>> > > the
>> > > > value of an array. My intial thoughts were to do something like 
>> the
>> > > > following,
>> > > > 
>> > > > Value1=0;
>> > > > Value2=log(Close);
>> > > > Value1=Ref(Value1,-1)+Value2;
>> > > > 
>> > > > However, that doesn't seem to work... So I've ended up with,
>> > > > 
>> > > > Value2=log(Close);
>> > > > Value1=Cum(Value2);
>> > > > 
>> > > > Which does seem to work. I can't see why the first doesn't.
>> > > > 
>> > > > Can anyone explain...? Thanks
>> > > >
>> > >
>> >
>>
> 
> 
> 
> ------------------------------------
> 
> 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
> 
> 
> 

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

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




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

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/