sum gud afl components code

bunti_k23

Well-Known Member
#1
hello guys here are sum afl codes which i have extracted from the bunch of useless afl s ,these are not trading systems but you can see it as extra accessories for any afl .you can copy this individual codes to any afl u want ,enjoy:)


1- this code will plot the trailling stoploss line .


res=HHV(Hahigh,4);
sup=LLV(Halow,4);
tsl=IIf(ValueWhen(IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0))!=0,IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0)),1)==1,sup,res);

Plot(tsl, _DEFAULT_NAME(), colorWhite, styleStaircase);


2- this code will plot targets in %terms with dashboard specifying all details ,here there is sum problem sl which is displayed in dashboard rest all is fine.


NW[0] = 0;
NW[BarCount-1] = Null;
for(i=BarCount-1;i>1;i--)
{
if(Buy == 1)
{
entry = H;
sig = "BUY";
sl = Ref(NW,-1);
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
if(Sell == 1)
{
sig = "SELL";
entry = L;
sl = Ref(NW,-1);
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, NW[BarCount-1], Ref(NW, -1));
sl = ssl[BarCount-1];

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);



messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ;
GfxTextOut( ( "bunti_k23"),13,y-100);
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
/*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);

}


3- this code will plot ribbon which is at the bottom on your chart.


_SECTION_BEGIN("trending ribbon");
uptrend=PDI()>MDI() AND MACD()>Signal();
downtrend=MDI()>PDI() AND Signal()>MACD();
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();


4- this code will plot magnified market price.

_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",350,800,800,800);
Ver=Param("Vertical Position",50,27,27,27);
GfxTextOut(""+C,Hor+250 , Ver-53 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+250, Ver-1 );
_SECTION_END();


5- this code will plot higher highs hl lh and ll.


//This Section is For HH HL LH LL //
Q = Param( "% Change", 0.6, 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 )
PlotText( "H TOP ", i, H[ i ] + dist, colorYellow );

if ( LH )
PlotText( "L TOP", i, H[ i ] + dist, colorYellow );

if ( HL )
PlotText( "H Bottom", i, L[ i ] - dist, colorYellow );

if ( LL )
PlotText( "L Bottom", i, L[ i ] - dist, colorYellow );

}



6- this code will plot hekeinshi candles synchronised with moving average (can be varied from parameter window)


/*
Heikin-Ashi(Koma-Ashi) with Moving Average Type
*/
SetChartOptions(2, chartWrapTitle);

// Calculate Moving Average
MAPeriod = Param("MA Period", 15, 1, 100);
MAOpen = EMA(Open, MAPeriod);
MAHigh = EMA(High, MAPeriod);
MALow = EMA(Low, MAPeriod);
MAClose = EMA(Close, MAPeriod);

HaClose = (MAOpen + MAHigh + MALow + MAClose) / 4;
HaOpen = AMA(Ref(HaClose, -1), 0.5);

// for graph collapse
for(i = 0; i <= MAPeriod; i++) HaClose = Null;
/*
// same
// HaOpen = (Ref(HaOpen, -1) + Ref(HaClose, -1)) / 2;
HaOpen[ 0 ] = HaClose[ 0 ];
for(i = 1; i < BarCount; i++) {
HaOpen = (HaOpen[i - 1] + HaClose[i - 1]) / 2;
}
*/

HaHigh = Max(MAHigh, Max(HaClose, HaOpen));
HaLow = Min(MALow, Min(HaClose, HaOpen));

// outs comments
"BarIndex = " + BarIndex();
"Open = " + Open;
"High = " + High;
"Low = " + Low;
"Close = "+ Close;
"HaOpen = " + HaOpen;
"HaHigh = " + HaHigh;
"HaLow = " + HaLow;
"HaClose = "+ HaClose;

// Plot graphs
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} HaOpen %g, HaHigh %g,
HaLow %g, HaClose %g (%.1f%%) {{VALUES}}",
HaOpen, HaHigh, HaLow, HaClose, SelectedValue(ROC( HaClose, 1))));
PlotOHLC(HaOpen, HaHigh, HaLow, HaClose, _DEFAULT_NAME(), ParamColor("Color",
colorBlack), styleCandle);

_SECTION_BEGIN("Colour Tap");
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
_SECTION_END();


7- this code will plot ema line.

e45 = EMA(C,45);
Plot(e45,"E45",colorGreen);

8- this code will plot donchian channels

// Plots a 20 period Donchian channel

pds=20;
DonchianUpper =HHV(Ref(H,-1),pds);
DonchianLower = LLV(Ref(L,-1),pds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;


Plot(DonchianUpper,"DU",colorBlue,styleLine);
Plot(DonchianMiddle,"DM",colorGreen,styleLine);
Plot(DonchianLower,"DL",colorRed,styleLine);
 

pareshR

Well-Known Member
#3
hello guys here are sum afl codes which i have extracted from the bunch of useless afl s ,these are not trading systems but you can see it as extra accessories for any afl .you can copy this individual codes to any afl u want ,enjoy:)


5- this code will plot higher highs hl lh and ll.

//This Section is For HH HL LH LL //
Q = Param( "% Change", 0.6, 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 )
PlotText( "H TOP ", i, H[ i ] + dist, colorYellow );
if ( LH )
PlotText( "L TOP", i, H[ i ] + dist, colorYellow );
if ( HL )
PlotText( "H Bottom", i, L[ i ] - dist, colorYellow );
if ( LL )
PlotText( "L Bottom", i, L[ i ] - dist, colorYellow );

}


Hello

can you help me how this r HH HL LH LL working or any link so i go through

thx
 

amitrandive

Well-Known Member
#4
hello guys here are sum afl codes which i have extracted from the bunch of useless afl s ,these are not trading systems but you can see it as extra accessories for any afl .you can copy this individual codes to any afl u want ,enjoy:)


5- this code will plot higher highs hl lh and ll.

//This Section is For HH HL LH LL //
Q = Param( "% Change", 0.6, 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 )
PlotText( "H TOP ", i, H[ i ] + dist, colorYellow );
if ( LH )
PlotText( "L TOP", i, H[ i ] + dist, colorYellow );
if ( HL )
PlotText( "H Bottom", i, L[ i ] - dist, colorYellow );
if ( LL )
PlotText( "L Bottom", i, L[ i ] - dist, colorYellow );

}


Hello

can you help me how this r HH HL LH LL working or any link so i go through

thx


Try dragging the price on the chart with this AFL , or try the below code.

The posting mention AFL components , not entire AFL's

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

Q = Param( "% Change", 0.6, 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( "H TOP ", i, H[ i ] + dist[i], colorYellow );
if ( LH[i] )
PlotText( "L TOP", i, H[ i ] + dist[i], colorYellow );
if ( HL[i] )
PlotText( "H Bottom", i, L[ i ] - dist[i], colorYellow );
if ( LL[i] )
PlotText( "L Bottom", i, L[ i ] - dist[i], colorYellow );
}
 

pareshR

Well-Known Member
#5
Try dragging the price on the chart with this AFL , or try the below code.

The posting mention AFL components , not entire AFL's

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

Q = Param( "% Change", 0.6, 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( "H TOP ", i, H[ i ] + dist[i], colorYellow );
if ( LH[i] )
PlotText( "L TOP", i, H[ i ] + dist[i], colorYellow );
if ( HL[i] )
PlotText( "H Bottom", i, L[ i ] - dist[i], colorYellow );
if ( LL[i] )
PlotText( "L Bottom", i, L[ i ] - dist[i], colorYellow );
}

Hello


how to add alert sound when HH,LH,HL, LL develop ?

thanks for ur help
thx
 

amsin21

Well-Known Member
#6
Hello


how to add alert sound when HH,LH,HL, LL develop ?

thanks for ur help
thx
//Alerts

AlertIf( HH, "SOUND c:/alert.wav", "Audio alert",0,1+2+4+8);
AlertIf( LH, "SOUND c:/alert.wav", "Audio alert",0,1+2+4+8);
AlertIf( HL, "SOUND c:/alert.wav", "Audio alert",0,1+2+4+8);
AlertIf( LL, "SOUND c:/alert.wav", "Audio alert",0,1+2+4+8);

//Speech to text

if(LastValue(HH)) Say(Name()+"Higher high",purge = True);
if(LastValue(LH)) Say(Name()+"Lower high",purge = True);
if(LastValue(HL)) Say(Name()+"Higher low",purge = True);
if(LastValue(LL)) Say(Name()+"Lower low",purge = True);

I'm not sure, it should be out of the loop or inside, maybe above experts can help
 

bunti_k23

Well-Known Member
#7
this code will plot instant support and resistances ,according to me its the best code.:thumb:



_SECTION_BEGIN("supp");
("Price");
RSIperiod = 15; // Param("RSI p",3,14,30,1);
Percent = 5; // Param("ZIG %",8,9,15,1);
EMAperiod = 5; //Param("EMA p",4,5,10,1);
HHVperiod = 8; //Param("HHV p",3,5,10,1);
NumLine = 2; //Param("Num Lines",3,1,20,1);

Base = DEMA(RSI(RSIperiod),EMAperiod);

GraphXSpace=0.5;


for( i = 1; i <= numline; i++ )
{
ResBase = LastValue(Peak(Base,Percent,i));
SupBase = LastValue(Trough(Base,Percent,i));
Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleLine);
Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleLine);
}

_SECTION_END();
 

pareshR

Well-Known Member
#8
Try dragging the price on the chart with this AFL , or try the below code.

The posting mention AFL components , not entire AFL's

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

Q = Param( "% Change", 0.6, 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( "H TOP ", i, H[ i ] + dist[i], colorYellow );
if ( LH[i] )
PlotText( "L TOP", i, H[ i ] + dist[i], colorYellow );
if ( HL[i] )
PlotText( "H Bottom", i, L[ i ] - dist[i], colorYellow );
if ( LL[i] )
PlotText( "L Bottom", i, L[ i ] - dist[i], colorYellow );
}
Hello Amit

HH,LH,HL, LL message come on chart delay, say between 10 to 30 minutes ,

so how to get real time HH,LH,HL , LL alerts ?


thx
paresh
 

bunti_k23

Well-Known Member
#9
guys anyone know how to extract the chandillier exit system from the turtle system,i want to plot that yellow line (from turtle system) on a plane chart,i tried by direct copying but there is condition for that line it will start from ur buying signal ,but on plane chart there is no buying signal :annoyed: ,so how to get the continous yellow line...:(
 

Similar threads