Fave This

Thursday, 20 May 2010

Re: [Komunitas AmiBroker] RSI All in One and trading the MACD AFL




Maaf Pak Bassir AFL yg saya lampirkan hanya untuk RSI dan trading the MACD (just indicator), tdk termasuk chart yg plg atas, yg diatas Foundation Chart hrs dgn plugin.

Demikian trm ksh.

Salam,


From: bassir <bassir76@gmail.com>
To: amibroker-4-bei@yahoogroups.com
Sent: Thu, May 20, 2010 6:23:55 PM
Subject: Re: [Komunitas AmiBroker] RSI All in One and trading the MACD AFL

 

Pak Isfandi,

Saya belum sempat coba sih AFL nya, tapi sepintas apa betul tampilannya seperti grafik ini ya pak. Kok di grafik banyak nongol tulisannya tetapi di AFL nya saya belum liat ada  perintah untuk title-title tsb? Atau chart yg apaling atas tidak dilampirkan AFLnya di sini ya pak?

On Thu, May 20, 2010 at 1:22 AM, <isfandi2001@ yahoo.com> wrote:


bagi rekan2 yg berminat AFL RSI hasil oprekan saya silahkan upload disini, RSI ini gabungan antara supp&resist Divergence, fibonacci line dan zig zag Trendlines and Wedges, pokoknya all in one alias campur sari... dan mungkin ada yg belum punya AFL trading the MACD disini juga saya lampirkan.  selamat mencoba dan semoga bermanfaat.

Start to copy from here;

// TRADING THE MACD Ver 1.0 by Karthik Marar. AFL provided as a part of the Discussion on trading the MACD in the Thread " Experiments in Technical Analysis"
// Afl provided to learn and get an insight for trading using the MACD. The AFL can be freely distributed except for commercial purpose.

_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 8, 2, 200, 1 );
r5 = Param( "Wk fast", 17, 2, 200, 1 );
m1=MACD(r1,r2) ;
s1=Signal(r1, r2,r3);
GraphXSpace =20;

mycolor=IIf( m1<0 AND m1>s1, 51,IIf(m1>0 AND m1>s1,colorLime, IIf(m1>0 AND m1<s1,colorOrange, colorRed) ));
Plot( m1, StrFormat(_SECTION_ NAME()+"(%g,%g)", r1, r2), mycolor,ParamStyle("MACD style") );
Plot( s1 ,"Signal" + _PARAM_VALUES( ), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
histcolor = IIf((m1-s1)- Ref((m1-s1) ,-1)> 0, colorLime, colorRed );

TimeFrameSet( inWeekly );
m1w=MACD(r4, r5);
s1w=Signal(r4, r5,r3);
kp=m1w-s1w;
kph=Ref(kp,- 1);
TimeFrameRestore( );

kw=TimeFrameExpand( kp, inWeekly ); // expand for display
khw=TimeFrameExpand ( kph, inWeekly ); // expand for display
mw=TimeFrameExpand( m1w, inWeekly ); // expand for display
sw=TimeFrameExpand( s1w, inWeekly ); // expand for display

hcolor=IIf(mw<0 AND mw>sw, 51,IIf(mw>0 AND mw>sw,colorLime, IIf(mw>0 AND mw<sw,colorOrange, colorRed) ));
gcolor=IIf(kw>khw,IIf(kw>0,colorDarkYellow, colorYellow) ,IIf(kw>0,colorSkyblue, colorBlue) );

Plot( 2,"Wkly MACD ribbon",hcolor,styleOwnSca le|styleArea| styleNoLabel, -0.5, 100 );
Plot( 2,"Ribbon",gcolor,styleOwnSca le|styleArea| styleNoLabel, -0.4, 40,-0.6 );

Plot( m1-s1, "MACD Histogram",  mycolor, styleHistogram | styleThick| styleOwnScale  );

_SECTION_END( );

_SECTION_BEGIN("Signals");
//Zero crossover up

j1=Cross(m1, 0);
PlotShapes(IIf( j1,shapeDigit1 ,Null),colorPaleGre en,0,Min( 0,0),Min( 0,0));
PlotShapes(IIf( j1,shapeUpArrow, Null),colorGreen ,0,Min(0, 0),-10);

// crossover above zero

j2=Cross(m1, s1) AND m1>0;
PlotShapes(IIf( j2,shapeDigit2 ,Null),colorYellow, 0,0,0);
PlotShapes(IIf( j2,shapeUpArrow, Null),colorGreen ,0,0,-10) ;

//Zero crossover down

j3=Cross(s1, m1) AND m1>0;
PlotShapes(IIf( j3,shapeDigit3 ,Null),colorOrange, 0,Min(0,0) ,0);
PlotShapes(IIf( j3,shapeDownArro w,Null),colorOra nge,0,Min( 0,0),-10) ;

// crossover below zero

j4=Cross(0,m1) ;
PlotShapes(IIf( j4,shapeDigit4 ,Null),colorRed, 0,0,0);
PlotShapes(IIf( j4,shapeDownArro w,Null),colorRed ,0,0,-10) ;

// Histogram peak and troughs
pt=m1-s1;
Tp = Ref(pT,-1) == HHV(pT,3);
Vl = Ref(pT,-1)== LLV(pT,3) ;
PlotShapes(IIf( Vl AND m1>s1 ,shapeSmallCircle+ shapePositionAbove, shapeNone) ,IIf(m1<0 ,colorYellow, colorLime) ,0,0,0);
PlotShapes(IIf( Tp AND m1<s1 ,shapeSmallCircle+ shapePositionAbove, shapeNone) ,colorRed, 0,0,0);

//Zeroline reject bearish
zd=BarsSince( j1);
zlrd1=(zd<6 )AND j4;
PlotShapes(IIf( zlrd1,shapeStar+ shapePositionAbove, shapeNone) ,colorDarkRed, 0,0,20);

//hooks bearish
Hu=BarsSince( j2);
Hu1=(Hu<6)AND j3;
PlotShapes(IIf( Hu1,shapeStar+ shapePositionAbove, shapeNone) ,colorRed, 0,0,20);

//Zeroline reject Bullish
zu=BarsSince( j4);
zlru=zu<6 AND j1;
PlotShapes(IIf( zlru,shapeStar+ shapePositionAbove, shapeNone) ,colorPink, 0,0,20);

//Hook Bullish
Hd=BarsSince( j3);
Hd1=Hd<6 AND j2;
PlotShapes(IIf( Hd1,shapeStar+ shapePositionAbove, shapeNone) ,colorLime, 0,0,20);

//ADX related calculations
plus=EMA(PDI( 14),3)>Ref(EMA(PDI( 14),3),-5) ;
ap=EMA(ADX(14) ,3)>Ref(EMA(ADX( 14),3),-5) ;
Minus=EMA(MDI( 14),3)>Ref(EMA(MDI( 14),3),-5) ;

//Power Dips - Bullish
PDIp=ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND ap AND Vl AND m1>s1 AND plus ;
PlotShapes(IIf( PDIp,shapeHollow Circle+ shapePositionAbove, shapeNone) ,colorCustom12, 0,0,0);

//power buys
pr2=ADX(14)>20 AND PDI(14)>20 AND ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND plus AND j2;
PlotShapes(IIf( pr2,shapeHollowC ircle+ shapePositionAbove, shapeNone) ,colorCustom12, 0,0,20);

//Power Dips - Bearish
PDIm=ADX(14)>PDI(14) AND MDI(14)>PDI(14) AND ap AND Tp AND m1<s1 AND Minus ;
PlotShapes(IIf( PDIm,shapeHollow Circle+ shapePositionAbove, shapeNone) ,colorWhite, 0,0,0);

//Power shorts
sr2=ADX(14)>20 AND MDI(14)>20 AND ADX(14)>PDI(14) AND MDI(14)>PDI(14) AND Minus AND j4;
PlotShapes(IIf( sr2,shapeHollowC ircle+ shapePositionAbove, shapeNone) ,colorRed, 0,0,-20);

//powerbuy2
pr2a=ADX(14)>20 AND PDI(14)>20 AND ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND  plus AND j1;
PlotShapes(IIf( pr2a,shapeHollow Circle+ shapePositionAbove, shapeNone) ,colorCustom12, 0,0,20);
_SECTION_END( );

_SECTION_BEGIN("Exploration");
Filter = j1 OR j2 OR j3 OR j4 OR PDIp OR PDIm OR pr2 OR sr2 ;

AddColumn(j1,"ZL UP",1);
AddColumn(J2,"MA Up",1);
AddColumn(j3,"MA DN",1);
AddColumn(J4,"ZL DN",1);
AddColumn(PDIp,"PDIP UP",1);
AddColumn(pr2,"PHK UP",1);
AddColumn(PDIm,"PDIP DN",1);
AddColumn(sr2,"PHk UP",1);
_SECTION_END( );

_SECTION_BEGIN("Display the Signals");
Title = "Trading the MACD" + " - " +  Name() + " - " + EncodeColor( colorRed) + Interval(2) + EncodeColor( ) +

 "  - " + Date() +" - " +EncodeColor( colorLime) + "MACD= "+WriteVal(m1) +"--"+EncodeColor( colorYellow) +
WriteIf (j1, " MACD Crossed above zero","")+
WriteIf (j2, " Bullish crossover above zero","")+
WriteIf (j4, " MACD Crossed below Zero","")+
WriteIf (j3, " Bearish crossover above zero","")+
WriteIf (PDIP, "  Bullish Power Dip","")+
WriteIf (pr2, " & Power Buy","")+
WriteIf (sr2, " & Power Short","")+
WriteIf (PDIm, " Bearish Power Dip","")+
WriteIf (Hd1, " & Bullish Hook","")+
WriteIf (Hu1, " & Bearish Hook","")+
WriteIf (zlrd1, " & Bearish zeroline Reject","")+
WriteIf (zlru, " & Bullish Zeroline Reject","");
_SECTION_END( );

Stop, and start from here for RSI;

_SECTION_BEGIN("RSI Fibo ZigZag Created by: sahamlq45.blogspot. com");
barvisible = Status("barvisible");
r = RSI( 14 );
maxr = LastValue( Highest( IIf( barvisible, r, 0 ) ) );
minr = LastValue( Lowest( IIf( barvisible, r, 100 ) ) );
ranr = maxr - minr;
Plot( r, "RSI(14)", colorRed );
Plot( maxr , "0%", colorGrey50 );
Plot( maxr - 0.236 * ranr, "-23.6%", colorPaleGreen );
Plot( maxr - 0.382 * ranr, "-38.2%", colorPaleBlue );
Plot( maxr - 0.50 * ranr, "-50.0%", colorOrange );
Plot( maxr - 0.618 * ranr, "-61.8%", colorPaleBlue );
Plot( minr , "-100%", colorGrey50 );
GraphXSpace = 3;
_SECTION_END( );

_SECTION_BEGIN("RSI Divergence");
//---------- --------- --------- --------- --------- --------- --------- --------- -----
//
//  Formula Name:    RSI Divergence
//  Author/Uploader: Aron Pipa
//  E-mail:         
//  Date/Time Added: 2006-03-19 22:00:02
//  Origin:         
//  Keywords:       
//  Level:           medium
//  Flags:           indicator
//  Formula URL:     http://www.amibroke r.com/library/ formula.php? id=603
//  Details URL:     http://www.amibroke r.com/library/ detail.php? id=603
//
//---------- --------- --------- --------- --------- --------- --------- --------- -----
//
//  + scanner
//
//---------- --------- --------- --------- --------- --------- --------- --------- -----

/*---------- --------- --------- --------- --------- -----
    RSI Divergence
    Aron Pipa, March, 20 , 2006
------------ --------- --------- --------- --------- --------* /

GraphXSpace= 7;
n=Param("% Reverse ",20,0,100,1) ;

Buy=Sell=0;
Var = Zig(RSI(), n);
t= Trough(RSI() , n, 1);
p= Peak(RSI(), n, 1);
x[0] =Var[0];
price[0] = C[0];
j=0;

// bearish divergence
for ( i=0; i<BarCount; i++)
{
if(Var[i] == p[i])
{

j++;
x[j] =Var[i];
price[j] =C[i];
if(x[j] <x[j-1] && price[j-1]< price[j])
Sell[i] =1;
}
}

// bullish divergence
for ( i=0; i<BarCount; i++)
{
if(Var[i] == t[i])
{
j++;
x[j] =Var[i];
price[j] =C[i];
if(x[j] >x[j-1] && price[j]<price[j-1])
Buy[i] =1;
}
}

Plot(Var, "", 39);
PlotShapes ( IIf(Sell, shapeSmallCircle, shapeNone), colorRed, 0 , Var,0);
PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone),  colorBrightGreen, 0, Var,0);

Title ="RSI Divergence" ;
_SECTION_END( );

_SECTION_BEGIN("RSI Trendlines and Wedges");
/*RSI Trendlines and Wedges*/
G=0;// set G=1, 2, 3, ... to see previous Resistance trendlines
GG=0;// set G=1, 2, 3, ... to see previous Support trendlines
x = Cum(1);
per = 1;// sensitivity calibration
s1=RSI();s11= RSI();
Plot(RSI(),"RSI",14,8);
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen ( pS, x, 1+GG ));
startt=LastValue( ValueWhen( pS, x, 2+GG ));
dtS =endt-startt;
endS = LastValue(ValueWhen ( pS, s1, 1+GG ) );
startS = LastValue( ValueWhen( pS, s1, 2+GG ));
aS = (endS-startS) /dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;// the Support trendline equation
Plot(IIf(x>startt-6 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS, -1e10),"Support",IIf(as>0,5,4),8);
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen ( pR, x, 1+G ));
startt1=LastValue( ValueWhen( pR, x, 2+G ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen ( pR, s11, 1+G ) );
startR = LastValue( ValueWhen( pR, s11, 2 +G ));
aR = (endR-startR) /dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;// the Resistance trendline equation
Plot(IIf(x>startT1-6 AND TRENDLINER>0 AND TRENDLINER<100,trendlineR, -1e10),"Resistance",IIf(Ar>0,5,4),8);
Ascwedge=Ar>0.5 AND As>sqrt(2)*Ar AND trendlineR>trendlineS;
Descwedge= As<-0.5 AND As>Ar/sqrt(2) AND trendlineR>trendlineS;
Filter=1;
AddColumn(Ascwedge,"AscWedge",1.0);
AddColumn(DescWedge ,"DesWedge",1.0);
AddColumn(Ascwedge AND trendlineS>50 AND RSI()>50,"Probable Bearish Breakout",1.0);
AddColumn(Descwedge AND trendlineR<50 AND RSI()<50,"Probable Bullish Breakout",1.0);


/* END of code */
_SECTION_END( );


salam,

Isfandi 






--
Regards,
Bassir



__._,_.___



Apabila anda membutuhkan software Amibroker, Realtime Data & pelatihan silahkan visit http://www.amibroker-4-bei.org

Berikut adalah beberapa jadwal pelatihan amibroker dalam waktu dekat:

Sabtu, 24 April 2010 : Latihan pengoperasian dasar AmiBroker berikut Technical analysis di Grand Flora Hotel Kemang - Jakarta.





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

No comments:

Post a Comment