Re: [amibroker] Custom volume histogram

 



// Volume cum
//----------------------------------------------------------
// cumulate the volume for each swing

// by reinsley
// Following the S&C "Price+Volume=Price movement by Tom ORD
// S&C's document is stored in Yahoo! files
// Mod of the Pivots And Prices formula
// http://www.amibroker.com/members/library/detail.php?id=1300

// double pane fmla by fxshrat
//----------------------------------------------------------
// Price
// pivot
// Vertical Daily Segment
// Zig-Hi-Zag-Lo formula
// swing volume
// double pane price and indicator III by fxshrat
// Seconds Remaining
// Xspace

_SECTION_BEGIN( "Price" );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} \nOpen %g \nHigh %g \nLow %g \nClose %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "", colorBlack , styleCandle );
_SECTION_END();

_SECTION_BEGIN( "pivot" );
price = ParamToggle( "Plot Swing Price", "Off|On", 0 );
num = Param( "trend", 4, 1, 10, 1 );
dist = 0.5 * ATR( 10 );
rightfig = Param( "rightfig ", 7, 1, 10, 1 );
xspace = Param( "GraphXSpace ", 10, 1, 20, 1 );

mHHV = HHV( H, num );
mLLV = LLV( L, num );

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

for( b = Firstvisiblebar + num; b <= Lastvisiblebar AND b < BarCount - num; b++ )
{
    i = num;
    ml = 0;
    mu = 0;

    while( i > 0 )
    {

        if( L[b] < L[b + i] )
        {
            ml++;
        }


        if( H[b] > H[b + i] )
        {
            mu++;
        }

        i--;
    }


    if( ml == num AND L[B] == mLLV[B] )
    {
        PlotText( "\n *\n", b, L[b], colorGreen );

        if( price == 1 )
        {
            p = StrRight( NumToStr( L[b], 4.1 ), rightfig );
            PlotText( "\n\n" + p, b - 2 , L[b] , colorGreen );
        }
    }


    if( mu == num AND H[B] == mHHV[B] )
    {
        PlotText( " *\n", b, H[b], colorRed );

        if( price == 1 )
        {
            p = StrRight( NumToStr( H[b], 4.1 ), rightfig );
            PlotText( p , b - 2 , H[b] + dist[b] + 1, colorRed );
        }
    }
}

_SECTION_END();

// Vertical Daily Segment
segments = IIf( Interval() < inDaily, Day(), Month() );
segments = segments != Ref( segments , -1 );
Plot( segments, "", colorDarkBlue, styleHistogram | styleOwnScale | styleDashed | styleNoLabel );

/*
Volbar = TimeFrameGetPrice( "V", in1Minute * 20, 0 );
_TRACE( "Volbar = " + Volbar );
*/




// Zig-Hi-Zag-Lo formula
_SECTION_BEGIN( "Zig-Hi-Zag-Lo" );
VolON = ParamToggle( "Plot Volume", "Off|On", 1 );
ZigON = ParamToggle( "Plot Zig", "Off|On", 1 );
RibbonZigON = ParamToggle( "Plot Ribbon Zig", "Off|On", 0 );
pr = Param( "ZigZag change amount", 0.1, 0.05, 20, 0.01 );

pk = PeakBars( H, pr ) == 0;
tr = TroughBars( L, pr ) == 0;

zzHi = Zig( H, pr );
zzLo = Zig( L, pr );
Avg = ( zzHi + zzLo ) / 2;

x = IIf( pk, zzHi, IIf( tr, zzLo, IIf( Avg > Ref( Avg, -1 ), H, L ) ) );
zzHiLo = Zig( x, pr );

zzup = zzHiLo > Ref( zzHiLo, -1 ) ;
zzdn = zzHiLo < Ref( zzHiLo, -1 );
ribboncol = IIf( zzup , colorWhite, colorBlack );

// Plot the ZigZAg and ribbon
if( RibbonZigON == 1 )
    Plot( 0.1, "", ribboncol, styleArea | styleOwnScale | styleNoLabel, 0, 100 );

if( ZigON == 1 )
    Plot( zzHiLo, "", ribboncol , styleNoLabel );

_SECTION_END();


// Swing Volume
_SECTION_BEGIN( "Swing Volume" );
Volswing = Sum( V, BarsSince( zzup != Ref( zzup, -1 ) ) + 1 );
SwingBar = BarsSince( zzHiLo != Ref( zzHiLo, -1 ) );

// plot Volume at 5% from bottom's pane
percent = Param( "PositTextVol%", 5, 2, 90, 0.5 );
xshift = Param( "xshift %", 4, 1, 90, 0.5 );
yshift = Param( "yshift %", 6, 1, 90, 0.5 );
Miny = Status( "axisminy" );
Maxy = Status( "axismaxy" );
y = Miny + ( Maxy - Miny ) * percent / 100;  // at 5 % above bottom of the pane
FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

for( i = Firstvisiblebar + 1; i <= Lastvisiblebar AND i < BarCount - 1; i++ )
{
    if( zzup [i] AND zzup [ i + 1] == 0 )
    {
        if( VolON == 1 )
        {
            PlotText( "" + Volswing [ i] , i - xshift , H[i] + yshift , colorWhite );
        }
    }

    if( zzup [i] == 0 AND zzup [ i + 1] == 1 )
    {
        if( VolON == 1 )
        {
            PlotText( "" + Volswing [ i] , i - xshift , L[i] - yshift , colorBlack );
        }

    }
}

if( VolON == 1 )
{
    PlotText( "" + Volswing , i + 2  , zzHiLo[BarCount - 1], LastValue( ribboncol ) );
}

_SECTION_END();

// double pane price and indicator III
// Version 1.1
// by fxshrat

_SECTION_BEGIN( "Double pane" );
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \nOp %g, \nHi %g, \nLo %g, \nCl %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//Plot( C, "", ParamColor( "Color Price outline", colorGrey50 ), GetPriceStyle() );

IH = Param( "Height of Indicator Area", 15, 0, 50, 1 ); // Height of indicator in percent pane height
tune = Param( "Fine Tune Price Height", 1, 0.1, 5, 0.1 );
Colorarea = ParamColor( "Color Indicator Area", colorBlack );

Vol = V / HighestVisibleValue( V ) * 100;
Colorvol = IIf( C > O, ParamColor( "Up Color", colorGreen ), ParamColor( "Down Color", colorRed ) );

Volperiod = Min( SelectedValue( BarIndex() ), Status( "lastvisiblebar" ) ) - Status( "firstvisiblebar" );
SumV = SelectedValue( Sum( V, Volperiod ) );

colvolzig = IIf( zzup , colorGreen, colorRed );

if( SumV > 0 )
{
    VolHeight = 100 / IH * 100;
    GraphXSpace = IH * tune;
    _N( Title = Title + StrFormat( ", \nVolume: %1.0f", V ) );
    Plot( Vol, "", colvolzig, styleHistogram | styleOwnScale | styleNoLabel, 0, VolHeight );
    Plot( 100, "", Colorarea, styleArea | styleOwnScale | styleNoLabel, 0, VolHeight );
}

_SECTION_END();

// Seconds Remaining
// _N( Title = ... must exist before
_SECTION_BEGIN( "Seconds Remaining" );
function GetSecondNum()
{
    Time       = Now( 4 );
    Seconds    = int( Time % 100 );
    Minutes    = int( Time / 100 % 100 );
    Hours    = int( Time / 10000 % 100 );
    SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
    return SecondNum;
}

//RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
SecsLeft    = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo    = TimeFrame - SecsLeft;

Secsleft = SecsToGo % 60 ;
Minleft = int( SecsToGo / 60 );
mysec = NumToStr( Secsleft, 2.0 );
mymin = NumToStr( Minleft, 2.0 );

if( ParamToggle( "Time Left Display", "GFX|Title", 1 ) )
{
    Title = Title + "\n\\c07 " +  Minleft + "\\c07 : " + "\\c07 " + Secsleft ;
}
else
{
    GfxSetTextAlign( 6 );// center alignment 6, right 0, left 2
    GfxSelectFont( "Tahoma", Status( "pxheight" ) / 35 );
    GfxSetTextColor( coloraqua );
    shiftHorizchange = Param( "Horiz Shift %Change", 50, 1, 80, 5 );
    shiftVertChange = Param( "Vert %Change", 120, 10, 660, 5 );
    GfxTextOut( mymin + " : " + mysec, shiftHorizchange, shiftVertChange );
}

_SECTION_END();

_SECTION_BEGIN( "Xspace" );
GraphXSpace = Param( "GraphXSpace ", 10, 1, 20, 1 );
_SECTION_END();



__._,_.___

Posted by: reinsley <reinsley@yahoo.fr>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___

Related Posts


EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv