PureBytes Links
Trading Reference Links
|
FWIW
I had to eliminate that same space when I copied it
from your original posting too
--- Tomasz Janeczko <groups@xxxxxxxxxxxxx> wrote:
> My codes work.
> I don't know how you copied it but the formula you
> have provided below is NOT the same as I provided.
> Specifically there is a SPACE between "ra" and "nge"
> in Status("lastbarinra nge"); which is wrong.
> My original formula was different.
>
> You need to copy paste PERFECTLY, without any
> addition/truncation. Go to original post and
> copy-paste AGAIN.
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message -----
> From: Jason Hart
> To: amibroker@xxxxxxxxxxxxxxx
> Sent: Wednesday, June 06, 2007 4:56 PM
> Subject: Re: [amibroker] Re: Corr Matrix via Gfx
> functions
>
>
> TJ - I don't want to beat a dead horse here but I
> can't get your formula to work, when I run it in AA
> I do not get any results. Here is your formula
> again:
>
> symlist = CategoryGetSymbols( categoryWatchlist,
> 22 );
> Filter = Status("lastbarinra nge");
> for( i = 0; ( sym = StrExtract( symlist, i ) ) !=
> ""; i++ )
> {
> Corr = Correlation( C, Foreign( sym, "C" ), 252 );
>
> Clr = 32 + SelectedValue( Corr ) * 32;
> AddColumn( Corr, sym, 1.2, ColorHSB( 128+Clr, 255,
> 255 ) ,
> ColorHSB( Clr, 255, 255 ) );
> }
>
> _______________________________
>
> Here is a correlation matrix formula I use for AA
> which works nicely, but it is very different from
> the one you posted. I'm curious if the results
> between the 2 formulas would be vastly different.
> Here's mine:
> // Exploration to create
> //Correlation matrix
> // Be sure to set
> //"Apply to" to desired wishlist Name
> // Also, change the watchlist number under
> categorywatchlist to the WL you want.
>
> Buy=Sell=Short=Cover=0;
>
> Filter = C > .01;
>
> AddTextColumn(FullName(),"Ticker",1.0);
> list =
> GetCategorySymbols(
> categoryWatchlist,
> 22);
> for(
> NumTickers=0; NumTickers < 99 AND StrExtract(
> list, NumTickers ) !=
> "";
> NumTickers++ );
>
>
> for(
> Col=0;
> Col<NumTickers; Col++)
> {
> Ticker1 =
> Name();
> Ticker2 =
> StrExtract( list, Col);
> Var1 =
> ROC(Foreign(Ticker1, "C"), 1);
>
> Var2 =
> ROC(Foreign(Ticker2,"C"),1);
>
> Test =
> Correlation( Var1, Var2,
> 260 );
> Color =
> IIf(Test>.45,
> colorBrightGreen,
> IIf(Test<0,
> colorRed,
> colorYellow));
> Color =
> IIf(Ticker1==Ticker2,
> 1, Color);
>
> AddColumn( Test,
> Ticker2, 1.3,
> 1, Color);
> }
>
>
> vlanschot <vlanschot@xxxxxxxxx> wrote:
> Ouch, if that is not a slap in the face for
> contributing code (with
> explanation of how NOT to use it), I don't know
> what is.
>
> Guess it was my last one.
>
> PS
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz
> Janeczko" <groups@xxx>
> wrote:
> >
> > Frankly speaking running correlation matrix
> inside INDICATOR window
> > is a VERY VERY BAD idea. Gfx functions ARE NOT
> intended to be used
> > in areas where better and less time-consuming
> methods exists for
> years.
> >
> > It makes no sense to put this into indicator
> code because
> > it will be re-computed with every refresh
> (mouse click on chart).
> > A rule for indicator code is that IT MUST be
> written so it executes
> BELOW 1 second.
> > Any formula that takes longer than 1 second to
> execute should NOT
> be used
> > as indicator.
> >
> > Correlation matrices like that are WAY better
> to be done inside AA
> window.
> >
> > Here is the formula (EXPLORATION):
> >
> > symlist = CategoryGetSymbols(
> categoryWatchlist, 0 );
> >
> > Filter = Status("lastbarinrange");
> > for( i = 0; ( sym = StrExtract( symlist, i ) )
> != ""; i++ )
> > {
> > Corr = Correlation( C, Foreign( sym, "C" ),
> 252 );
> >
> > Clr = 32 + SelectedValue( Corr ) * 32;
> > AddColumn( Corr, sym, 1.2, ColorHSB( 128+Clr,
> 255, 255 ) ,
> ColorHSB( Clr, 255, 255 ) );
> > }
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message -----
> > From: David Fitch
> > To: amibroker@xxxxxxxxxxxxxxx
> > Sent: Tuesday, June 05, 2007 6:31 PM
> > Subject: Re: [amibroker] Re: Corr Matrix via
> Gfx functions
> >
> >
> > AB still locks up when I try this code. I
> cannot place it in a
> pane. AB just stops. I'm wondering if it has
> anything to do with the
> use of "CategoryGetSymbols" function. According
> to help, it is
> looking for watchlists 0 to 63. I have deleted
> the original 0 - 63
> watchlists and replaced them with new ones that
> are 0-75. Could not
> using the original watchlists cause this
> problem?
> > Thanks
> > Dave
> >
> > ----- Original Message -----
> > From: vlanschot
> > To: amibroker@xxxxxxxxxxxxxxx
> > Sent: Tuesday, June 05, 2007 1:31 AM
> > Subject: [amibroker] Re: Corr Matrix via Gfx
> functions
> >
> >
> > Make sure you choose a watchlist (via
> > Parameters) that has at least 2 but does not
> have too many
> securities
> > in it, say less than 50 if you use 1 pane.
> >
> > Also, as is generally the case in AB,
> cross-sectional analysis
> (i.e.
> > matrix calculations across stocks) is very
> computer intensive.
> >
> > PS
> > --- In amibroker@xxxxxxxxxxxxxxx,
> "jayhart_1972"
> <jayhart_1972@>
> > wrote:
> > >
> > > PS - thanks for sharing, looks interesting.
> BTW, has anyone
> got
> > this
> > > to work? When I applied the indicator I get
> nothing but a
> blue
> > screen
> > >
> > > J
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx,
> "vlanschot" <vlanschot@>
> wrote:
> > > >
> > > > Thought I'd share the following code.
> > > >
> > > > PS
> > > >
> > > > //Simple application of the new Gfx
> functions, basically
> > calculating
> > > > //the correlation matrix of any WL of
> choice. You can
> easily
> > adjust
> > > > //this code to move to Var-Covar matrix,
> etc.
> > > > // PS 28/05/07
> > > >
> > > >
> > > > GfxSetOverlayMode(2); // Show Only Matrix
> > > >
> > > > function NrSecs(ListType,ListNr)
> > > > {
> > > > global NrPosPrices;
> > > >
> > > > if(ListType==1) ExtrList =
> CategoryGetSymbols
> > > > (categoryGroup,ListNr);
> > > > else if(ListType==2)ExtrList =
> CategoryGetSymbols
> > > > (categoryWatchlist,ListNr);
> > > > else if(ListType==3)ExtrList =
> CategoryGetSymbols
> > > > (categoryIndustry,ListNr);
> > > >
> > > > NrSecurs=0;
> > > > NrPosPrices=0;
> > > >
> > > > for( n=0; (Ticker=StrExtract( ExtrList,
> n))!= ""; n++)
> > > > {
> > > > NrSecurs=NrSecurs+1;
> > > > SetForeign(Ticker);
> > > > Prijs=C;
> > > > RestorePriceArrays();
> > > > NrPosPrices=NrPosPrices+IIf(Prijs!=Null
> AND
> > > > Prijs>0,1,0);
> > > > }
> > > > return NrSecurs;
> > > > }
> > > >
> > > > function PrintTxtInCell( Str, row, Col,
> CellWidth,
> CellHeight,
> > > > HorzAdj, VertAdj, Formaat )
> > > > {
> > > > GfxDrawText( Str, Col * CellWidth +
> HorzAdj, row *
> CellHeight +
> > > > VertAdj, (Col + 1 ) * CellWidth, (row + 1
> ) * CellHeight,
> > Formaat);
> > > > }
> > > >
> > > > function PrintInCell( val, row, Col,
> CellWidth, CellHeight,
> > > HorzAdj,
> > > > VertAdj )
> > > > {
> > > > GfxDrawText( NumToStr(val), Col *
> CellWidth + HorzAdj, row
> *
> > > > CellHeight + VertAdj, (Col + 1 ) *
> CellWidth, (row + 1 ) *
> > > > CellHeight, 1|32|4);
> > > > }
> > > >
> > > >
> > > > //CH = Param("CellH",20,10,100,5);
> > > > //CW = Param("CellW",100,10,300,5);
> > > > HA=0;
> > > > VA=0;
> > > >
> > > > String = "" ;
> > > > for ( x = 0 ; x < 200 ; x++ )
> > > > {
> > > > WList = CategoryGetName(
> categoryWatchlist, x );
> > > > if (WList != "" )
> > > > {
> > > > String = String + WList +"," ;
> > > > // Creates a list of WatchLists, NOT
> symbols !!!
> > > > }
> > > > }
> > > > WatchList = ParamList ( "Watch List",
> String );
> > > >
> > > >
> WLnr=CategoryFind(WatchList,categoryWatchlist);
> > > > WLSymbols =
> CategoryGetSymbols(categoryWatchlist,WLnr);
> > > >
> > > > NrSymbs = NrSecs(2,WLNr);
> > > >
> > > > CW= Status("pxwidth")/(NrSymbs+1);// In
> order to allow
> Rowheadings
> > > > CH =
> Status("pxheight")/(NrSymbs+1);//Colheadings
> > > >
> > > > //GfxSetTextAlign(6 | 24);
> > > >
> > > > RetLB = Param("RetLB",1,1,100);
> > > > CorrLB = Param("CorrLB",30,5,256);
> > > >
> > > > Start = BarCount-RetLB;
> > > >
> > > > ActBar =
> Min(BarCount-1,LastValue(SelectedValue(BarIndex
> ())));
> > > > ActD =
> LastValue(SelectedValue(DateTime()));
> > > >
> > > > GfxSelectFont( "MS Serif", CH/4,800);
> > > > PrintTxtInCell( "CorrM
> @:\n"+NumToStr(ActD,formatDateTime),
> 0,
> > > 0,CW,
> > > > CH, HA, VA, 1);
> > > >
> > > > for ( x = 0 ; (Ticker = StrExtract (
> WLSymbols, x ))!="" ;
> x++ )
> > > > {
> > > > SetForeign(Ticker);
> > > > RetTick = ROC(C,RetLB);
> > > > FN = FullName();
> > > > RestorePriceArrays();
> > > >
> > > > GfxSelectFont( "MS Serif", CH/4,800);
> > > > PrintTxtInCell( Ticker, 0, x+1 ,CW, CH,
> HA, VA,1|32|4 );
> > > >
> > > > GfxSelectPen( colorBlue );
> > > >
> > > > for( i = 0; (Ticker2 = StrExtract (
> WLSymbols, i))!="" ;
> i++ )
> > > > {
> > > > SetForeign(Ticker2);
> > > > RetTick2 = ROC(C,RetLB);
> > > > FN2 = FullName();
> > > > RestorePriceArrays();
> > > >
> > > > if (Ticker2 == Ticker) Corr=1;
> > > > else Corr = Correlation(RetTick, RetTick2,
> CorrLB);
> > > >
> > > > GfxSelectFont( "MS Serif", CH/4,800);
> > > > PrintTxtInCell( Ticker2, i+1, 0, CW, CH,
> HA,
> > > > VA,1|32|4);
> > > > GfxSelectFont( "MS Serif", CH/4);
> > > > Kleur = IIf(Corr[ActBar]>=0,
> colorGreen,colorRed);
> > > > GfxSetTextColor(Kleur);
> > > > PrintInCell( Corr[ ActBar ], i+1, x+1, CW,
> CH, HA,
> > > > VA);
> > > > //PrintInCell( Corr[ ActBar ] , i+1, x+1);
> > > > GfxSetTextColor(colorBlack);
> > > >
> > > > GfxMoveTo( 0, (i+1) * CH);
> > > > GfxLineTo( (x+2) * CW, (i+1) * CH );//
> Columns
> > > > }
> > > >
> > > > GfxMoveTo( 0, (x+1)*CH); // Move to end of
> last column
> > > > //GfxLineTo( 6 * CW, i * CH );
> > > > }
> > > >
> > > > for( Col = 1; Col < NrSymbs+2; Col++ )
> > > > {
> > > > GfxMoveTo( Col * CW, 0);
> > > > GfxLineTo( Col * CW, (NrSymbs+1) * CH );
> > > > }
> > > >
> > > >
> > > > Title="";
> > > >
> > >
> >
>
>
>
>
>
>
>
------------------------------------------------------------------------------
> Pinpoint customers who are looking for what you
> sell.
Rick Osborn
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/
|