some collection of AFL

#6
sorry to say you but actually i m new in amibroker so ask you how to use this in back testing or find out some stock in amibroker so guide me how to use it
 
#9
_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(HaClos e > 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(RSI a(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(RSI a(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();
 

Similar threads