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

Re: [amibroker] 2 indicators on one chart



PureBytes Links

Trading Reference Links

Here is a start, check the attached file.

Anthony

Russ Ty wrote:

> Hi all,
>
> Is there anyway to combine two different indicators on
> one chart. For example, to pinpoint where we are in
> the business cycle, I would like to combine two trend
> deviations (see prior mails) on one chart. One for an
> inflationary stock and another for a deflationary
> stock - a type of relative strength analysis - and
> compare their individual peaks and troughs at the same
> time.
>
> Furthermore, is there anyway to apply indicators to
> other indicators rather than the price graph e.g. can
> I plot a ROC chart or a trend deviation for a relative
> strength analysis of a bank vs a gold share?
>
> kind regards
> Russ
>
> __________________________________________________
> Do You Yahoo!?
> Find a job, post your resume.
> http://careers.yahoo.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

Relative Performance charts


In "Relative Performance Charting" article, Phil Doyle presented a technique for comparing relative percentage rate of change
of many securities on the same chart. Article presents two versions of these charts: basic comparison chart and baseline
performance chart. Both kinds can be easily implemented using AmiBroker 3.60 and its built-in foreign() function. To recreate
basic relative performance chart in AmiBroker just select Indicator Builder from Analysis menu and enter the following code:

/* Relative Performance charts
** AFL implementation by Tomasz Janeczko
**
** Use Automatic scaling, Grid: Percent, Limits, Middle
**
** This example plots 4 lines
** bold red - currently selected ticker
** blue - DJIA
** black - IBM
** green - MSFT
** you can of course change the tickers as you wish
*/
maxgraph = 4; // as many as you wish to use
startpoint = 10; // the start point of comparision will be 10th bar
price = close;
graph0 = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 );
graph0style = 4;
// you can change the ticker below
price = foreign("^DJI", "C");
graph1 = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 );
graph1style = 1;
// you can change the ticker below
price = foreign("IBM", "C");
graph2 = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 );
graph2style = 1;
// you can change the ticker below
price = foreign("MSFT", "C");
graph3 = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 );
graph3style = 1;
graph3color = 6;



The formula uses ^DJI, IBM and MSFT tickers that are compared to currently selected stock. You can of course modify those
ticker names to match your local exchange or add if you want a wider group to be included on the chart. The picture below
shows proper settings of Scaling and Grid lines for Relative Performance charts.



Once you entered the formula and set scaling/grid as shown, you just need to click on Apply and the chart will appear in a new
pane.

A slightly more advanced version of Relative Performace Chart is a baseline version that displays the performance of several
securities compared to one "base" security (in the example below this is ^DJI) - showing exactly what stocks outperform or
underperform the base stock/index. The formula for the baseline relative performance chart is as follows:

/* Baseline Relative Performance charts
** with ^DJI as a base line
** AFL implementation by Tomasz Janeczko
**
** Use Automatic scaling, Grid: Percent, Limits, Middle
**
** This example plots 4 lines
** bold red - currently selected ticker
** blue - DJIA - Base Line
** black - IBM
** green - MSFT
** you can of course change the tickers as you wish
*/
maxgraph = 4; // as many as you wish to use
startpoint = 10; // the start point of comparision will be 10th bar
// here is a base line
price = foreign("^DJI", "C");
baseline = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 );
price = close;
graph0 = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 ) - baseline;
graph0style = 4;
// base line chart (flat line)
graph1 = baseline - baseline;
graph1style = 1;
// you can change the ticker below
price = foreign("IBM", "C");
graph2 = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 ) - baseline;
graph2style = 1;
// you can change the ticker below
price = foreign("MSFT", "C");
graph3 = 100 * ( price/ValueWhen( cum(1) == startpoint, price ) - 1 ) - baseline;
graph3style = 1;
graph3color = 6;



The settings for this version are the same as shown above. Below you will find the picture that shows the result of applying the
formula to Philip Morris (MO) stock. It clearly shows that MO outperforms Dow Jones average by more than 40% in 7 month
period.



Volume Weighted Average Price Support/Resistance



A second article in the May 2001 issue of Technical Analysis of Stocks and Commodities presents the method of computing
support and resistance curves based on volume-weighted average price. In the article author suggest to enter peak and trough
points by hand. The formula presented below takes more automatic approach - it finds the highest high and lowest low for
given stock automatically and uses that points for calculations without the need to enter them manually:

/* Volume Weighted Average Support/Resistance lines */
/* From May 2001 issue of TASC */
/* AFL implementation by Tomasz Janeczko */
/* black line represents closing price */
/* red - VWAP Support line */
/* blue - VWAP Resistance line */
/* Starting point for support/resistance lines */
/* are calculated from highest and lowest history prices */
/* You can of course choose other points if you wish */
trbar = LastValue( Lowest( L ) ) == L;
pkbar = LastValue( Highest( H ) ) == H;
avgprice = ( High + Low )/2;
pv = avgprice * V;
cumpv = Cum( pv );
cumv = Cum( V );
MRes = IIF( BarsSince( pkbar ), ( cumpv - ValueWhen( pkbar, cumpv ) ) / ( cumv -
ValueWhen( pkbar, cumv ) ), avgprice );
MSup = IIF( BarsSince( trbar ), ( cumpv - ValueWhen( trbar, cumpv ) ) / ( cumv -
ValueWhen( trbar, cumv ) ), avgprice );

graph0 = MSup;
graph1 = MRes;
graph2= close;
graph2style = 64;


Again one should use Automatic scaling for this formula in Indicator Builder.

Tomasz Janeczko,
amibroker.com