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

Re: [amibroker] Re: General query about cumulating values for indicators



PureBytes Links

Trading Reference Links

There is no special "penalty" for using looping, however same
code written using array operators will always be faster.
Literally almost every code can be written using array operators,
with some thinking. As always - post ENTIRE formula if you want help.
Also look at SetBarsRequired function to limit the number of bars
that are used.

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


> Tomasz,
> 
> I have already read the link you provided. Sadly one needs to make
> mistakes sometimes to completely understand.
> Sorry, I should have rephrased my statement. You cannot change the
> value of an array by recursively referencing earlier values with the
> following syntax (which those of us coming from other languages are
> used to),
> 
> Value1=Ref(Value1,-1) * 2;
> 
> for example. But that's fine. I now understand that this cannot be
> done, and I have implemented the looping structures I posted in my
> previous message.
> 
> I am however, now finding this indicator pretty slow at intraday level
> when scrolling through charts. Is there a large speed penalty to using
> the looping structures as I have....?
> 
> Many Thanks
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> wrote:
>>
>> 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@xxx>
>> 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*Value10[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@> 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/