Simple Coding Help - No Promise.

amitrandive

Well-Known Member
Here is an attempt - presuming that all HHs & LLs need to be marked. But if we visually inspect the charts - there are cases where these HHs & LLs need not be a major turning point and there are other points that would qualify. I suppose that is the power of human brain.

There seems to be quite a few methods to draw a horizontal line and 2 methods given here seem to be the simplest. Feel free to change the shape, color and width of the horizontal lines.

Code:
_SECTION_BEGIN("HH");
Q = Param( "% Change", 2, 0.1, 10, 0.1 );
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 );

for ( i = 0; i < BarCount; i++ )
{
	if ( HH[i] ){
		PlotText( "HH", i, H[ i ] + dist[i], colorRed );
		PlotText( "=======================", i, H[i], colorRed);
	}
	if ( LH[i] )
		PlotText( "LH", i, H[ i ] + dist[i], colorRed );

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

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

/*
width=5;

for ( j = 0; j > width*-1; j--) {
	PlotShapes( IIf(Ref(HH,j),shapeStar,shapeNone), colorRed, layer=0, yposition=Ref(H,j), Offset=0 );
	PlotShapes( IIf(Ref(LL,j),shapeStar,shapeNone), colorBrightGreen, layer=0, yposition=Ref(L,j), Offset=0 );
}

*/

Filter=HH OR HL OR LH OR LL;
AddColumn(RSI(2),"RSI",1.2);
AddColumn(Close,"PRICE",1.2);
AddColumn(HH,"SHORT");
AddColumn(LH,"LH");
AddColumn(HL,"HL");
AddColumn(LL,"COVER");
AddColumn(V,"volume",1.0);
_SECTION_END();

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
Plot( IIf(HL==1,Close,Null), "Close", colorPink, styleLine );
Plot( IIf(Ref(HL,-1)==1,Close,Null), "Close", colorPink, styleLine );
Plot( IIf(Ref(HL,-2)==1,Close,Null), "Close", colorPink, styleLine );
Plot( IIf(Ref(HL,-3)==1,Close,Null), "Close", colorPink, styleLine );


_SECTION_END();
TechQuant

Is it possible to have an exploration for the HH,HL,LH and LL values on a daily time frame or any time frame?:confused:
 
TechQuant

Is it possible to have an exploration for the HH,HL,LH and LL values on a daily time frame or any time frame?:confused:
Just add the high & low columns to the exploration:

Code:
Filter=HH OR HL OR LH OR LL;
AddColumn(RSI(2),"RSI",1.2);
AddColumn(Close,"PRICE",1.2);
AddColumn(High,"High",1.2);
AddColumn(Low,"Low",1.2);
AddColumn(HH,"SHORT");
AddColumn(LH,"LH");
AddColumn(HL,"HL");
AddColumn(LL,"COVER");
AddColumn(V,"volume",1.0);
Whenever HH & LH have a value of one, then the corresponding High column gives you the HH & LH values. Similarly, whenever HL & LL have a value of one, then the corresponding Low column gives you the HL & LL values.
 
I found AddToComposite working but no idea what 'WL' stands for. And the 'Individual Optimize' button in the image is not present in my amibroker (5.6). It would be really helpful if you could share your code.
WL - watchlist
Individual optimize is part of 5.7.

You said you get it done and haven't even tried yet.

You system code uses switch statement that sets time frame variable (used in Timeframeset) according to time frame info which is part of the created index name of each clone.
 
Last edited:
Hmm... I am working on a couple of AFLs as well and have some other things to do as well. Also, there is no point inventing the wheel again, is there? So if you have already written a code to do the job, why should I waste my time doing it over again? Unless you are willing not to share your 'wheel'.
But others shall "waste" their time for you. I won't post it just like that. I'm not a code breeder on your farm. Where is the quid pro quo?

I am working on a couple of AFLs as well and have some other things to do as well.
lmao!!

I am capable of doing it myself.
 

amitrandive

Well-Known Member
Just add the high & low columns to the exploration:

Code:
Filter=HH OR HL OR LH OR LL;
AddColumn(RSI(2),"RSI",1.2);
AddColumn(Close,"PRICE",1.2);
AddColumn(High,"High",1.2);
AddColumn(Low,"Low",1.2);
AddColumn(HH,"SHORT");
AddColumn(LH,"LH");
AddColumn(HL,"HL");
AddColumn(LL,"COVER");
AddColumn(V,"volume",1.0);
Whenever HH & LH have a value of one, then the corresponding High column gives you the HH & LH values. Similarly, whenever HL & LL have a value of one, then the corresponding Low column gives you the HL & LL values.
TechQuant

Thanks for the prompt reply, this works great:clap::clap::clap:
 

Nehal_s143

Well-Known Member
Sir

please see below Nifty1 hourly chart and Nifty has respected so many times the historical Support and Resistance marked with yellow round



Every time Nifty touch Hist S&R its not buy or sell but we can be alert at this levels




Here is an attempt - presuming that all HHs & LLs need to be marked. But if we visually inspect the charts - there are cases where these HHs & LLs need not be a major turning point and there are other points that would qualify. I suppose that is the power of human brain.

There seems to be quite a few methods to draw a horizontal line and 2 methods given here seem to be the simplest. Feel free to change the shape, color and width of the horizontal lines.

Code:
_SECTION_BEGIN("HH");
Q = Param( "% Change", 2, 0.1, 10, 0.1 );
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 );

for ( i = 0; i < BarCount; i++ )
{
	if ( HH[i] ){
		PlotText( "HH", i, H[ i ] + dist[i], colorRed );
		PlotText( "=======================", i, H[i], colorRed);
	}
	if ( LH[i] )
		PlotText( "LH", i, H[ i ] + dist[i], colorRed );

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

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

/*
width=5;

for ( j = 0; j > width*-1; j--) {
	PlotShapes( IIf(Ref(HH,j),shapeStar,shapeNone), colorRed, layer=0, yposition=Ref(H,j), Offset=0 );
	PlotShapes( IIf(Ref(LL,j),shapeStar,shapeNone), colorBrightGreen, layer=0, yposition=Ref(L,j), Offset=0 );
}

*/

Filter=HH OR HL OR LH OR LL;
AddColumn(RSI(2),"RSI",1.2);
AddColumn(Close,"PRICE",1.2);
AddColumn(HH,"SHORT");
AddColumn(LH,"LH");
AddColumn(HL,"HL");
AddColumn(LL,"COVER");
AddColumn(V,"volume",1.0);
_SECTION_END();

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
Plot( IIf(HL==1,Close,Null), "Close", colorPink, styleLine );
Plot( IIf(Ref(HL,-1)==1,Close,Null), "Close", colorPink, styleLine );
Plot( IIf(Ref(HL,-2)==1,Close,Null), "Close", colorPink, styleLine );
Plot( IIf(Ref(HL,-3)==1,Close,Null), "Close", colorPink, styleLine );


_SECTION_END();
 

Nehal_s143

Well-Known Member
sir you may refer chapter 4 you will get clear idea about Historical support and resistance

link to download ebook

http : // www . 4shared . com /office/rWYkIQk0/Alex_Nekritin__Walter_Peters__.html

Admin, hope posting download link is allowed, if not, please remove link, will send link to interested member by PM
 
Hi Pratap,

There is some logical error here. (not the coding error). can u suggest how can I get candles with long wicks. on either side.
Comparing the shadow with absolute price will give you different results for stocks with high price (eg 500) in comparison to a stock with low price (eg 50). The length of the shadow should be compared to the size of the body.

Code:
UpperShadow = H - Max(O,C);
LowerShadow = Min(O,C) - L;
Body = IIf(abs(O-C) == 0, 1, abs(O-C));
Filter = (UpperShadow/Body > 3) OR (LowerShadow/Body > 3);
 

Similar threads