Simple Coding Help - No Promise.

cloudTrader

Well-Known Member
Dear all,

In this code only HH LH HL LL are getting plotted....
how to get the values also to get plotted along with them?

I tried ValueWhen function but could not do it properly... kindly help
See If you can take some clue from this AFL.

Code:
// pivots and prices
// based on Pramod's comments
//http://www.amibroker.com/library/detail.php?id=617
// adapted by Reinsley : Prices on Pivot and ajustable digits # 
// mod by Sanjiv Bansal : take care of Highs or Lows when two adjacent bars are
//equal
// does not reference to future

SetChartOptions( 0, chartShowDates );

_SECTION_BEGIN( "Price" );
_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, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | styleCandle 
| styleThick );
_SECTION_END();

_SECTION_BEGIN( "pivot" );
price = ParamToggle( "Plot Price", "Off|On", 1 );
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();

GraphXSpace = xspace;
:thumb:
 
Plz help me..............
http://www.traderji.com/amibroker/95071-buy-above-sell-below-nth-candle.html

Happy singh... plz help me in this code...

Thanks in advance..
Seems your requirement is same as ORB
where opening range is from 9:15 to 9:55 AM

Try this

Code:
_SECTION_BEGIN("ORB");
ND = Day()!= Ref(Day(), -1); 
ET = ParamTime("ORB_End_Time","9:55:00"); 
HH = HighestSince(ND,H); 
LL = LowestSince (ND,L);
Hi = ValueWhen(TimeNum()<ET, HH);
Lo = ValueWhen(TimeNum()<ET, LL);
Plot(IIf(ND,Null,Hi),"BO",colorLightGrey,styleDashed|styleNoRescale);
Plot(IIf(ND,Null,Lo),"BD",colorLightGrey,styleDashed|styleNoRescale);
_SECTION_END();

Happy :)
 
Thanks happy....

I got solution from boarder.. Sorry.. Missed to update here....

Thank u so much..

Seems your requirement is same as ORB
where opening range is from 9:15 to 9:55 AM

Try this

Code:
_SECTION_BEGIN("ORB");
ND = Day()!= Ref(Day(), -1); 
ET = ParamTime("ORB_End_Time","9:55:00"); 
HH = HighestSince(ND,H); 
LL = LowestSince (ND,L);
Hi = ValueWhen(TimeNum()<ET, HH);
Lo = ValueWhen(TimeNum()<ET, LL);
Plot(IIf(ND,Null,Hi),"BO",colorLightGrey,styleDashed|styleNoRescale);
Plot(IIf(ND,Null,Lo),"BD",colorLightGrey,styleDashed|styleNoRescale);
_SECTION_END();

Happy :)
 

toughard

Well-Known Member
See If you can take some clue from this AFL.

Code:
// pivots and prices
// based on Pramod's comments
//http://www.amibroker.com/library/detail.php?id=617
// adapted by Reinsley : Prices on Pivot and ajustable digits # 
// mod by Sanjiv Bansal : take care of Highs or Lows when two adjacent bars are
//equal
// does not reference to future

SetChartOptions( 0, chartShowDates );

_SECTION_BEGIN( "Price" );
_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, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | styleCandle 
| styleThick );
_SECTION_END();

_SECTION_BEGIN( "pivot" );
price = ParamToggle( "Plot Price", "Off|On", 1 );
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();

GraphXSpace = xspace;
:thumb:
Hi thanks for the timely help....
BWT I again failed in achieving desired results, look like its advanced for my level of basic AFL knowledge :confused: where ever this comes I struggle
 

toughard

Well-Known Member
Tried this... ummmmm but no use... can some one kindly stitch it for me...

Q = Param( "% Change", 0.05, 0.01, 10, 0.01 );
Z = Zig( C , q ) ;
HH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( z, q, 1 ) > Peak( Z, q, 2 ) ) );
LH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( Z, q, 1 ) < Peak( Z, q, 2 ) ) );
HL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) > Trough( Z, q, 2 ) ) );
LL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) < Trough( Z, q, 2 ) ) );
GraphXSpace = 5;
dist = 0.5 * ATR( 20 );
rightfig = Param( "rightfig ", 7, 1, 10, 1 );
xspace = Param( "GraphXSpace ", 10, 1, 20, 1 );


for ( i = 0; i < BarCount; i++ )
{

if ( HH )
p = StrRight( NumToStr( HH, 4.1 ), rightfig );
PlotText( "HH"+p ,i, HH[ i ] + dist, colorRed );


if ( LH )
PlotText( "LH", i, H[ i ] + dist, colorRed );

if ( HL )
PlotText( "HL", i, L[ i ] - dist, colorBrightGreen );

if ( LL )
PlotText( "LL", i, L[ i ] - dist, colorBrightGreen );
}



See If you can take some clue from this AFL.

Code:
// pivots and prices
// based on Pramod's comments
//http://www.amibroker.com/library/detail.php?id=617
// adapted by Reinsley : Prices on Pivot and ajustable digits # 
// mod by Sanjiv Bansal : take care of Highs or Lows when two adjacent bars are
//equal
// does not reference to future

SetChartOptions( 0, chartShowDates );

_SECTION_BEGIN( "Price" );
_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, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | styleCandle 
| styleThick );
_SECTION_END();

_SECTION_BEGIN( "pivot" );
price = ParamToggle( "Plot Price", "Off|On", 1 );
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();

GraphXSpace = xspace;
:thumb:
 
Last edited:

toughard

Well-Known Member
hello


i need dotted horizontal lines plotting low and high of yesterday .

please help
Plot(TimeFrameGetPrice( "H", inDaily, -1 ),"H",colorYellow,styleDots);
PlotText("PDH",BarCount,LastValue(TimeFrameGetPrice( "H", inDaily, -1 ),True),colorYellow);
Plot(TimeFrameGetPrice( "L", inDaily, -1 ),"L",colorYellow,styleDots);
PlotText("PDL",BarCount,LastValue(TimeFrameGetPrice( "L", inDaily, -1 ),True),colorYellow);
 

Raghuveer

Well-Known Member
hello


i need dotted horizontal lines plotting low and high of yesterday .

please help
afl below:
Code:
//D1=yesterday

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Plot(O, "Open", colorBlack, styleHidden);
_SECTION_END();

ShowD1OHLC= ParamToggle("ShowD1OHLC", "No|Yes", 1);

numbars= LastValue(Cum(Status("barvisible")));
hts= -33.5;

dt= DateTime() ;
dtnum= DateTimeConvert(0, dt) ;
isNewDt= dtnum != Ref(dtnum, -1) ;
isLastbar= H-H ;
isLastbar= dtnum != Ref(dtnum, 1) ;


_SECTION_BEGIN("Last days H/L");
D1HColor= ParamColor("D1HColor", colorWhite);
D1LColor= ParamColor("D1LColor", colorWhite);

D1HStyle= ParamStyle("D1HStyle", styleDashed|styleNoLabel|styleNoRescale);
D1LStyle= ParamStyle("D1LStyle", styleDashed|styleNoLabel|styleNoRescale);

if(ShowD1OHLC)
{
D1H= TimeFrameGetPrice("H", inDaily, -1);
D1L= TimeFrameGetPrice("L", inDaily, -1);

Plot(IIf(isLastbar,Null,D1H), "D1H", D1HColor, D1HStyle);
Plot(IIf(isLastbar,Null,D1L), "D1L", D1LColor, D1LStyle);

PlotText("D1H ", LastValue(BarIndex())-(numbars/Hts), LastValue(D1H,1), D1HColor);
PlotText("D1L ", LastValue(BarIndex())-(numbars/Hts), LastValue(D1L,1), D1LColor);
}

_SECTION_END();
see this link also http://www.traderji.com/amibroker/95098-need-ohlc-code.html#post992568
 

Similar threads