Simple Coding Help - No Promise.

amitrandive

Well-Known Member
Dear All
How can I get the following values?
1)Highest High of the last 10 bars(HH10)
2)Highest high of the last 30 bars preceding HH10.
3)A buy signal at the next bar or above HH10.
I have afl which shows highest high of last 7 days, check if this can be useful after modification

Code:
_SECTION_BEGIN("7D Pivot Range");
Plot( C, "Close", ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
snTDC=TimeFrameGetPrice( "C", inDaily, -1);
sndh1=TimeFrameGetPrice( "H", inDaily, -1);
sndh2=TimeFrameGetPrice( "H", inDaily, -2);
sndh3=TimeFrameGetPrice( "H", inDaily, -3);
sndh4=TimeFrameGetPrice( "H", inDaily, -4);
sndh5=TimeFrameGetPrice( "H", inDaily, -5);
sndh6=TimeFrameGetPrice( "H", inDaily, -6);
sndh7=TimeFrameGetPrice( "H", inDaily, -7);
sndh8=TimeFrameGetPrice( "H", inDaily, -7);
sndl1=TimeFrameGetPrice( "l", inDaily, -1);
sndl2=TimeFrameGetPrice( "l", inDaily, -2);
sndl3=TimeFrameGetPrice( "l", inDaily, -3);
sndl4=TimeFrameGetPrice( "l", inDaily, -4);
sndl5=TimeFrameGetPrice( "l", inDaily, -5);
sndl6=TimeFrameGetPrice( "l", inDaily, -6);
sndl7=TimeFrameGetPrice( "l", inDaily, -7);
sndl8=TimeFrameGetPrice( "l", inDaily, -7);

snMaxh1=Max(sndh1,sndh2);
snMaxh2=Max(sndh3,sndh4);
snMaxh3=Max(sndh5,sndh6);
snMaxh4=Max(sndh7,sndh8);

snMaxh=Max(Max(snMaxh1,snMaxh2), Max(snMaxh3,snMaxh4));


snMinl1=Min(sndl1,sndl2);
snMinl2=Min(sndl3,sndl4);
snMinl3=Min(sndl5,sndl6);
snMinl4=Min(sndl7,sndl8);

snMinl=Min(Min(snMinl1,snMinl2), Min(snMinl3,snMinl4));

snTDPP = (snMaxh + snMinl + snTDC)/3;
snPP2 = (snMaxh + snMinl)/2;
snDif  = abs(snTDPP-snPP2);
snPPU = snTDPP + snDif;
snPPL = snTDPP - snDif;

Plot (snTDPP,"",colorYellow,1);
Plot(snPPU, "",colorYellow,styleDashed);
Plot(snPPL, "",colorYellow,styleDashed);


Title = EncodeColor(colorWhite)+ "" + "" + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorBlue) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+" 3dh= "+WriteVal(snMaxh)+" 3dL= "+WriteVal(snMinl);

_SECTION_END();
Nehal_s143

Thanks , but preferably would like to have this on a smaller time frame ,say 5 min.
 

kiran_thiru

Well-Known Member
@trash and fxarun , thanks you for your efforts guys:thumb::thumb::thumb: , its actually quite similar to what i needed , with some additions still needed , can you guys please add following into the AFL..please:clapping::clapping:

1-custom color change settings and plotting lines customization

2-i need to draw weekly ,daily as well as monthly pivots simultaneously on the charts too , with option to hide any or all of them

3- i also need to draw all these pivots for previous weeks days and months but with an option to only plot current timeframe like current daily weekly monthly pivot too , just like in the image

4-lastly i need to draw pivots for customizable time frame too , all in the same chart , i mean separate from daily, weekly and monthly .............for example if i could draw pivot for 10 days only in addition to daily weekly and monthly.all four in same chart , all customizable colors enabled to distinguish

i know guys i asked for a lot from you and i know its a lot of work , but i will be highly obliged to you if you could do that ............:thumb::thumb::clapping::clapping:

it would look like this for all weekly pivots plotted on charts , its my java chart and it cant plot all 4 types for me , only 1 time frame at a time


@toocool. are you got afl with your customizations. i added that code, but it did not displays chart decreption clearly in white back ground.
if you have all customizable options afl share with us.
 

trash

Well-Known Member
Works well for all the other pivot types.
It shows the following error for WF and Floor Pivots.
Please advise.
It had a leftover ( 'Pivot ==' ) from the old code in it.

Code:
_SECTION_BEGIN("Multi Pivots");
//Modified and added extended floor pivots  from ("Multi Pivots -StockManiacs") by fxarun;
// modified by trash

SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
Plot( C, "Close", IIf( C > Ref( C, -1 ), colorWhite , IIf( C < Ref( C, -1 ), colorSkyblue , colorYellow ) ), 64 );

RColor = ParamColor( "Resistance Color", colorOrange );//
SColor = ParamColor( "Support Color", colorBrightGreen );//
PColor = ParamColor( "Pivot Color", colorYellow );//
style = ParamStyle( "Style", 0, maskDefault );

T_F = ParamList( "Pivot T_F", "iDay|Hourly|2_Hrs|3_Hrs|4_Hrs|EOD|Weekly|Monthly" );

switch ( T_F )
{
	case "iDay":
		tmfrm = inDaily;
		delay = -1;
		break;
	case "Hourly":
		tmfrm = inHourly;
		delay = -1;
		break;
	case "2_Hrs":
		tmfrm = inHourly * 2;
		delay = -1;
		break;

	case "3_Hrs":
		tmfrm = inHourly * 3;
		delay = -1;
		break;

	case "4_Hrs":
		tmfrm = inHourly * 4;
		delay = -1;
		break;

	case "EOD":
		tmfrm = inDaily;
		delay = 0;
		break;

	case "Weekly":
		tmfrm = inWeekly;
		delay = -1;
		break;

	case "Monthly":
		tmfrm = inMonthly;
		delay = -1;
		break;

	default:
		break;
}

H_1 = TimeFrameGetPrice( "H", tmfrm, -delay );
L_1 = TimeFrameGetPrice( "L", tmfrm, -delay );
C_1 = TimeFrameGetPrice( "C", tmfrm, -delay );
O_1 = TimeFrameGetPrice( "O", tmfrm );


// To calculate the Pivot Levels
R = H_1 - L_1; // Range
_N(Pivot =ParamList("Pivot Type ", "Classical|Woodies|Fibonacci|WF|FloorPivots"));

switch ( Pivot )
{
	case "Classical":
		PP = ( H_1 + L_1 + C_1 ) / 3;
		r1 = ( 2 * PP ) - L_1 ;
		s1 = ( 2 * PP ) - H_1 ;
		r2 = PP - s1 + r1;
		s2 = PP - ( r1 - s1 ) ;
		r3 = 2 * ( PP - L_1 ) + H_1 ;
		s3 = L_1 - ( 2 * ( H_1 - PP ) );
		r4 = Null;
		s4 = Null;
		bc = Null;
		tc = Null;
		break;

	case "Woodies":
		PP = ( H_1 + L_1 + C_1 + O_1 ) / 4;
		r1 = ( 2 * PP ) - L_1;
		r2 = PP + R;
		r3 = H_1 + 2 * ( PP - L_1 );
		r4 = r3 + R;
		s1 = ( 2 * PP ) - H_1;
		s2 = PP - R;
		s3 = L_1 - 2 * ( H_1 - PP );
		s4 = S3 - R;
		bc = Null;
		tc = Null;
		break;

	case "Fibonacci":
		PP = ( H_1 + L_1 + C_1 ) / 3;
		r3 = PP + 1.000 * R;
		r2 = PP + 0.618 * R;
		r1 = PP + 0.382 * R;
		s1 = PP - 0.382 * R;
		s2 = PP - 0.618 * R;
		s3 = PP - 1.000 * R;
		r4 = Null;
		s4 = Null;
		bc = Null;
		tc = Null;
		break;

	case "WF":
		PP = ( H_1 + L_1 + O_1 + O_1 ) / 4;
		s1 = PP - ( R * 0.38 );
		s2 = PP - ( R * 0.62 );
		s3 = PP - ( R * 1.272 );
		r1 = PP + ( R * 0.38 );
		r2 = PP + ( R * 0.62 );
		r3 = PP + ( R * 1.272 );
		r4 = Null;
		s4 = Null;
		bc = Null;
		tc = Null;
		break;

	case "FloorPivots":
		PP = ( H_1 + L_1 + C_1 ) / 3;
		r1 = ( 2 * PP ) - L_1  ;
		s1 = ( 2 * PP ) - H_1;
		r2 = PP + R;
		s2 = PP - R;
		r3 = R1 + R;
		s3 = S1 - R;
		r4 = R3 + ( R2 - R1 );
		s4 = S3 - ( S1 - S2 );
		bc = ( H_1 + L_1 ) / 2;
		tc = ( PP - bc ) + PP;
		break;

	default:
		break;
}

// Plot Pivot Levels in the charts
Plot ( PP, "PP", Pcolor, style );
Plot ( r1, "R1", Rcolor, style );
Plot ( r2, "R2", Rcolor, style );
Plot ( r3, "R3", Rcolor, style );
Plot ( s1, "S1", Scolor, style );
Plot ( s2, "S2", Scolor, style );
Plot ( s3, "S3", Scolor, style );
Plot ( r4, "R4", Rcolor, style );
Plot ( s4, "S4", Scolor, style );
Plot ( tc, "TC", colorWhite, style );
Plot ( bc, "BC", colorWhite, style );
_SECTION_END();
 

amitrandive

Well-Known Member
It had a leftover ( 'Pivot ==' ) from the old code in it.

Code:
_SECTION_BEGIN("Multi Pivots");
//Modified and added extended floor pivots  from ("Multi Pivots -StockManiacs") by fxarun;
// modified by trash

SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
Plot( C, "Close", IIf( C > Ref( C, -1 ), colorWhite , IIf( C < Ref( C, -1 ), colorSkyblue , colorYellow ) ), 64 );

RColor = ParamColor( "Resistance Color", colorOrange );//
SColor = ParamColor( "Support Color", colorBrightGreen );//
PColor = ParamColor( "Pivot Color", colorYellow );//
style = ParamStyle( "Style", 0, maskDefault );

T_F = ParamList( "Pivot T_F", "iDay|Hourly|2_Hrs|3_Hrs|4_Hrs|EOD|Weekly|Monthly" );

switch ( T_F )
{
	case "iDay":
		tmfrm = inDaily;
		delay = -1;
		break;
	case "Hourly":
		tmfrm = inHourly;
		delay = -1;
		break;
	case "2_Hrs":
		tmfrm = inHourly * 2;
		delay = -1;
		break;

	case "3_Hrs":
		tmfrm = inHourly * 3;
		delay = -1;
		break;

	case "4_Hrs":
		tmfrm = inHourly * 4;
		delay = -1;
		break;

	case "EOD":
		tmfrm = inDaily;
		delay = 0;
		break;

	case "Weekly":
		tmfrm = inWeekly;
		delay = -1;
		break;

	case "Monthly":
		tmfrm = inMonthly;
		delay = -1;
		break;

	default:
		break;
}

H_1 = TimeFrameGetPrice( "H", tmfrm, -delay );
L_1 = TimeFrameGetPrice( "L", tmfrm, -delay );
C_1 = TimeFrameGetPrice( "C", tmfrm, -delay );
O_1 = TimeFrameGetPrice( "O", tmfrm );


// To calculate the Pivot Levels
R = H_1 - L_1; // Range
_N(Pivot =ParamList("Pivot Type ", "Classical|Woodies|Fibonacci|WF|FloorPivots"));

switch ( Pivot )
{
	case "Classical":
		PP = ( H_1 + L_1 + C_1 ) / 3;
		r1 = ( 2 * PP ) - L_1 ;
		s1 = ( 2 * PP ) - H_1 ;
		r2 = PP - s1 + r1;
		s2 = PP - ( r1 - s1 ) ;
		r3 = 2 * ( PP - L_1 ) + H_1 ;
		s3 = L_1 - ( 2 * ( H_1 - PP ) );
		r4 = Null;
		s4 = Null;
		bc = Null;
		tc = Null;
		break;

	case "Woodies":
		PP = ( H_1 + L_1 + C_1 + O_1 ) / 4;
		r1 = ( 2 * PP ) - L_1;
		r2 = PP + R;
		r3 = H_1 + 2 * ( PP - L_1 );
		r4 = r3 + R;
		s1 = ( 2 * PP ) - H_1;
		s2 = PP - R;
		s3 = L_1 - 2 * ( H_1 - PP );
		s4 = S3 - R;
		bc = Null;
		tc = Null;
		break;

	case "Fibonacci":
		PP = ( H_1 + L_1 + C_1 ) / 3;
		r3 = PP + 1.000 * R;
		r2 = PP + 0.618 * R;
		r1 = PP + 0.382 * R;
		s1 = PP - 0.382 * R;
		s2 = PP - 0.618 * R;
		s3 = PP - 1.000 * R;
		r4 = Null;
		s4 = Null;
		bc = Null;
		tc = Null;
		break;

	case "WF":
		PP = ( H_1 + L_1 + O_1 + O_1 ) / 4;
		s1 = PP - ( R * 0.38 );
		s2 = PP - ( R * 0.62 );
		s3 = PP - ( R * 1.272 );
		r1 = PP + ( R * 0.38 );
		r2 = PP + ( R * 0.62 );
		r3 = PP + ( R * 1.272 );
		r4 = Null;
		s4 = Null;
		bc = Null;
		tc = Null;
		break;

	case "FloorPivots":
		PP = ( H_1 + L_1 + C_1 ) / 3;
		r1 = ( 2 * PP ) - L_1  ;
		s1 = ( 2 * PP ) - H_1;
		r2 = PP + R;
		s2 = PP - R;
		r3 = R1 + R;
		s3 = S1 - R;
		r4 = R3 + ( R2 - R1 );
		s4 = S3 - ( S1 - S2 );
		bc = ( H_1 + L_1 ) / 2;
		tc = ( PP - bc ) + PP;
		break;

	default:
		break;
}

// Plot Pivot Levels in the charts
Plot ( PP, "PP", Pcolor, style );
Plot ( r1, "R1", Rcolor, style );
Plot ( r2, "R2", Rcolor, style );
Plot ( r3, "R3", Rcolor, style );
Plot ( s1, "S1", Scolor, style );
Plot ( s2, "S2", Scolor, style );
Plot ( s3, "S3", Scolor, style );
Plot ( r4, "R4", Rcolor, style );
Plot ( s4, "S4", Scolor, style );
Plot ( tc, "TC", colorWhite, style );
Plot ( bc, "BC", colorWhite, style );
_SECTION_END();
Thanks trash
Working now!!!
:clap:
 

xsis

Active Member
dear traders and coders

i want a simple afl which automatically plots fib levels including extension levels on either side on the basis of yest's range i.e high-low. for example, on today's chart, i want fib levels of yest's range i.e. high-low
i tried finding it on web but failed! pls help!

thks
 

Nehal_s143

Well-Known Member
dear traders and coders

i want a simple afl which automatically plots fib levels including extension levels on either side on the basis of yest's range i.e high-low. for example, on today's chart, i want fib levels of yest's range i.e. high-low
i tried finding it on web but failed! pls help!

thks
xsis, dig the thread it has been already given recently some few pages back... :thumb:
 

KelvinHand

Well-Known Member
Last edited:

manishchan

Well-Known Member
Hi Friends,

I'm looking for multi timeframe MACD (with lines and histogram) and ADX. Please share if anyone has it. Or if you can possibly code it.

Thanks in advance. :)
 

amitrandive

Well-Known Member
Hi Friends,

I'm looking for multi timeframe MACD (with lines and histogram) and ADX. Please share if anyone has it. Or if you can possibly code it.

Thanks in advance. :)
For MACD try this

www.wi sesto cktrader.com/indicators/1721-macd-time-frame

For ADX try this

www.wis estoc ktrader.com/indicators/1937-adx-with-multiple-timeframe

Have not tried,see if it works.
 

Similar threads