Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
Find Out More Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

swing11 for Amibroker (AFL)

Copy & Paste Friendly
Version( 6.0 );

x = BarIndex();
fvb = FirstVisibleValue( x );
lvb = LastVisibleValue( x );
rightStrength = Param( "Fractal Pivot Right side Strength", 5, 0, 50, 1 );
leftStrength = Param( "Fractal Pivot Left side Strength", 10, 0, 50, 1 );
tf = Param( "Time Frame (min)", 5, 1, 10080, 1 );
tog1 = ParamToggle( "Alternate Pivots", "No|Yes", 1 );// clean pivots

tfrm = in1Minute * tf;
fact = Nz( Max( tfrm / 60, Interval() / 60 ) / ( Interval() / 60 ) );

if( fact == 0 )
    fact = 1;

pk = tr = px0 = px1 = px2 = tx0 = tx1 = tx2 = ph0 = ph1 = ph2 = tl0 = tl1 = tl2 = ll = hl = hh = lh = dt = db = 0;
pkn = trn = pxn0 = pxn1 = pxn1 = txn0 = txn1 = txn2 = phn0 = phn1 = phn2 = tln0 = tln1 = tln2 = 0;

function calculateMainPivots()
{
    pk = H > Ref( HHV( H, leftStrength * fact ), -1 ) AND Ref( HHV( H, rightStrength * fact ), rightStrength * fact ) <= H;
    tr = L < Ref( LLV( L, leftStrength * fact ), -1 ) AND Ref( LLV( L, rightStrength * fact ), rightStrength * fact ) >= L;

    if( tog1 )
    {
        pkw = pk;
        trw = tr;
        pk = pkw AND H == HighestSince( trw, H );
        tr = trw AND L == LowestSince( pkw, L );

        pkw = pk;
        trw = tr;
        tr = ExRem( Reverse( trw ), Reverse( pkw ) );
        pk = ExRem( Reverse( pkw ), Reverse( trw ) );

        tr = Reverse( tr );
        pk = Reverse( pk );
    }

    for( i = 0; i < 3; i++ )
    {
        VarSet( "px" + i, ValueWhen( pk, x, i ) );
        VarSet( "tx" + i, ValueWhen( tr, x, i ) );
        VarSet( "ph" + i, ValueWhen( pk, H, i ) );
        VarSet( "tl" + i, ValueWhen( tr, L, i ) );
        
        VarSet( "pxdis" + i, lvb - ValueWhen( pk, x, i ) );
        VarSet( "txdis" + i, lvb - ValueWhen( tr, x, i ) );
    }

    ll = tr AND tl1 < tl2;
    hl = tr AND tl1 > tl2;
    hh = pk AND ph1 > ph2;
    lh = pk AND ph1 < ph2;
    dt = pk AND ph1 == ph2;
    db = tr AND tl1 == tl2;
}

function calculateWorkingPivots()
{
    pkn = H > Ref( HHV( H, ( leftStrength + 0 ) * fact ), -1 );
    trn = L < Ref( LLV( L, ( leftStrength + 0 ) * fact ), -1 );

    for( i = 0; i < 3; i++ )
    {
        VarSet( "pxn" + i, ValueWhen( pkn, x, i ) );
        VarSet( "txn" + i, ValueWhen( trn, x, i ) );
        VarSet( "phn" + i, ValueWhen( pkn, H, i ) );
        VarSet( "tln" + i, ValueWhen( trn, L, i ) );
    }
}

GraphXSpace = 5;
SetChartBkColor( colorBlack );
SetChartOptions( 1, chartShowDates, chartGridMiddle, 0, 0, 0 );
SetBarFillColor( IIf( C > O, ColorRGB( 0, 75, 0 ), IIf( C <= O, ColorRGB( 75, 0, 0 ), colorLightGrey ) ) );
Plot( C, "", IIf( C > O, ColorRGB( 0, 255, 0 ), IIf( C <= O, ColorRGB( 255, 0, 0 ), colorLightGrey ) ), 64, Null, Null, 0, 0, 1 );

function drawPivotLabels()
{
    sz = 5;

    for( i = lvb; i > fvb; i-- )
    {
        {
            if( ll[i] ) PlotTextSetFont( "LL", "Arial Black", sz, i, L[i], colorGreen, colorDefault, -25 );

            if( hl[i] ) PlotTextSetFont( "HL", "Arial Black", sz, i, L[i], colorGreen, colorDefault, -25 );

            if( db[i] ) PlotTextSetFont( "DB", "Arial Black", sz, i, L[i], colorLightBlue, colorDefault, -25 );

            if( hh[i] ) PlotTextSetFont( "HH", "Arial Black", sz, i, H[i], colorRed, colorDefault, 20 );

            if( lh[i] ) PlotTextSetFont( "LH", "Arial Black", sz, i, H[i], colorRed, colorDefault, 20 );

            if( dt[i] ) PlotTextSetFont( "DT", "Arial Black", sz, i, H[i], colorOrange, colorDefault, 20 );
        }
    }
}

calculateMainPivots();
calculateWorkingPivots();
drawPivotLabels();

PlotShapes( shapeSmallCircle*trn, ColorRGB( 0, 30, 0 ), 0, L, -10 );
PlotShapes( shapeSmallCircle*pkn, ColorRGB( 50, 0, 0 ), 0, H, 10 );

if( !tog1 )// cleanpivots turned off
{
    PlotShapes( shapeSmallCircle * tr, IIf( txdis1 > rightStrength * fact, ColorRGB( 0, 255, 0 ), colorWhite ), 0, L, -10 );
    PlotShapes( shapeSmallCircle * pk, IIf( pxdis1 > rightStrength * fact, ColorRGB( 255, 0, 0 ), colorWhite ), 0, H, 10 );
}
else // cleanpivots turned on
{   
	// => this part not finished, validation still needs to be adressed
    PlotShapes( shapeSmallCircle * tr, ColorRGB( 0, 255, 0 ), 0, L, -10 );
    PlotShapes( shapeSmallCircle * pk, ColorRGB( 255, 0, 0 ), 0, H, 10 );            
}

Title = Name() +
        " | " + Now( 2 );
Back