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

[amibroker] Re: Trouble trying to compare industry and market ...



PureBytes Links

Trading Reference Links

Louis,

Here is some basic code that shows that it was easy after-all


//Adapted from Tomasz Janeckzko's Relative Performance code 

if (MarketID(1) == "NYSE")
		TickerList = "^DJI,^TNX";
else if (MarketID(1) == "Nasdaq")
       TickerList = "^IXIC,^TNX";

fvb = Status("firstvisiblebar");
Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], Name(), colorBlue );
for( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
 fc = Foreign( symbol, "C" );

 if( ! IsNull( fc[ 0 ] ) )
 {
   Plot( 100 * ( fc - fc[ fvb ] )/ fc[ fvb ], symbol, 
colorLightOrange + ( (2*i) % 15 ), styleLine );
 }
}
PlotGrid( 0, colorYellow );

If you use the example Dow database shipped with AB and then use 
AmiQuote to add ^IXIC and ^TXN and get some data for them to match 
the original database time range you will be able to see how it works.

(You might need to manually move INTC and MSFT to Nasdaq (Market) 
first then as you scroll down to INTC and MSFT the index plotted will 
change from ^DJI to ^IXIC.

It is only very basic - you can extend the idea to get what you want 
e.g. you could use nested IF's with the AND condition to produce more 
specific and complex ticker lists.

I used Yahoo data because we all have access to it for sharing code 
examples.

I just picked any old symbols to prove that the concept is workable.

Another, easier way to do it, would be to put the market index, 
sector index, gold index and all, say, gold stocks in a watchlist - 
you could then use InWatchlist() as the condition for using the 
market/sector/gold index from that watchlist.

Adding more watchlists for other subsets would allow more complex 
choices.

I only used stuff to write the code that had already been posted in 
this thread (thanks to the others who contributed ideas/code etc).



Before you can paint you have to understand the canvas, the colours 
and the brush.

brian_z  *:-)


--- In amibroker@xxxxxxxxxxxxxxx, "louisprefontaine" <rockprog80@xxx> 
wrote:
>
> Hi,
> 
> I am a newbie with Amibroker as well as on this board, but I have 
some
> talent for learning and am trying to learn to write code really 
hard.
>  So far, I had no problem that did not have a solution.
> 
> But now this is something that I don't understand.  I want to 
compare
> a market indicator (such as the Dow Jones)  and a sector indicator
> (such as the mining index).
> 
> Here is the code I wrote so far (I know it's messy; I'm still 
learning)
> 
> 
> --------------------------------------------------------------------
----------------------------------------------------------------------
--------------------------------------
> 
> Ticker = GetBaseIndex(); // plot industry, need to create composite
> sectors
> 
> TickerName = IndustryID(1);
> 
> TickerClose = Foreign( Ticker, "close" );
> 
> 
> for( i = 0; ( symbol = StrExtract( Ticker, i ) ) != ""; i++ )
> {
>   fc = Foreign( ticker, "C" );
> }
> 
> PlotGrid( 0, colorYellow );
> 
> 
> _N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );
> 
>      ticker= ( 100 * ( fc - Ref( fc, -10 ))/Ref (fc,-10)) ;
> Current= ( 100 * ( C - Ref (Close, -10) ) / Ref (Close, -10)) ;
> 
> 
> --------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
------------
> 
> Basically, all I want to do is to add the Industry index along with
> the Market index which is what is displayed right now.  Anybody 
would
> know how to do this?  I tried to experiment with getbaseindex  and
> industry()  and things like that but I got no way to add both
> marketid(0) and industryid (0)  in the same piece of code.
> 
> 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

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