PureBytes Links
Trading Reference Links
|
Thanks Bruce,
Very good observations. Percentile() obviously isn't working they
way I expected it to either (not exactly anyhow). It also seems to
ignore the data at BarCount-1, which is good to know, because it
would mean I'd want to shift my sample ROC data back by one more
bar.
It also explains why you got the 100 on the 2 point test you tried,
rather than the 500 as you expected. Other than that I DO think its
behaving the way I thought it was supposed to in terms of
calculations. Try this one:
Data = Null;
Data[BarCount-1] = 11;
Data[BarCount-2] = 10;
Data[BarCount-3] = 9;
Data[BarCount-4] = 8;
Data[BarCount-5] = 7;
Data[BarCount-6] = 6;
Data[BarCount-7] = 5;
Data[BarCount-8] = 4;
Data[BarCount-9] = 3;
Data[BarCount-10] = 2;
Data[BarCount-11] = 1;
Data[BarCount-12] = 0;
X = Percentile(Data, 11, 51);
Filter = Status("lastbarinrange");
AddColumn(BarIndex(), "BARINDEX", 5.0);
AddColumn(x, "X", 5.2);
As long as the lookback period is less than 12 this works pretty
much as expected. I think the observation that it won't work at
BarCount-1 is key to getting it to do what I wanted.
Thanks for checking it out. I'll post the final code with some
thoughts on how you can use it when I get it going and debug it a
bit.
-ace
--- In amibroker@xxxxxxxxxxxxxxx, "bruce1r" <bruce1r@xxxx> wrote:
> I was playing around with this for grins and think that you may
want
> to ask Tomasz about the function of Percentile(). It isn't doing
> what I would have expected.
>
> First, you can make your code run by using the following line in
> place of the original -
>
> x[i]=LastValue(Percentile( ROC260, count-1, y[i] ));
>
> I don't think that this is going to end up doing what you want,
> though. To me, it looks like the Percentile() function finds the
> percentile rank in the PREVIOUS "N" tick period. When count is
used,
> it is referencing before the first value.
>
> To see this, look at the following exploration -
>
> Data = Null;
> Data[BarCount-1] = 500;
> Data[BarCount-2] = 40;
> Data[BarCount-3] = 100;
> X = Percentile(Data, 2, 100);
> Filter = Status("lastbarinrange");
> AddColumn(BarIndex(), "BARINDEX", 5.0);
> AddColumn(x, "X", 5.0);
>
> I'd expect X to equal 500. Instead, it equals 100. if you set
the
> rank to 50, the Percentile() function yields 70 (halfway between
40
> and 100. You can also see the issue by setting the period to 3 -
the
> last value of X will be Null.
>
> -- Bruce R.
>
> --- In amibroker@xxxxxxxxxxxxxxx, "acesheet" <acesheet@xxxx> wrote:
> > Folks,
> >
> > Can someone explain to me why the series '~xroc' is always
zeros.
> > What this script does is to assemble all the 1 year rate of
changes
> > of a watchlist into one variable called ROC260. The ROC data is
> > shifted forward so that the most recent times record the ROC
data
> > (i.e. rather than near index 0 , it goes back from index
BarCount-
> 1).
> >
> > I'd then like to determine the ROC's fitting into the 1%, 10%,
> > 20%...90%, 99% ranks based on this data. This is what the
> >
> > The variable 'count' stores the actual length of data from the
> Group
> > list being surveyed. This becomes the period for the Percentile
> > function.
> >
> > The variable 'y' is the rank that is being sought. It records
via
> > AddToComposite without a problem, even at index 0 (or the first
> > point). For some reason I can't record '~xroc' or it comes up
with
> > zeroes via some other error.
> >
> > Anyone have an idea of why I can't record ~xroc? I'm pulling my
> hair
> > out right now over this one. I don't want to go bald.
> >
> > Thanks.
> >
> > -ace
> >
> > //-----------------------------------------------------------
> > // First seed the temporary variable for ROC(C,260) with the
ROC's
> > // of all the stocks in in Group0
> > //-----------------------------------------------------------
> > list = CategoryGetSymbols( categoryGroup, 0 );
> > ROC260=Null;
> > count=0;
> > x=Null;
> > y=Null;
> > AddToComposite(y,"~yrank","C");
> > AddToComposite(x,"~xroc","C");
> > for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
> > {
> > ROC260[i+1]=LastValue(ROC(Nz(Foreign( sym, "Close" )),260));
> > count=count+1;
> > }
> > k=(BarCount-1-count);
> > roc260=Ref(ROC260,-k); // This is correct
> > AddToComposite(ROC260,"~roc260","C",1);
> > //-----------------------------------------------------------
> > // Loop i goes through percentile ranks in
> > // increments of 10 from 1 to 99
> > // x = the ROC(C,260) that corresponds to rank y
> > // y = % Rank in 10% Increments
> > //-----------------------------------------------------------
> > for( i = 0; i<=10; i++ )
> > {
> > y[i]=i*10;
> > if(i<1) y[i]=1;
> > if(i>9) y[i]=99;
> > x[i]=LastValue(Percentile( ROC260, count, y[i] ));
> > }
> > AddToComposite(y,"~yrank","C",1);
> > AddToComposite(x,"~xroc","C",1);
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
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/
|