PureBytes Links
Trading Reference Links
|
Yes, I did email out an
example of how to do this last week
set the filter in aa window
to n=2 last quotations
This is an example for 3
sets of data, just put your results variables in place of
mine
bar = BarCount - 1 - BarIndex();
x[BarCount-3] = LastValue( AvMinorRFMovePercentAll
);y[BarCount-3] = LastValue( AvMinorRFPullbackPercentAll );x[BarCount-2]
= LastValue( AvMinorFRMovePercentAll );y[BarCount-2] = LastValue(
AvMinorFRPullbackPercentAll );x[BarCount-1] = LastValue(
AvMinorFFMovePercentAll );y[BarCount-1] = LastValue(
AvMinorFFPullbackPercentAll );
A1 = ValueWhen( bar, BarCount-1 );A2 = ValueWhen( bar,
BarCount-2 );A3 = ValueWhen( bar, BarCount-3 );
Filter = BarIndex()==A1 OR BarIndex()==A2 OR
BarIndex()==A3;
AddColumn( x,
"M("+Price[LowLevel]+"-"+Price[HighLevel]+")", 1.1 );
AddColumn( y,
"P("+Price[LowLevel]+"-"+Price[HighLevel]+")", 1.1 );
Cheers,Graham<A
href="">http://groups.msn.com/asxsharetrading<A
href="">http://groups.msn.com/fmsaustralia
<FONT
face=Tahoma size=2>-----Original Message-----From: dirk schreiber
[mailto:tianatrading@xxxxxxxxx] Sent: Thursday, 11 December 2003
7:06 AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker]
one-stock exploration with various rows
still trying to find a better way
to code my pair trading approach:
would it be possible to do an
explore with various loops against one ticker and then visualize this in aa
with various rows? the following code calculates both short- and mid-term
correlation of one stock against a watchlist. the way it is written, it gives
the result in one row, first short-term then mid-term. -- is there a way to
code so that those two rows would show one beneath the other ??
any help appreciated, thanks so
far,
dirk
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
dirk
schreiber
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, December 10, 2003
11:12 AM
Subject: Re: [amibroker] CORRELATION
MATRIX: filter within loop ?
thank you herman for the
code.
i have the feeling that we are
getting closer, although i realize why you say that this solution only works
for a single stock. it is obvious since we cannot have different columns for
every row. but at least your variation of the code can show how many
correlations with other stocks above/beneath a certain level every stock
has.
i will try to see if i can
enhance your code of the single stock correlation exploration.
thanks,
dirk
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Herman
vandenBergen
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Tuesday, December 09, 2003 1:01
PM
Subject: RE: [amibroker] CORRELATION
MATRIX: filter within loop ?
<FONT face=Arial color=#0000ff
size=2>Forgot Yahoo doesn't attach
files anymore, here is the code:
<FONT face=Arial color=#0000ff
size=2><SPAN
class=570355911-09122003>
<SPAN
class=570355911-09122003>//
THIS WILL ONLY WORK CORRECTLY EXPLORING THE CURRENT STOCK AGAINST
THE
// WATCHLIST SELECTED IN THE
GetCategorySymbols() !!!!!<FONT
face=Arial> //
Exploration to create Correlation
matrix<FONT
color=#000000> <FONT
color=#ff0000>Buy=<FONT
color=#ff0000>Sell<FONT
color=#000000>=<FONT
color=#ff0000>Short<FONT
color=#000000>=<FONT
color=#ff0000>Cover<FONT
color=#000000>=0<FONT
size=2>; LastBarInTest =
LastValue<FONT
color=#000000>(ValueWhen<FONT
color=#000000>(Status<FONT
color=#000000>("LastBarInTest"<FONT
color=#000000>),<FONT
color=#0000ff>BarIndex<FONT
face=Arial>())); <FONT
color=#ff0000>Filter =
Status(<FONT
color=#ff00ff>"LastBarInTest"<FONT
face=Arial>); list = <FONT
color=#0000ff>GetCategorySymbols( <FONT
color=#ff0000>categoryWatchlist<FONT
color=#000000>, 0<FONT
size=2> ); <FONT
color=#ff0000>for(
NumTickers=0;
NumTickers < 100
AND
StrExtract( list,
NumTickers ) != ""<FONT
size=2>; NumTickers++ );
IIf<FONT
color=#000000>(C<FONT
color=#000000>>50<FONT
color=#000000>,AddTextColumn<FONT
color=#000000>(Name<FONT
color=#000000>(),"Ticker"<FONT
color=#000000>,1.0<FONT
color=#000000>),0<FONT
size=2>); <FONT
color=#ff0000>for(
Col=0<FONT
face=Arial>; Col<NumTickers; Col++) {
Ticker1 = <FONT
color=#0000ff>Name<FONT
color=#000000>(); Ticker2 = <FONT
color=#0000ff>StrExtract<FONT
face=Arial>( list, Col); Var1 = <FONT
color=#0000ff>Foreign(Ticker1,<FONT
color=#ff00ff>"C"<FONT
color=#000000>); Var2 = <FONT
color=#0000ff>Foreign(Ticker2,<FONT
color=#ff00ff>"C"<FONT
color=#000000>); Corr = <FONT
color=#0000ff>Correlation( Var1, Var2,
8<FONT
face=Arial> ); Color = <FONT
color=#0000ff>IIf(Corr==<FONT
color=#ff00ff>1,<FONT
color=#ff0000>colorBlack<FONT
color=#000000>,IIf<FONT
color=#000000>(Corr<-0.8<FONT
color=#000000>,<FONT
color=#ff0000>colorRed<FONT
color=#000000>,IIf<FONT
color=#000000>(Corr<-0.5<FONT
color=#000000>,<FONT
color=#ff0000>colorOrange<FONT
color=#000000>,IIf<FONT
color=#000000>(Corr<-0.2<FONT
color=#000000>,<FONT
color=#ff0000>colorLightOrange<FONT
color=#000000>,IIf<FONT
color=#000000>(Corr<0.2<FONT
color=#000000>,<FONT
color=#ff0000>colorCustom9<FONT
color=#000000>,IIf<FONT
color=#000000>(Corr<0.5<FONT
color=#000000>,<FONT
color=#ff0000>colorAqua<FONT
color=#000000>,IIf<FONT
color=#000000>(Corr<0.8<FONT
color=#000000>,<FONT
color=#ff0000>colorBrightGreen<FONT
color=#000000>,<FONT
color=#ff0000>colorGreen<FONT
size=2>))))))); <FONT
color=#ff0000>if(
Corr[LastBarInTest] > 0.75<FONT
color=#000000> ) AddColumn<FONT
color=#000000>( Corr, Ticker2, 1.3<FONT
color=#000000>, 1<FONT
color=#000000>, Color); }
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>I think you have a problem doing this when
correlating one watchlist against another watchlist because the table
would have to be completed to know which column would have to be
displayed. However you can do this using the OSAKA table DLL but that
is beyond my programming capability :-)
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>When testing only the current stock against a watchlist you
can use the code attached. Note two lines were
added/modified:
<FONT face=Arial color=#0000ff
size=2>
LastBarInTest
= LastValue(<FONT
color=#0000ff>ValueWhen(<FONT
color=#0000ff>Status(<FONT
color=#ff00ff>"LastBarInTest"),<FONT
color=#0000ff>BarIndex()));
<FONT face=Arial
size=2>....
<FONT
color=#ff0000>if( Corr[LastBarInTest]
> 0.75 )
AddColumn( Corr,
Ticker2, 1.3,
1, Color);
<FONT face=Arial
size=2>
<FONT face=Arial
size=2>herman.
<FONT face=Arial
size=2>-----Original Message-----From: dirk schreiber
[mailto:tianatrading@xxxxxxxxx]Sent: December 9, 2003 7:01
PMTo: amibrokerSubject: [amibroker] CORRELATION
MATRIX: filter within loop ?
does anybody know how to
filter within loops?
i'm still playing around with
the very nice CORRELATION MATRIX that came out of a group effort last
month.
while visually it's nice to
look at, i am having trouble trying to expand upon its
functionality.
i would like to be able to
set a filter within the loop so that the matrix only shows those pairs
with a correlation of higher than 0.75 for example. i have tried using
"addcolumn(iif ...." and "iif( ... addcolumn" but that did not work. i
understand that the for-loop overrides any filter within the loop?
a question closely related
is, i think, if it is possible to modify the code so that the
correlation of any ticker would not be calculated against itself,
because filtering within the matrix (if possible) for high
correlation would not work, as every row has one incident of a
perfect correlation of 1 (its own correlation).
below is a
modified version of the code.
hope i made myself
clear,
any help
appreciated,
dirk
// Exploration to create Correlation matrix
Buy<FONT face=Arial
size=2>=Sell=Short=Cover=<FONT
color=#ff00ff>0;
Filter =
Status(<FONT
color=#ff00ff>"LastBarInTest");
list = <FONT
color=#0000ff>GetCategorySymbols( categoryWatchlist, <FONT
color=#ff00ff>3 );
for<FONT face=Arial
size=2>( NumTickers=0; NumTickers
< 100 AND StrExtract( list,
NumTickers ) != ""; NumTickers++ );
IIf<FONT face=Arial
size=2>(C>50,<FONT
color=#0000ff>AddTextColumn(<FONT
color=#0000ff>Name(),"Ticker",<FONT
color=#ff00ff>1.0),0);
for<FONT face=Arial
size=2>( Col=0; Col<NumTickers; Col++)
{
Ticker1 = Name();
Ticker2 = <FONT
color=#0000ff>StrExtract( list, Col);
Var1 = <FONT
color=#0000ff>Foreign(Ticker1,"C");
Var2 = <FONT
color=#0000ff>Foreign(Ticker2,"C");
Corr = <FONT
color=#0000ff>Correlation( Var1, Var2, <FONT
color=#ff00ff>8 );
Color = <FONT
color=#0000ff>IIf(Corr==<FONT
color=#ff00ff>1,colorBlack,<FONT
color=#0000ff>IIf(Corr<-<FONT
color=#ff00ff>0.8,colorRed,<FONT
color=#0000ff>IIf(Corr<-<FONT
color=#ff00ff>0.5,colorOrange,<FONT
color=#0000ff>IIf(Corr<-<FONT
color=#ff00ff>0.2,colorLightOrange,<FONT
color=#0000ff>IIf(Corr<<FONT
color=#ff00ff>0.2,colorCustom9,<FONT
color=#0000ff>IIf(Corr<<FONT
color=#ff00ff>0.5,colorAqua,<FONT
color=#0000ff>IIf(Corr<<FONT
color=#ff00ff>0.8,colorBrightGreen,colorGreen)))))));
AddColumn(
Corr, Ticker2, 1.3, <FONT
color=#ff00ff>1, Color);
} <FONT
face=Arial size=2>Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT
face=Arial size=2>--------------------------------------------Check
group FAQ at: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face=Arial size=2> Your use of Yahoo! Groups is subject to
the Yahoo! Terms of
Service.
Do you Yahoo!?<A
href=""><FONT face=Arial
size=2>Protect your identity with Yahoo! Mail
AddressGuard<FONT face=Arial
size=2>Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<FONT
face=Arial
size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT
face=Arial size=2>--------------------------------------------Check
group FAQ at: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face=Arial size=2> Your use of Yahoo! Groups is subject to the
Yahoo! Terms of
Service. Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Do you Yahoo!?Protect
your identity with Yahoo! Mail AddressGuardSend
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Do you Yahoo!?Protect
your identity with Yahoo! Mail AddressGuard
Yahoo! Groups Sponsor
ADVERTISEMENT
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
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|