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

Re: [amibroker] Re: Index comparison: Steve Dugas



PureBytes Links

Trading Reference Links

Here it is again - as usual, watch out for line wrap...

Steve

=========================================================

// Filename: Rel Perf Close.afl

// Task: Plots relative performance of tickers entered into params dialog.

// set charting options

SetBarsRequired( 100000, 100000 );

SetChartOptions( 0, chartShowDates|chartShowArrows|chartWrapTitle );

// initialize variables

_N( Tickers = ParamStr( "Enter Tickers ( comma seperated list )", "!! SET 
TICKERS !!" ) );

UsingRange = ParamToggle( "Display % Change Relative To", "Previous Bar ( no 
options to set )|First Bar Of Range ( set options below )", 1 );

UsingDates = ParamToggle( "Set Range Using", "Visible Bars (default) / Range 
Markers (when set)|Dates Below" );

StartDate = ParamDate( "Range Start Date", Date() );

EndDate = ParamDate( "Range End Date", Date() );

PlotZero = ParamToggle( "Display Zero Line?", "No|Yes", 1 );

Extend = ParamToggle( "Extend Final Values/Zero Line Across All Bars?", 
"No|Yes" );

ColorStart = Param( "Start Color Rotation At #", 34, 0, 55, 1 );

ColorInc = Param( "Increment Color Rotation By", 1, -55, 55, 1 );

GraphXSpace = Param( "GraphXSpace", 5, -50, 100, 1 );

BarNumber = BarIndex();

DateNumber = DateNum();

TickerName = "";

DataBase = GetDatabaseName();

// calculate start and end of range

if ( UsingDates ) // use dates from param dialog

{

StartBar = LastValue( ValueWhen( StartDate == DateNumber, BarNumber ) );

EndBar = LastValue( ValueWhen( EndDate == DateNumber, BarNumber ) );

}

else if ( BeginValue( BarNumber ) ) // use start and end of range if start 
marker set

{

StartBar = BeginValue( BarNumber );

EndBar = EndValue( BarNumber );

}

else // use visible bars

{

StartBar = Status( "firstvisiblebar" );

EndBar = Status( "lastvisiblebar" ) - 1;

}

// plot zero line

if ( PlotZero )

{

if ( Extend )

Zero = 0;

else

{

Zero = Null;

for ( Bar = StartBar; Bar <= EndBar; Bar++ ) // fill bars inside range

Zero[Bar] = 0;

}

Plot( Zero, "", colorBrown, styleLine|styleNoLabel );

}

// assign ticker name and get close

for ( i = 0; ( Ticker = StrExtract( Tickers, i ) ) != ""; i++ ) // extract 
current ticker

{

if ( Ticker == "CURRENT" )

{

TickerName = Name();

TickerClose = Close;

Color = colorWhite;

}

else if ( Ticker == "INDUSTRY" )

{

Ticker = GetBaseIndex();

TickerName = IndustryID( 1 ) + " ( " + Ticker + " )";

TickerClose = Foreign( Ticker, "close" );

Color = colorBrightGreen;

}

else if ( Ticker == "SECTOR" )

{

if ( DataBase == "Data-TC2005" )

{

Ticker = StrLeft( GetBaseIndex(), 4 ) + "0";

TickerName = SectorID( 1 ) + " ( " + Ticker + " )";

TickerClose = Foreign( Ticker, "close" );

}

else // database is QP2

{

Ticker = GetBaseIndex(); // plot industry, need to create composite sectors

TickerName = SectorID( 1 ) + " ( " + Ticker + " )";

TickerClose = Foreign( Ticker, "close" );

}

Color = colorGreen;

}

else if ( Ticker == "MARKET" )

{

Color = colorRed;

if ( DataBase == "Data-TC2005" )

{

if ( MarketID() == 1 )

{

Ticker = "nyse";

TickerName = MarketID(1);

TickerClose = Foreign( Ticker, "Close" );

}

else if ( MarketID() == 2 )

{

Ticker = "xax";

TickerName = MarketID(1);

TickerClose = Foreign( Ticker, "close" );

}

else if ( MarketID() == 3 )

{

Ticker = "compqx";

TickerName = MarketID(1);

TickerClose = Foreign( Ticker, "close" );

}

}

else // database is QP2

{

if ( MarketID() == 1 )

{

Ticker = "!nya";

TickerName = MarketID(1);

TickerClose = Foreign( Ticker, "Close" );

}

else if ( MarketID() == 2 )

{

Ticker = "!xax";

TickerName = MarketID(1);

TickerClose = Foreign( Ticker, "close" );

}

else if ( MarketID() == 3 )

{

Ticker = "!comp";

TickerName = MarketID(1);

TickerClose = Foreign( Ticker, "close" );

}

}

}

else

{

TickerName = Ticker;

TickerClose = Foreign( Ticker, "close" );

Color = ( ( ( ColorStart + ( i * ColorInc ) ) % 56 ) + 56 ) % 56;

}

// calculate % change

TickerChg = Null; // initialize % change array

if ( UsingRange ) // calculate % change relative to start of range

for ( Bar = StartBar; Bar <= EndBar; Bar++ ) // fill bars inside range

TickerChg[Bar] = ( TickerClose[Bar] - TickerClose[StartBar] ) / 
TickerClose[StartBar] * 100;

else

for ( Bar = StartBar; Bar <= EndBar; Bar++ ) // fill bars inside range

TickerChg[Bar] = ( TickerClose[Bar] - TickerClose[Bar-1] ) / 
TickerClose[Bar-1] * 100;

if ( TickerName == "!! SET TICKERS !!" )

Title = EncodeColor( colorRed ) + Tickername;

else

Plot( TickerChg, TickerName, Color, styleLine );

if ( Extend )

Plot( TickerChg[EndBar], "", Color, styleLine );

}

----- Original Message ----- 
From: "gillesdeprez" <gillesdeprez@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, May 25, 2006 12:27 PM
Subject: [amibroker] Re: Index comparison: Steve Dugas


> Hi Steve, thanks for your answer...But attachments are not stored
> anymore on Yahoo groups...Or did I miss something? I checked the AB
> library, and the file section of this group, unsuccessfully...
> TIA, friendly,
> Gilles
>
>
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxx> wrote:
>>
>> Here is a pretty flexible relative performance tool. Range
> defaults to
>> visible bars but you can change it with range markers or by
> setting dates in
>> the Params. Also, ticker list accepts keywords like CURRENT,
> INDUSTRY,
>> etc.(you may need to edit the tickers associated with the keywords
> depending
>> on your data provider). Feel free to ask if you have any questions.
>>
>> Steve
>>
>> ----- Original Message ----- 
>> From: "gillesdeprez" <gillesdeprez@xxx>
>> To: <amibroker@xxxxxxxxxxxxxxx>
>> Sent: Tuesday, May 23, 2006 9:21 AM
>> Subject: [amibroker] Index comparison
>>
>>
>> > Hi all!
>> > Does one of you know if there is any possibility to compare
> index with
>> > AB? I mean, compare for example the djia with the BEL20, from a
>> > starting point let's say 1st january 2004, where both index
> would be
>> > at the same level for this date?
>> > TIA, be happy!
>> > Gilles
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > 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 other support material please check also:
>> > http://www.amibroker.com/support.html
>> >
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>
>
>
>
>
>
>
>
> 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 other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
> 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

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