Informative AFL

#1
Useful afl for all. :clap:
Use it and comment.

AFL NO:1

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



tchoice=Param("Title Selection ",2,1,2,1);

Q=Param("% Change",2.1,1,10,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( "HH", i, H[ i ]+dist, colorCustom12 );
if( LH ) PlotText( "LH", i, H[ i ]+dist, colorCustom12 );
if( HL ) PlotText( "HL", i, L[ i ]-dist, colorAqua );
if( LL ) PlotText( "LL", i, L[ i ]-dist, colorAqua );

}
TimeFrameSet(inDaily);
MA3 = MA(C,3);
Cl = C;
TimeFrameRestore();
MA3=(TimeFrameExpand( MA3, inDaily));
Cl=(TimeFrameExpand( Cl, inDaily));
barcolor =IIf(C > MA3 , colorGreen,IIf(C < MA3,colorRed, colorBlack) );
Plot( C, "Close", barcolor , styleNoTitle |styleCandle);
Plot(MA(H,12),"", colorYellow, styleLine);


Evalue = SelectedValue(C);
V1 = Evalue -(Evalue *0.8/100);
V2 = Evalue -((Evalue- V1)/2);
V3 = V1 -(Evalue * 0.00866);
Plot(V1,"v1",colorGreen, styleLine|styleNoRescale);
//Plot(V2,"v2",colorGreen, styleLine|styleNoRescale);
Plot(V3,"v3",colorGreen, styleLine|4+8+2048);

Evalue = SelectedValue(C);
V4 = Evalue+(Evalue *0.008);
V5 = Evalue +(( V4-Evalue )/2);
V6 = V4 +(Evalue * 0.00866);


Plot(V4,"v4",colorRed, styleLine|styleNoRescale);

//Plot(V5,"v5",colorRed, styleLine|styleNoRescale);

Plot(V6,"v6",colorRed, styleLine|4+8+2048);



Evalue = (V3);
V7 = Evalue -(Evalue *0.8/100);
V8 = Evalue -((Evalue- V7)/2);
V9 = V7 -(Evalue * 0.00866);
Plot(V7,"v7",colorPink, styleLine|styleNoRescale);
//Plot(V8,"v8",colorPink, styleLine|styleNoRescale);
Plot(V9,"v9",colorPink, styleLine|4+8+2048);

Evalue =(V6);
V10 = Evalue+(Evalue *0.008);
V11 = Evalue +(( V10-Evalue )/2);
V12 = V10 +(Evalue * 0.00866);


Plot(V10,"v10",colorCustom12, styleLine|styleNoRescale);

//Plot(V11,"v11",colorCustom12, styleLine|styleNoRescale);

Plot(V12,"v12",colorCustom12, styleLine|4+8+2048);


Evalue = (V9);
V13 = Evalue -(Evalue *0.8/100);
V14 = Evalue -((Evalue- V7)/2);
V15 = V13 -(Evalue * 0.00866);
Plot(V13,"v13",colorGold, styleLine|styleNoRescale);
//Plot(V14,"v14",colorGOLD, styleLine|styleNoRescale);
Plot(V15,"v15",colorGold, styleLine|4+8+2048);

Evalue =(V12);
V16 = Evalue+(Evalue *0.008);
V17 = Evalue +(( V10-Evalue )/2);
V18 = V16 +(Evalue * 0.00866);


Plot(V16,"v16",colorViolet, styleLine|styleNoRescale);

//Plot(V17,"v17",colorVIOLET, styleLine|styleNoRescale);

Plot(V18,"v18",colorViolet, styleLine|4+8+2048);









H1 = TimeFrameGetPrice("H", inDaily, -3); // yesterdays high
L1 = TimeFrameGetPrice("L", inDaily, -3); // low
C1= TimeFrameGetPrice("C", inDaily, -3); // close
//DayO = TimeFrameGetPrice("O", inDaily); // current day open


// PIVOT Calculation
P = ( H1+ L1 + C1 )/3;
R1 = (2*P)-L1;
R2 = P +(H1 - L1);
R3 = R1 +(H1-L1);
R4 = R2 +(H1-L1);
R5 = R3 +(H1-L1);
R6 = R4 +(H1-L1);
R7 = R5 +(H1-L1);
R8 = R6 +(H1-L1);
R9 = R7 +(H1-L1);
R10 = R8 +(H1-L1);
R11 = R9 +(H1-L1);

S1 = (2*P)-H1;
S2 = P -(H1 - L1);
S3 = S1 - (H1-L1);
S4 = S2 - (H1-L1);
S5 = S3 - (H1-L1);
S6 = S4 - (H1-L1);
S7 = S5 - (H1-L1);
S8 = S6 - (H1-L1);
S9 = S7 - (H1-L1);
S10 = S8 - (H1-L1);
S11 = S9 - (H1-L1);


// PIVOT mid points
MIDR1 = (P+R1)/2;
MIDR2 = (R1+R2)/2;
MIDR3 = (R2+R3)/2;
MIDS1 = (P+S1)/2;
MIDS2 = (S1+S2)/2;
MIDS3 = (S2+S3)/2;

//PLOTS
//Plot(R1, "",colorPink,styleDashed+styleNoRescale);
//Plot(R2, "",colorRed,styleLine+styleNoRescale);
//Plot(R3, "",colorRed,styleLine+styleNoRescale);
//Plot(R4, "",colorCustom12,styleLine+styleNoRescale);
//Plot(R5, "",colorCustom12,styleLine+styleNoRescale);
//Plot(R6, "",colorTan,styleLine+styleNoRescale);
//Plot(R7, "",colorPink,styleLine+2048);
//Plot(R8, "",colorTan,4+8+2048);
Plot(R9, "",colorTan,4+8+2048);
Plot(R10, "",colorTan,4+8+2048);
Plot(R11, "",colorTan,4+8+2048);





//Plot(P, "",colorWhite,styleDashed+styleNoRescale);

//Plot(S1, "",colorAqua,styleDashed+styleNoRescale);
//Plot(S2, "",colorAqua,styleLine+styleNoRescale);
//Plot(S3, "",colorAqua,styleLine+styleNoRescale);
//Plot(S4, "",colorGold,styleLine+styleNoRescale);
//Plot(S5, "",colorCustom12,styleLine+styleNoRescale);
//Plot(S6, "",colorTan,styleLine+styleNoRescale);
//Plot(S7, "",colorAqua,styleLine+2048);
//Plot(S8, "",colorTan,4+8+2048);
Plot(S9, "",colorGold,4+8+2048);
Plot(S10, "",colorGold,4+8+2048);
Plot(S11, "",colorGold,4+8+2048);




//Plot(MIDR1, "",colorRose,styleDashed+styleNoRescale);
//Plot(MIDR2, "",colorRose,styleDashed+styleNoRescale);
//Plot(MIDR3, "",colorRose,styleDashed+styleNoRescale);

//Plot(MIDS1, "",colorYellow,styleDashed+styleNoRescale);
//Plot(MIDS2, "",colorYellow,styleDashed+styleNoRescale);
//Plot(MIDS3, "",colorYellow,styleDashed+styleNoRescale);

//Plot(H1, "",colorRed,styleDots+styleNoRescale);
//Plot(L1, "",colorYellow,styleDots+styleNoRescale);

//Plot(C1, "",colorOrange,styleDots+styleNoRescale);


n=130;
per =11.5;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa(C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
//Plot(ValueWhen( (Cross(RSIa(C,n), trendlineS ) OR (S1==trendlineS )), L),"", colorPink, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((Cross(RSIa(C,n),trendlineR )OR (S11==trendlineR )), H),"", colorBrown, styleDashed|styleNoRescale|styleThick);

Buy = (S1==trendlineS );
Sell = (S11==trendlineR );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorWhite , colorCustom12) );
dist = 0.95*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "RSI 130 Buy " + L[ i ], i, L[ i ]-dist, colorWhite );
if( Sell ) PlotText( "RSI 130 Sell " + H[ i ], i, H[ i ]+dist, colorCustom12);
}


Plot(MA(C,210), "MA89",colorCustom12 , 4+8+2048);



MyPeriod = 300;
percent =0.786;// Param("percent ",0.60, 0.1, 10, 0.1);

firstpointL = 3;
firstpointH = 3;

y0=LastValue(Trough(L,percent,firstpointL));
y1=LastValue(Trough(Ref(L,-1),percent,1));

for( i = 1; i < MyPeriod AND y0 >= y1; i++ )

//for( i = 1; i < BarCount AND y0 >= y1; i++ )
{

firstpointL++;
y0=LastValue(Trough(L,percent,firstpointL));
}

x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL));
x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1));
LineL = LineArray( x0, y0, x1, y1, 1 );
/*
Plot(C, "C", colorBlack, styleCandle);
*/
Plot( LineL, " Support Trend line", colorLightOrange,4 +8+2048 );
yt0=LastValue(Peak(H,percent,firstpointH));
yt1=LastValue(Peak(Ref(H,-1),percent,1));

for(i = 1; i < MyPeriod AND yt0 <= yt1; i++ )
//for(i = 1; i < BarCount AND yt0 <= yt1; i++ )
{

firstpointH++;
yt0=LastValue(Peak(H,percent,firstpointH));
}

xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH));
xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1));
LineH = LineArray( xt0, yt0, xt1, yt1, 1 );

Plot( LineH, "Resistance Trend line", colorBrown,4 +8+2048 );



_SECTION_END();

_SECTION_BEGIN( "Chart Settings");
SetChartOptions( 0,chartShowArrows|chartShowDates );
SetChartBkColor( ParamColor( "Outer panel",colorBlack) );
SetChartBkGradientFill(
ParamColor(" Inner panel upper",colorDarkGrey),
ParamColor(" Inner panel lower",colorBlack) );
numbars = LastValue(Cum( Status("barvisible")));
dec = (Param("Decimals" ,2,0,7,1) /10)+1;
bi=BarIndex( );
sbi = BarIndex();

//Plot(C,"",IIf( C>O,27, IIf(C<O,32,colorGrey50)),64) ;

_SECTION_BEGIN( "Fib Levels");
pct = Param( "Pivot %",1.0,0.10, 60,0.10);
fibi = ParamToggle( "Plot IR Fibs","Off|On" ,0);
hLb=Param("High Look Back",1,1,30, 1);
lLb=Param("Low Look Back",1,1,30, 1);
irtxt = ParamToggle( "IR Text Labels","Off| On",0);
fts = Param ("Text H Shift", -36.1,-50,50, 0.10);
//////////// /////////
pk=PeakBars( H,pct)==0;
tr=TroughBars( L,pct)==0;
zHi=Zig(H,pct) ; zLo=Zig(L,pct) ; HLAvg=(zHi+zLo) /2;
zp=IIf(pk,zHi, IIf(tr,zLo, IIf(HLAvg> Ref(HLAvg, -1),H,L)) );
za=Zig(zp,pct) ;
pR=Ref(za,-1) <za AND za>Ref(za,1) ;
pS=Ref(za,-1) >za AND za<Ref(za,1) ;

//Plot(za,"",11, 1|styleNoLabel) ;
//PlotShapes(shapeDownArrow*pR, colorBrightGreen ,0,H,-18) ;
//PlotShapes(shapeUpArrow*pS,colorBrightGreen,0,L,- 18);
//////////// ///////// ///////// ///////// /////////
_SECTION_BEGIN( "Fibs");
xr0=SelectedValue( ValueWhen( pR,sbi,hLb) );
yr0=SelectedValue( ValueWhen( pR,zp,hLb) );
xs0=SelectedValue( ValueWhen( pS,sbi,lLb) );
ys0=SelectedValue( ValueWhen( pS,zp,lLb) );
x1=BarCount- 1;
deltaP=abs(yr0- ys0);
sup=xs0>xr0;
res=xr0>xs0;
respct = IIf(xr0>xs0, 0,100);
suppct = IIf(xs0>xr0, 0,100);
resLp=LineArray( xr0,yr0,x1, yr0,0);
supLp = LineArray(xs0, ys0,x1,ys0, 0);
//////////// ////////
function fibr(fibv)
{
delta=abs(yr0- ys0);
retval=delta* fibv;
fibval=IIf(res, yr0-retval, IIf(sup,ys0+ retval,Null) );
return fibval;
}
//////////// ////Fib Retracements/ ///////// ///////
f236=fibr(0.236);f382= fibr(0.382) ;f500=fibr( 0.500);
f618=fibr(0.618);f786= fibr(0.786) ;f127=fibr( 1.272);
f162=fibr(1.620);f200= fibr(2.000) ;f262=fibr( 2.620);
f314=fibr(3.141);f424= fibr(4.240) ;
//////////// ///////// ///
function ifib(ifib)
{
x0= IIf(res,xr0, xs0);
x1=BarCount- 1;
ifibline=LineArray( x0,ifib,x1, ifib);
return ifibline;
}

if(fibi==1) {
istyle=styleDashed| styleNoLabel| styleNoRescale;
Plot(resLp," ",32,8);
Plot(supLp," ",55,8);
Plot(ifib(f236) ,"",40,istyle) ; Plot(ifib(f382) ,"",36,istyle) ;
Plot(ifib(f500) ,"", 6,istyle); Plot(ifib(f618) ,"",43,istyle) ;
Plot(ifib(f786) ,"",42,istyle) ; Plot(ifib(f127) ,"",10,istyle) ;
Plot(ifib(f162) ,"",34,istyle) ; Plot(ifib(f200) ,"",55,istyle) ;
Plot(ifib(f262) ,"",51,istyle) ; Plot(ifib(f424) ,"",32,istyle) ;
}
if(irtxt==1) {
VizBars = Status("LastVisible Bar")-Status( "FirstVisibleBar ");
Bars = (round(Vizbars/ fts));
mxpos = SelectedValue( BarIndex( ))-(Bars) ;
//////////// ////////
PlotText(StrFormat( "%.2f %.0f % ",resLp,respct) +"%",mxpos, yr0,32);
PlotText(StrFormat( "%.2f %.0f % ",supLp,suppct) +"%",mxpos, ys0,55);
PlotText("" + NumToStr(f236, dec)+ " 23%",mxpos,f236, 40,1);
PlotText("" + NumToStr(f382, dec)+ " 38%",mxpos,f382, 36,1);
PlotText("" + NumToStr(f500, dec)+ " 50%",mxpos,f500, 11,1);
PlotText("" + NumToStr(f618, dec)+ " 62%",mxpos,f618, 43,1);
PlotText("" + NumToStr(f786, dec)+ " 78%",mxpos,f786, 42,1);
PlotText("" + NumToStr(f127, dec)+ " 127%",mxpos, f127,10,1) ;
PlotText("" + NumToStr(f162, dec)+ " 162%",mxpos, f162,34,1) ;
PlotText("" + NumToStr(f200, dec)+ " 200%",mxpos, f200,55,1) ;
PlotText("" + NumToStr(f262, dec)+ " 262%",mxpos, f262,51,1) ;
PlotText("" + NumToStr(f424, dec)+ " 424%",mxpos, f424,32,1) ;
}

Title = EncodeColor( 55)+ Title = Name() + " " + EncodeColor( 55)
+ Date() + " " + EncodeColor( 3) + "{{INTERVAL} } " +
EncodeColor( 55)+ " Open = "+ EncodeColor( 10)+ NumToStr
(O,dec) +
EncodeColor( 55)+ " High = "+ EncodeColor( 43) + NumToStr
(H,dec) +
EncodeColor( 55)+ " Low = "+ EncodeColor( 32)+ NumToStr
(L,dec) +
EncodeColor( 55)+ " Close = "+ EncodeColor( 42)+ NumToStr
(C,dec) +
EncodeColor( 55)+ " BI = "+ EncodeColor( 42)+ NumToStr
(bi,1.0) +
EncodeColor( 55)+ " Volume = "+ EncodeColor( 55)+ NumToStr
(V,1.0) +"\n"+"\n"+
EncodeColor( 55)+ " Sup = "+ EncodeColor( 55)+ NumToStr
(ys0,dec) +"\n"+
EncodeColor( 40)+ " 23%= "+ EncodeColor( 40)+ NumToStr
(f236,dec) +"\n"+
EncodeColor( 36)+ " 38%= "+ EncodeColor( 36)+ NumToStr
(f382,dec) +"\n"+
EncodeColor( 55)+ " 50% = "+ EncodeColor( 55) + NumToStr
(f500,dec) +"\n"+
EncodeColor( 43)+ " 62% = "+ EncodeColor( 43)+ NumToStr
(f618,dec) +"\n"+
EncodeColor( 42)+ " 78% = "+ EncodeColor( 42)+ NumToStr
(f786,dec) +"\n"+
EncodeColor( 55)+ " Res = "+ EncodeColor( 55)+ NumToStr
(yr0,dec) +"\n"+
EncodeColor( 10)+ "127% = "+ EncodeColor( 10)+ NumToStr
(f127,dec) +"\n"+
EncodeColor( 34)+ "162% = "+ EncodeColor( 34)+ NumToStr
(f162,dec) +"\n"+
EncodeColor( 55)+ "200% = "+ EncodeColor( 55) + NumToStr
(f200,dec) +"\n"+
EncodeColor( 25)+ "262% = "+ EncodeColor( 25)+ NumToStr
(f262,dec) +"\n"+
EncodeColor( 32)+ "424% = "+ EncodeColor( 32)+ NumToStr
(f424,dec);

GraphXSpace= 12;


AFL NO: 2


_SECTION_BEGIN("HA");


tchoice=Param("Title Selection ",2,1,2,1);

Q=Param("% Change",2.1,1,10,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( "HH", i, H[ i ]+dist, colorCustom12 );
if( LH ) PlotText( "LH", i, H[ i ]+dist, colorCustom12 );
if( HL ) PlotText( "HL", i, L[ i ]-dist, colorBlack );
if( LL ) PlotText( "LL", i, L[ i ]-dist, colorBlack );

}

//calculates floor pivots from previous days data & plots it on the present intraday chart.
//RED LINE = RESISTANCE
//RED DASHED LINE = MINI RESISTANCE
//BLUE LINE = SUPPORT
//BLUE DASHED LINE = MINI SUPPORT
//YELLOW DOTTED LINE = PIVOT
//RED DOTTED LINE = PREVIOUS Day High
//BLUE DOTTED LINE = PREVIOUS Day Low
//BLACK DOTTED LINE = PREVIOUS Day Close


//2 - IN - 1 PRICE CHART
Pstyle = ParamToggle("Heikin Ashi","On|Off",1);
if(Pstyle==0){
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotOHLC(HaOpen,HaHigh,HaLow,HaClose,"",IIf(HaClose > HaOpen,colorGreen,colorBrown),styleCandle);

Sell = (abs(HaOpen -HaClose )<= ((HaHigh -HaLow )*0.1));
Buy = (abs(HaOpen -HaClose )<= ((HaHigh -HaLow )*0.1)) ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

//PlotShapes( IIf( Sell, shapeDownArrow+ shapePositionAbove, shapeNone), colorCustom12 );
Plot(EMA(HaClose,20), "", colorBlue , styleLine|styleThick );
Plot(Wilders(H,260.6), "",colorCustom12 , styleDashed|styleThick );
Plot(EMA(HaClose,10), "",colorTan, styleLine|styleThick );



TimeFrameSet(inHourly);
Hh=HHV (L,24);
Ll =LLV (H,24);
TimeFrameRestore();
Hh1=(TimeFrameExpand( Hh, inHourly));
Ll1=(TimeFrameExpand( Ll, inHourly));

Plot(Hh1 , "27dayssellbelclose",colorRed, 4+8+2048);
Plot(Ll1 , "27daysbuyabvclose",colorGreen, 4+8+2048);

Buy=Cross(C,LL);
Sell=Cross(HH,C);
Filter=Buy OR Sell;




_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

}
else {
_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() );
}


Pivot = ParamToggle("Pivot", "weekly|monthly", 1);

if(Pivot)
{
H1 = TimeFrameGetPrice("H", inMonthly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inMonthly, -1); // low
C1= TimeFrameGetPrice("C", inMonthly, -1); // close


}
else
{
H1 = TimeFrameGetPrice("H", inWeekly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inWeekly, -1); // low
C1= TimeFrameGetPrice("C", inWeekly, -1); // close
}

// PIVOT Calculation
P = ( H1+ L1+ C1 )/3;
R1 = P+(H1-L1)/2-(P-C1)/2;
R2 = H1-L1+P;
R3 = H1-L1+R1;
R4 = H1-L1+R2;
R5 = H1-L1+R3;
R6 = H1-L1+R4;
R7 = H1-L1+R5;
R8 = H1-L1+R6;
R9 = H1-L1+R7;
R10 = H1-L1+R8;



S1 = P -(H1-L1)/2-(P-C1)/2;
S2 = P -(H1-L1);
S3 = S1 -(H1-L1);
S4 = S2 -(H1-L1);
S5 = S3 -(H1-L1);
S6 = S4 -(H1-L1);
S7 = S5 -(H1-L1);
S8 = S6 -(H1-L1);
S9 = S7 -(H1-L1);
S10 =S8 -(H1-L1);





// PIVOT mid points
//PLOTS
Plot(R1, "",colorBlue,4+8+2048);
Plot(R2, "",colorBlue,4+8+2048);
Plot(R3, "",colorBlue,4+8+2048);
Plot(R4, "",colorBlue,4+8+2048);
Plot(R5, "",colorBlue,4+8+2048);
Plot(R6, "",colorBlue,4+8+2048);
Plot(R7, "",colorBlue,4+8+2048);
Plot(R8, "",colorBlue,4+8+2048);
Plot(R9, "",colorBlue,4+8+2048);
Plot(R10, "",colorBlue,4+8+2048);


Plot(P, "",colorBlack,styleDots+styleNoRescale);
Plot(S1, "",colorGold,4+8+2048);
Plot(S2, "",colorGold,4+8+2048);
Plot(S3, "",colorGold,4+8+2048);
Plot(S4, "",colorGold,4+8+2048);
Plot(S5, "",colorGold,4+8+2048);
Plot(S6, "",colorGold,4+8+2048);
Plot(S7, "",colorGold,4+8+2048);
Plot(S8, "",colorGold,4+8+2048);
Plot(S9, "",colorGold,4+8+2048);
Plot(S10, "",colorGold,4+8+2048);



// PIVOT mid points
MIDR1 = (P+R1)/2;
MIDR2 = (R1+R2)/2;
MIDR3 = (R2+R3)/2;
MIDR4 = (R3+R4)/2;
MIDR5 = (R4+R5)/2;
MIDR6 = (R5+R6)/2;
MIDR7 = (R6+R7)/2;
MIDR8 = (R7+R8)/2;
MIDR9 = (R8+R9)/2;
MIDR10 = (R9+R10)/2;




MIDS1 = (P+S1)/2;
MIDS2 = (S1+S2)/2;
MIDS3 = (S2+S3)/2;
MIDS4 = (S3+S4)/2;
MIDS5 = (S4+S5)/2;
MIDS6 = (S5+S6)/2;
MIDS7 = (S6+S7)/2;
MIDS8 = (S7+S8)/2;
MIDS9 = (S8+S9)/2;
MIDS10 = (S9+S10)/2;



//PLOTS





Plot(MIDR1, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR2, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR3, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR4, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR5, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR6, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR7, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR8, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR9, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR10, "",colorBlue,styleLine+styleNoRescale);


Plot(MIDS1, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS2, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS3, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS4, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS5, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS6, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS7, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS8, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS9, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS10, "",colorGold,styleLine+styleNoRescale);












MIDRR1 = (MIDR1+MIDR2)/2;
MIDRR2 = (MIDR3+MIDR4)/2;
MIDRR3 = (MIDR5+MIDR6)/2;
MIDRR4 = (MIDR7+MIDR8)/2;
MIDRR5 = (MIDR9+MIDR10)/2;





MIDSS1 = (MIDS1+MIDS2)/2;
MIDSS2 = (MIDS3+MIDS4)/2;
MIDSS3 = (MIDS5+MIDS6)/2;
MIDSS4 = (MIDS7+MIDS8)/2;
MIDSS5 = (MIDS9+MIDS10)/2;



//PLOTS





Plot(MIDRR1, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR2, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR3, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR4, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR5, "",colorBlue,styleDashed+styleNoRescale);

Plot(MIDSS1, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS2, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS3, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS4, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS5, "",colorGold,styleDashed+styleNoRescale);
















n=130;
per =11.5;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa(C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
//Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = (S1==trendlineS );
Sell = (S11==trendlineR );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorRed, colorCustom12) );
dist = 1.9*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Rsi130 Buy " + L[ i ], i, L[ i ]-dist, colorBlack);
if( Sell ) PlotText( "Rsi130Sell " + H[ i ], i, H[ i ]+dist, colorBlack);
}

n=45;
per =9;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa(C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
//Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = (S1==trendlineS );
Sell = (S11==trendlineR );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorRed, colorCustom12) );
dist = 0.9*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Rsi45 Buy " + L[ i ], i, L[ i ]-dist, colorBlack);
if( Sell ) PlotText( "Rsi45Sell " + H[ i ], i, H[ i ]+dist, colorBlack);
}




_SECTION_END();
 
#2
Dear Mangalam;

Highly appreciate sharing.
There is one space mistake in AFL NO:1, and 3 in AFL NO:2
Excellent indicators.
For AFL NO:2
I changed it to the following:
_SECTION_BEGIN("HA");


tchoice=Param("Title Selection ",2,1,2,1);

Q=Param("% Change",2.1,1,10,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( "HH", i, H[ i ]+dist, colorCustom12 );
if( LH ) PlotText( "LH", i, H[ i ]+dist, colorCustom12 );
if( HL ) PlotText( "HL", i, L[ i ]-dist, colorWhite );
if( LL ) PlotText( "LL", i, L[ i ]-dist, colorWhite );

}

//calculates floor pivots from previous days data & plots it on the present intraday chart.
//RED LINE = RESISTANCE
//RED DASHED LINE = MINI RESISTANCE
//BLUE LINE = SUPPORT
//BLUE DASHED LINE = MINI SUPPORT
//YELLOW DOTTED LINE = PIVOT
//RED DOTTED LINE = PREVIOUS Day High
//BLUE DOTTED LINE = PREVIOUS Day Low
//BLACK DOTTED LINE = PREVIOUS Day Close


//2 - IN - 1 PRICE CHART
Pstyle = ParamToggle("Heikin Ashi","On|Off",1);
if(Pstyle==0){
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotOHLC(HaOpen,HaHigh,HaLow,HaClose,"",IIf(HaClose > HaOpen,colorGreen,colorBrown),styleCandle);

Sell = (abs(HaOpen -HaClose )<= ((HaHigh -HaLow )*0.1));
Buy = (abs(HaOpen -HaClose )<= ((HaHigh -HaLow )*0.1)) ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

PlotShapes( IIf( Sell, shapeDownArrow+ shapePositionAbove, shapeNone), colorCustom12 );
Plot(EMA(HaClose,20), "", colorBlue , styleLine|styleThick );
Plot(Wilders(H,260.6), "",colorCustom12 , styleDashed|styleThick );
Plot(EMA(HaClose,10), "",colorTan, styleLine|styleThick );



TimeFrameSet(inHourly);
Hh=HHV (L,24);
Ll =LLV (H,24);
TimeFrameRestore();
Hh1=(TimeFrameExpand( Hh, inHourly));
Ll1=(TimeFrameExpand( Ll, inHourly));

Plot(Hh1 , "27dayssellbelclose",colorRed, 4+8+2048);
Plot(Ll1 , "27daysbuyabvclose",colorGreen, 4+8+2048);

Buy=Cross(C,LL);
Sell=Cross(HH,C);
Filter=Buy OR Sell;




_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

}
else {
_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() );
}


Pivot = ParamToggle("Pivot", "weekly|monthly", 1);

if(Pivot)
{
H1 = TimeFrameGetPrice("H", inMonthly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inMonthly, -1); // low
C1= TimeFrameGetPrice("C", inMonthly, -1); // close


}
else
{
H1 = TimeFrameGetPrice("H", inWeekly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inWeekly, -1); // low
C1= TimeFrameGetPrice("C", inWeekly, -1); // close
}

/*
// PIVOT Calculation
P = ( H1+ L1+ C1 )/3;
R1 = P+(H1-L1)/2-(P-C1)/2;
R2 = H1-L1+P;
R3 = H1-L1+R1;
R4 = H1-L1+R2;
R5 = H1-L1+R3;
R6 = H1-L1+R4;
R7 = H1-L1+R5;
R8 = H1-L1+R6;
R9 = H1-L1+R7;
R10 = H1-L1+R8;



S1 = P -(H1-L1)/2-(P-C1)/2;
S2 = P -(H1-L1);
S3 = S1 -(H1-L1);
S4 = S2 -(H1-L1);
S5 = S3 -(H1-L1);
S6 = S4 -(H1-L1);
S7 = S5 -(H1-L1);
S8 = S6 -(H1-L1);
S9 = S7 -(H1-L1);
S10 =S8 -(H1-L1);

*/


/*
// PIVOT mid points
//PLOTS
Plot(R1, "",colorBlue,4+8+2048);
Plot(R2, "",colorBlue,4+8+2048);
Plot(R3, "",colorBlue,4+8+2048);
Plot(R4, "",colorBlue,4+8+2048);
Plot(R5, "",colorBlue,4+8+2048);
Plot(R6, "",colorBlue,4+8+2048);
Plot(R7, "",colorBlue,4+8+2048);
Plot(R8, "",colorBlue,4+8+2048);
Plot(R9, "",colorBlue,4+8+2048);
Plot(R10, "",colorBlue,4+8+2048);


Plot(P, "",colorBlack,styleDots+styleNoRescale);
Plot(S1, "",colorGold,4+8+2048);
Plot(S2, "",colorGold,4+8+2048);
Plot(S3, "",colorGold,4+8+2048);
Plot(S4, "",colorGold,4+8+2048);
Plot(S5, "",colorGold,4+8+2048);
Plot(S6, "",colorGold,4+8+2048);
Plot(S7, "",colorGold,4+8+2048);
Plot(S8, "",colorGold,4+8+2048);
Plot(S9, "",colorGold,4+8+2048);
Plot(S10, "",colorGold,4+8+2048);



// PIVOT mid points
MIDR1 = (P+R1)/2;
MIDR2 = (R1+R2)/2;
MIDR3 = (R2+R3)/2;
MIDR4 = (R3+R4)/2;
MIDR5 = (R4+R5)/2;
MIDR6 = (R5+R6)/2;
MIDR7 = (R6+R7)/2;
MIDR8 = (R7+R8)/2;
MIDR9 = (R8+R9)/2;
MIDR10 = (R9+R10)/2;




MIDS1 = (P+S1)/2;
MIDS2 = (S1+S2)/2;
MIDS3 = (S2+S3)/2;
MIDS4 = (S3+S4)/2;
MIDS5 = (S4+S5)/2;
MIDS6 = (S5+S6)/2;
MIDS7 = (S6+S7)/2;
MIDS8 = (S7+S8)/2;
MIDS9 = (S8+S9)/2;
MIDS10 = (S9+S10)/2;


//PLOTS





Plot(MIDR1, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR2, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR3, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR4, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR5, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR6, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR7, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR8, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR9, "",colorBlue,styleLine+styleNoRescale);
Plot(MIDR10, "",colorBlue,styleLine+styleNoRescale);


Plot(MIDS1, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS2, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS3, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS4, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS5, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS6, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS7, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS8, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS9, "",colorGold,styleLine+styleNoRescale);
Plot(MIDS10, "",colorGold,styleLine+styleNoRescale);




MIDRR1 = (MIDR1+MIDR2)/2;
MIDRR2 = (MIDR3+MIDR4)/2;
MIDRR3 = (MIDR5+MIDR6)/2;
MIDRR4 = (MIDR7+MIDR8)/2;
MIDRR5 = (MIDR9+MIDR10)/2;





MIDSS1 = (MIDS1+MIDS2)/2;
MIDSS2 = (MIDS3+MIDS4)/2;
MIDSS3 = (MIDS5+MIDS6)/2;
MIDSS4 = (MIDS7+MIDS8)/2;
MIDSS5 = (MIDS9+MIDS10)/2;



//PLOTS





Plot(MIDRR1, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR2, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR3, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR4, "",colorBlue,styleDashed+styleNoRescale);
Plot(MIDRR5, "",colorBlue,styleDashed+styleNoRescale);

Plot(MIDSS1, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS2, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS3, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS4, "",colorGold,styleDashed+styleNoRescale);
Plot(MIDSS5, "",colorGold,styleDashed+styleNoRescale);




*/











n=130;
per =11.5;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa (C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = (S1==trendlineS );
Sell = (S11==trendlineR );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorRed, colorCustom12) );
dist = 1.9*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Rsi130 Buy " + L[ i ], i, L[ i ]-dist, colorWhite);
if( Sell ) PlotText( "Rsi130Sell " + H[ i ], i, H[ i ]+dist, colorWhite);
}

n=45;
per =9;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa (C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = (S1==trendlineS );
Sell = (S11==trendlineR );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorRed, colorCustom12) );
dist = 0.9*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Rsi45 Buy " + L[ i ], i, L[ i ]-dist, colorWhite);
if( Sell ) PlotText( "Rsi45Sell " + H[ i ], i, H[ i ]+dist, colorWhite);
}




_SECTION_END();

They are really useful afl for all
Hoping to accept my comment

Copy right is yours.

Best regards,
 

Similar threads