Simple Coding Help - No Promise.

Hi all
Need help

I want line drawn between yesterday's HIGH and day before yesterday's High
and line between yesterday's Low and day before yesterday's Low
as shown in first chart
Dear Loss _lover Ji..

please if possible look into post no : 5596 & request to make that afl..

Thanks in advance...
Here you go friends, hope this helps:
C-like:
_SECTION_BEGIN( "2-Day Hi-Lo Trendline" );
     bi = BarIndex();
    
     h1 = TimeFrameGetPrice( "H", inDaily, -1 );
     h2 = TimeFrameGetPrice( "H", inDaily, -2 );     
     CondH1 = H == SelectedValue( h1 );
     CondH2 = H == SelectedValue( h2 );     
     biH1 = ValueWhen( CondH1, bi );
     biH2 = ValueWhen( CondH2, bi );     
     laH = LineArray( SelectedValue( biH2 ), SelectedValue( h2 ), SelectedValue( biH1 ), SelectedValue( h1 ), 1 );
    
     l1 = TimeFrameGetPrice( "L", inDaily, -1 );
     l2 = TimeFrameGetPrice( "L", inDaily, -2 );
     CondL1 = L == SelectedValue( l1 );
     CondL2 = L == SelectedValue( l2 );
     biL1 = ValueWhen( CondL1, bi );
     biL2 = ValueWhen( CondL2, bi );     
     laL = LineArray( SelectedValue( biL2 ), SelectedValue( L2 ), SelectedValue( biL1 ), SelectedValue( L1 ), 1 );
    
     SetChartOptions( 0, chartShowDates );
     _N( Title = StrFormat( "{{NAME}} {{DATE}} O %g, H %g, L %g, C %g", O, H, L, C ) + WriteIf( Nz( V, 0 ) == 0, "", ", Vol " + V ) );
     Plot( C, "", colorDefault, styleCandle );
     Plot( laH, "", colorGreen, styleLine | styleNoRescale, Null, Null, 0, 0, 3 );
     Plot( laL, "", colorBrown, styleLine | styleNoRescale, Null, Null, 0, 0, 3 );
_SECTION_END();
Snips.gif
 
Its same which you poasted I think...
Vijay Sir, Hope this works the way you want.
Code:
_SECTION_BEGIN("HiLo Vol of Day");

//========= Price Plot ============

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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );


intrvl = Interval();
Bars = ((6*60*60)+(15*60))/intrvl;

lowVol = Volume <= LLV( Volume, Bars );

//========= Low Volume Bar Circle Plot below Price =============

PlotShapes(shapeSmallCircle*lowVol,colorred, 0, L, -25);

//=========== Sound Alert once for the Low Volume Bar by travi =======

if( LastValue( lowVol ) )
    {
        dt = LastValue( DateTime() );

        SayC = Nz( StaticVarGet( "Say" + Name() ) );
        if ( !SayC || dt != SayC )
        {
            StaticVarSet( "Say" + Name(), dt );
            Say( "Low Volume in " + Name(), True );
        }
    }

_SECTION_END();
This is how it looks:

HiLoCircle.png
 
Last edited:

VJAY

Well-Known Member
Vijay Sir, Hope this works the way you want.
Code:
_SECTION_BEGIN("HiLo Vol of Day");

//========= Price Plot ============

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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );


intrvl = Interval();
Bars = ((6*60*60)+(15*60))/intrvl;

lowVol = Volume <= LLV( Volume, Bars );

//========= Low Volume Bar Circle Plot below Price =============

PlotShapes(shapeSmallCircle*lowVol,colorred, 0, L, -25);

//=========== Sound Alert once for the Low Volume Bar by travi =======

if( LastValue( lowVol ) )
    {
        dt = LastValue( DateTime() );

        SayC = Nz( StaticVarGet( "Say" + Name() ) );
        if ( !SayC || dt != SayC )
        {
            StaticVarSet( "Say" + Name(), dt );
            Say( "Low Volume in " + Name(), True );
        }
    }

_SECTION_END();
This is how it looks:

View attachment 32398
Thanks bbhanushali.....i think it serves my need....will check it on monday...as am out from home/system...and please avoid this 'sir'....
 

RadhuK

Well-Known Member
Here you go friends, hope this helps:
C-like:
_SECTION_BEGIN( "2-Day Hi-Lo Trendline" );
     bi = BarIndex();
   
     h1 = TimeFrameGetPrice( "H", inDaily, -1 );
     h2 = TimeFrameGetPrice( "H", inDaily, -2 );    
     CondH1 = H == SelectedValue( h1 );
     CondH2 = H == SelectedValue( h2 );    
     biH1 = ValueWhen( CondH1, bi );
     biH2 = ValueWhen( CondH2, bi );    
     laH = LineArray( SelectedValue( biH2 ), SelectedValue( h2 ), SelectedValue( biH1 ), SelectedValue( h1 ), 1 );
   
     l1 = TimeFrameGetPrice( "L", inDaily, -1 );
     l2 = TimeFrameGetPrice( "L", inDaily, -2 );
     CondL1 = L == SelectedValue( l1 );
     CondL2 = L == SelectedValue( l2 );
     biL1 = ValueWhen( CondL1, bi );
     biL2 = ValueWhen( CondL2, bi );    
     laL = LineArray( SelectedValue( biL2 ), SelectedValue( L2 ), SelectedValue( biL1 ), SelectedValue( L1 ), 1 );
   
     SetChartOptions( 0, chartShowDates );
     _N( Title = StrFormat( "{{NAME}} {{DATE}} O %g, H %g, L %g, C %g", O, H, L, C ) + WriteIf( Nz( V, 0 ) == 0, "", ", Vol " + V ) );
     Plot( C, "", colorDefault, styleCandle );
     Plot( laH, "", colorGreen, styleLine | styleNoRescale, Null, Null, 0, 0, 3 );
     Plot( laL, "", colorBrown, styleLine | styleNoRescale, Null, Null, 0, 0, 3 );
_SECTION_END();
View attachment 32395
Thanx Loss_Lover ji . Just what I needed. Can easily see brakeout happening from two day trendlines.
BTW, why your ID is Loss_Lover, when you have winning strategies ???
 
Thanx Loss_Lover ji . Just what I needed.
Here is an updated version.
C-like:
fvb = Status( "firstvisiblebar" );
lvb = Status( "lastvisiblebar" );
pxchartwidth = Status( "pxchartwidth" );
pxchartheight = Status( "pxchartheight" );
pxchartleft = Status( "pxchartleft" );
pxchartbottom = Status( "pxchartbottom" );
MaxY = Status( "axismaxy" );
MinY = Status( "axisminy" );

function GfxConvertBarToPixelX( bar )
{
     //Based on http://www.amibroker.com/kb/2009/03/30/how-to-convert-from-bar-value-to-pixel-co-ordinates/
     local bardiff, barnum, relbar, px;
     barnum = lvb - fvb + 1;
     bardiff = bar - fvb;
     relbar = bardiff / barnum;
     px = relbar * pxchartwidth + pxchartleft;
     return Nz( px );
}
function GfxConvertValueToPixelY( Value )
{
     //Based on http://www.amibroker.com/kb/2009/03/30/how-to-convert-from-bar-value-to-pixel-co-ordinates/
     pxy = pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight / ( Maxy - Miny + 1e-9 ) );
     return Nz( pxy );
}

_SECTION_BEGIN( "2-Day Hi-Lo Trendline" );
     shift = Param( "Extend beyond last visible bar", 10, 0, 100, 1 );
     bi = BarIndex();
     PxPerBar = pxchartwidth / ( lvb - fvb );
    
     h1 = TimeFrameGetPrice( "H", inDaily, -1 );
     h2 = TimeFrameGetPrice( "H", inDaily, -2 );
     pxH1 = GfxConvertValueToPixelY( SelectedValue( h1 ) );
     pxH2 = GfxConvertValueToPixelY( SelectedValue( h2 ) );
     CondH1 = H == SelectedValue( h1 );
     CondH2 = H == SelectedValue( h2 );
     biH1 = ValueWhen( CondH1, bi );
     biH2 = ValueWhen( CondH2, bi );
     pxBiH1 = GfxConvertBarToPixelX( SelectedValue( biH1 ) );
     pxBiH2 = GfxConvertBarToPixelX( SelectedValue( biH2 ) );
     laH = LineArray( SelectedValue( biH2 ), SelectedValue( h2 ), SelectedValue( biH1 ), SelectedValue( h1 ) );
     dxH = pxBiH2 - pxBiH1;
     dyH = pxH2 - pxH1;
     slopeH = dyH / dxH;
     extBarsH = bi[ BarCount - 1 ] - SelectedValue( biH1 ) + shift;
     x1H = pxBiH1;
     y1H = pxH1;
     x2H = x1H + ( extBarsH * PxPerBar );
     y2H = y1H + ( slopeH * ( x2H - x1H ) );
    
     l1 = TimeFrameGetPrice( "L", inDaily, -1 );
     l2 = TimeFrameGetPrice( "L", inDaily, -2 );
     pxL1 = GfxConvertValueToPixelY( SelectedValue( L1 ) );
     pxL2 = GfxConvertValueToPixelY( SelectedValue( L2 ) );
     CondL1 = L == SelectedValue( l1 );
     CondL2 = L == SelectedValue( l2 );
     biL1 = ValueWhen( CondL1, bi );
     biL2 = ValueWhen( CondL2, bi );
     pxBiL1 = GfxConvertBarToPixelX( SelectedValue( biL1 ) );
     pxBiL2 = GfxConvertBarToPixelX( SelectedValue( biL2 ) );
     laL = LineArray( SelectedValue( biL2 ), SelectedValue( L2 ), SelectedValue( biL1 ), SelectedValue( L1 ) );
     dxL = pxBiL2 - pxBiL1;
     dyL = pxL2 - pxL1;
     slopeL = dyL / dxL;
     extBarsL = bi[ BarCount - 1 ] - SelectedValue( biL1 ) + shift;
     x1L = pxBiL1;
     y1L = pxL1;
     x2L = x1L + ( extBarsL * PxPerBar );
     y2L = y1L + ( slopeL * ( x2L - x1L ) );
    
     SetChartOptions( 0, chartShowDates );
     _N( Title = StrFormat( "{{NAME}} {{DATE}} O %g, H %g, L %g, C %g", O, H, L, C ) + WriteIf( Nz( V, 0 ) == 0, "", ", Vol " + V ) );
     Plot( C, "", colorDefault, styleCandle );
     Plot( laH, "", colorGreen, styleLine | styleThick | styleNoRescale, Null, Null, 0, 0, 4 );
     Plot( laL, "", colorBrown, styleLine | styleNoRescale, Null, Null, 0, 0, 4 );
    
     GfxSetZOrder( 0 );
     GfxSelectPen( colorBrightGreen, 1 );
     GfxMoveTo( x1H, y1H );
     GfxLineTo( x2H, y2H );
     GfxSelectPen( colorRed, 1 );
     GfxMoveTo( x1L, y1L );
     GfxLineTo( x2l, y2L );
    
     RequestMouseMoveRefresh();
_SECTION_END();
Snips.gif
 
Thank you bbhanushali. Appreciate your response.
What I was looking for is only from a exploration perspective. Since I dont see the scrips in your screen shot not sure.
Will cite with an example, Auropharma Buy, then I should get the next signal for Auropharma only if the buy changes to a Sell. In my case, I keep getting the same signal for Auropharma throughout with Buy depending upon the interval chosen.

I hope you understand now. Will try your code any way.

Many thanks bro,
Cheers
JS
 

Similar threads