_SECTION_BEGIN("MACD");
SetChartBkColor( colorBlack ) ;
r1 = Param( "Fast avg", 11, 3, 20, 1 );
r2 = Param( "Slow avg", 35, 10, 35, 1 );
r3 = Param( "Signal avg", 6, 3, 20, 1 );
ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
Hst = ml-sl;
A1=EMA(C,4)-EMA(C,34);
BBtops=BBandTop(A1,10,1);
BBbots=BBandBot(A1,10,1);
//Color_bar=IIf(a1<0 AND a1>Ref(a1,-1), colorAqua,IIf(a1>0 AND a1>Ref(a1,-1),colorBlue,IIf(a1>0 AND a1<Ref(a1,-1),colorOrange,colorRed)));
Color_bar=IIf(a1>BBtops, colorBlue,IIf(a1<BBbots,colorRed,colorYellow));
//Plot( ml = MACD(3, 11), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
//Plot( sl = Signal(3,11,16), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
bbtop = BBandTop( Hst, 10, 1 );
bbbot = BBandBot( Hst, 10,1 );
//Plot( BBandTop( Hst, 9, 1 ), "BBTop", colorYellow, styleDashed );
//Plot( BBandBot( Hst, 9,1 ), "BBBot", colorYellow, styleDashed );
Color = IIf (Hst > BBtop,colorBlue,IIf(hst < bbbot,colorRed, IIf (Hst > 0,colorBlue,colorRed)));
//Plot( Hst, "secret", color , styleThick );
/*
Buy = Cross (Hst,bbtop);
Sell = Cross (bbtop,Hst);
Short = Cross (bbbot,Hst);
Cover = Cross (Hst,bbbot);
*/
band = Param("band",10,1,40,1);
//Buy = Color == colorBlue AND Close > EMA(High,band);
//Short = color== colorRed AND Close < EMA (Low,band);
Buy = Color == colorBlue AND Color_bar==colorBlue AND Close > EMA(High,band);
Short = color== colorRed AND Color_bar == colorRed AND Close < EMA (Low,band);
Buy = ExRem(Buy, Short);
Short = ExRem(Short, Buy);
Hi = EMA(High,band);
Lo = EMA(Low,band);
Sell = Close < HI;
Cover = Close > LO ;
Sell = ExRem(Cover, Sell);
Cover = ExRem(Sell, Cover);
PlotShapes(Sell*shapeCircle,colorGreen);
PlotShapes(Cover*shapeCircle,colorRed);
//PlotShapes (Buy*shapeUpArrow,colorYellow);
//PlotShapes (Short*shapeDownArrow,colorYellow);
//PlotShapes (Sell*shapeHollowCircle,colorRed);
//PlotShapes (Cover*shapeHollowCircle,colorGreen);
Plot (Close,"close",Color_bar,styleCandle);
Plot (Hi,"upper band",colorWhite,styleDashed);
Plot (Lo,"lower band",colorWhite,styleDashed);
Plot(6, "", Color, styleOwnScale| styleArea|styleNoLabel,-0.5,100);
_SECTION_END();
_SECTION_BEGIN("Support & Resistance");
//Support and resistance levels using RSI.
//graham Kavanagh May 2003
//Load into Indicator Builder
//Sensitivity of the levels can be changed with the variables
//Can test different numbers live with the Param function ctrl-R with open pane
RSIperiod = 5; // 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 = 5; //Param("HHV p",3,5,10,1);
NumLine = 1; //Param("Num Lines",3,1,20,1);
Base = DEMA(RSI(RSIperiod),EMAperiod);
//GraphXSpace=0.5;
//Plot(C,"",colorWhite,styleCandle);
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);
}
//Title = Name() + "; " + Date() + ": Support & Resistance Levels using RSI: " + /*EncodeColor(colorGreen)+ "Support Levels are Green; "+EncodeColor(colorRed)+ "Resistance Levels are Red: "+EncodeColor(colorBlack)+*/ "Num lines ="+WriteVal(numline,1) ;
dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
//if( Buy[i] ) PlotText( "Buy\n@" + C[ i ]+"\n sl :"+ValueWhen( supbase==Base, LLV(L,HHVperiod) ) , i, L[ i ]-dist[i], colorBlack,colorGreen );
//if( Short[i] ) PlotText( "Sell\n@" + C[ i ]+"\n sl :"+ ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), i, H[ i ]+dist[i], colorBlack, colorRed );
if( Buy[i] ) PlotText( "Buy\n@" + C[ i ] , i, L[ i ]-dist[i], colorBlack,colorGreen );
if( Short[i] ) PlotText( "Sell\n@" + C[ i ], i, H[ i ]+dist[i], colorBlack, colorRed );
}
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGreen, colorRed ) );
_SECTION_END();