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

Re: [amibroker] Indicator Builder - If on Daily chart = x, but on Weekly = y



PureBytes Links

Trading Reference Links

Dimitris,

This is all correct.

LastValue - references all future quotes (because on the very first bar it looks at the very last available (FUTURE) bar)
As for requirements for StochD - when you call the function inside the loop
- you effectively call StochD many times - 
so the requirements are ADDED UP for each and every function called, as described in my previous e-mail.

As written below: the requirement counting sums up all individual function requirements (in each call).
This usually gives higher than absolute minimum, but this is good because it is better to
use a bit more bars than a bit less.

Note also: QuickAFL is internal AB stuff. I have provided the description for reference only.
Not to discuss anything. 

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, July 22, 2004 11:18 AM
Subject: [amibroker] Re: QuickAFL and SetBarsRequired and other stories


> Tomasz,
> The check answer for
> 
> z=0;
> for(j=10;j<=100;j=j+10)
> {
> y=LastValue(StochD(j));
> if(y>50)
> {
> z=y;AddColumn(z,WriteVal(j,1.0));
> }
> }
> Filter=1;
> 
> is:
> "Approximately 640 past and ALL future quotes are needed to calculate 
> the formula properly."!!
> [I use the latest v.4.59.0. with QuickAFL enabled]
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Hello,
> > 
> > Warning: this is an advanced topic and beginners should skip this 
> post entirely.
> > --------------------------------------------------------------------
> ----------------------
> > 
> > A few words about why using SetBarsRequired is superior to turning 
> QuickAFL off.
> > 
> > Just Quick Fact first:
> > 
> > There is NO difference between turning OFF QuickAFL and
> > adding SetBarsRequired( 1000000, 1000000) at the top of your formula
> > except the latter allows you to do disable QuickAFL feature on PER-
> FORMULA level (which is better).
> > So SetBarsRequired allows to selectively turn off QuickAFL without 
> affecting
> > the performance of ALL indicators.
> > 
> > You can also use
> > SetBarsRequired( 530, 0 );
> > if you do not want to turn off quickafl at all but just provide 
> extra 500 past bars
> > (AB "internally" adds 30 bars at start anyway when no 
> SetBarsRequired is used
> > - hence 500 vs. 530 specified)
> > 
> > Now a few more words how QuickAFL (and AA "Check") function works
> > 
> > (I have explained it already here:
> > http://finance.groups.yahoo.com/group/amibroker-beta/message/1123
> > but here is a quote for quicker reference:)
> > 
> > 
> > I think I should explain how 'check' function works...
> > well it has direct connection with the way how "QUICKAFL" feature
> > calculates number of bars required to correctly compute given 
> function.
> > 
> > "CHECK" feature is in fact "side-effect" of what I need to implement
> > to make QuickAFL working.
> > 
> > (FYI: QuickAFL is described in the User's Guide: Preferences window:
> > Enable QuickAFL(tm) for indicators - this turns on QuickAFL(tm) 
> feature that
> > causes faster charts redraws. QuickAFL works so it
> > calculates only part of the array that is currently visible. If you 
> use this
> > feature and your formulas are script based you should
> > add SetBarsRequired function to your code. Recommended especially 
> when you work
> > with data that have more than 10000 bars. )
> > 
> > To calculate number of bars required to calculate formula
> > AmiBroker internally uses two variables 'backward ref' and 'forward 
> ref'.
> > 
> > 'backward ref' describes how many PREVIOUS bars are needed to 
> calculate
> > the value for today, and 'forward ref' tells how many FUTURE bars 
> are needed
> > to calculate value for today.
> > 
> > When plotting indicators AB takes FIRST visible bar and 
> subtracts 'backward ref"
> > and takes LAST visible bar and adds 'forward ref' to calculate 
> first and last
> > bar
> > needed for calculation of the formula.
> > 
> > Now every AMiBroker's built -in function is written so that it adds
> > its own requirements to those variables.
> > 
> > So for example when parser scans the formula like this:
> > 
> > buy = C > Ref ( MA( C, 40 ), -1 );
> > 
> > it analyses it and "sees" the
> > MA with parameter 40.
> > It knows that simple moving average of period 40 requires 40 past 
> bars
> > and zero future bars to calculate correctly so it does the 
> following (all
> > internally):
> > 
> > BackwardRef = BackwardRef + 40;
> > ForwardRef = ForwardRef + 0;
> > 
> > Now it sees Ref( .., -1 );
> > 
> > It knows that Ref with shift of -1 requires 1 past bar and zero 
> future bars
> > so it "accumulates" requirements this way:
> > 
> > BackwardRef = BackwardRef + 1;
> > ForwardRef = ForwardRef + 0;
> > 
> > So it ends up with
> > BackwardRef = 41;
> > ForwardRef = 0;
> > 
> > AND THESE VALUES are used in the "CHECK" dialog.
> > 
> > To make sure that simple for loops that reference few past bars do 
> not need to
> > call SetBarsRequired
> > AmiBroker automatically adds 30 to BackwardRef just in case.
> > 
> > That's why the CHECK dialog will tell you that the formula
> > buy = C > Ref ( MA( C, 40 ), -1 );
> > 
> > requires 71 past bars and 0 future bars.
> > 
> > You can modify it to:
> > buy = C > Ref ( MA( C, 50 ), -2 );
> > 
> > and it will tell you that it requires 82 past bars (30+50+2) and 
> zero future
> > bars.
> > 
> > If you modify it to:
> > buy = C > Ref ( MA( C, 50 ), 1 );
> > 
> > It will tell you that it needs 80 past bars (30+50) and ONE future 
> bar (from
> > Ref).
> > 
> > This is how "CHECK" function works: it adds the requirements of 
> individual
> > functions
> > to calculate the requirements for entire formula.
> > If NO FUNCTION needs any future quote to calculate then CHECK will 
> tell you that
> > the formula does
> > not reference future quotes.
> > 
> > Note: QuickAFL is currently enabled only for INDICATORS,
> > but... the calculations performed for QuickAFL are used also 
> by "CHECK" feature
> > to 'estimate' if formula needs future bars or not.
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> 
> 
> 
> 
> 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
> 
> 
> 
>  
> 
>


------------------------ 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/