Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: Trix Bars number
Author/Uploader: reinsley - (email hidden)
Date/Time added: 2009-03-03 05:41:29
Origin:
Keywords: trix
Level: basic
Flags: indicator

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

Count Trix Bars for each swing.
Plot a ribbon with the bar number for up and down swings.
Colored swing.
Adjustable Scale PlotText above the ribbon : courtesy by Aron.
It helps to decipher a trend-countertrend-trend.
An easy count A-B-C or 1-2-3.
A serie of trix green segments longer than red segments and going upper at each step can be compared with another time unit. Eg 1 min - 3 min - 10 min.

Formula:

//	Trix Bars number

//	Trix Bars number for each swing

periods = Param( "Periods", 5, 2, 200, 1 );
TrixOnClose = Trix( periods );

uptx = TrixOnClose >= Ref( TrixOnClose, -1 );
dntx = TrixOnClose <= Ref( TrixOnClose, -1 );

Peaktrix = TrixOnClose > Ref( TrixOnClose, -1 )AND TrixOnClose > Ref(
TrixOnClose, 1 );
Troughtrix = TrixOnClose < Ref( TrixOnClose, -1 )AND TrixOnClose < Ref(
TrixOnClose, 1 ) ;

BarsUp = BarsSince( dntx );
BarsDn = BarsSince( uptx );

Colortx = IIf( uptx , colorGreen, IIf( dntx , colorRed, colorGreen ) );

Plot( TrixOnClose, "Trix (" + periods + ")" , Colortx, styleThick );

// Trix's ribbon
Ribbon = IIf( uptx , colorBrightGreen, IIf( dntx , colorRed, colorBrightGreen )
);
Plot( 3, "", Ribbon , styleOwnScale | styleArea | styleNoLabel, 0, 100 );

// plot a text at 5% from bottom's pane
percent = Param( "PositText%", 5, 2, 90, 0.5 );
Miny = Status( "axisminy" );
Maxy = Status( "axismaxy" );
y = Miny +  ( Maxy - Miny ) * percent / 100; // at 5 % above bottom of the
pane

for ( i = 0; i < BarCount; i++ )
{
    if ( Peaktrix [i] )
        PlotText( "" + BarsUp [ i ], i - BarsUp [ i ] / 2 + 1, y, colorGreen
);

    if ( Troughtrix [i] )
        PlotText( "" + BarsDn [ i ], i - BarsDn [ i ] / 2 + 1, y, colorRed );
}

GraphXSpace = 10;

Comments:

dan
dan [at] hidden.com
2009-04-20 21:09:52
good stuff!
reinsley

2010-05-14 04:29:37
To display the last segment figure, add the if ( LastValue( uptx ) ) under the for loop.



for ( i = 0; i < BarCount; i++ )
{
if ( Peaktrix [i] )
PlotText( \\\"\\\" + BarsUp [ i ], i - BarsUp [ i ] / 2 + 1, y, colorGreen );

if ( Troughtrix [i] )
PlotText( \\\"\\\" + BarsDn [ i ], i - BarsDn [ i ] / 2 + 1, y, colorRed );
}

if ( LastValue( uptx ) )
PlotText( \\\"\\\" + LastValue( BarsUp ) , BarCount - 1 / 2 + 1, y, colorGreen );
else
PlotText( \\\"\\\" + LastValue( BarsDn ) , BarCount - 1 / 2 + 1, y, colorRed );


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM