//McGinley Dynamic
// By Karthik Marar - www.karthikmarar.blogspot.com
// Public release for personal use only.
//Please do not commercialize this indicator in its original or modified form
_SECTION_BEGIN("McGinley Dynamic - V.1.0");
SetBarsRequired( sbrAll );
N = Param("McGinley Dynamic N ",10,1,30,1);
Output[0] = C[0];
for( i = 1; i < BarCount; i++ )
{
output[ i ] = output[ i - 1 ] + (C[i]-Output[i-1])/( N*(C[i] / Output[i-1])^4) ;
}
Plot(C,"Price",IIf(C>output,colorLime,colorRed),styleBar|styleThick);
Plot(Output,"McGinley Dynamic",colorYellow,1|styleThick);
Plot(EMA(C,13),"EMA",colorRed,1);
//EMA2high=IIf(EMA(O,13)-2*H>0,2*H-EMA(Open,13)>0);
//Plot(EMA2high,"EMA Sell",colorRed,1);
//EMA2low=IIf(EMA(C,13)-2*L>0,2*L-EMA(Close,13)>0);
//Plot(EMA2low,"EMA BUY",colorGreen,1);
_SECTION_END();
//_SECTION_BEGIN("Title");
//if( Status("action") == actionIndicator )
//(
//Title = EncodeColor(colorWhite)+ "McGinley Dynamic - V.1.0 " + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
// " - " + Date() +" - "+"\n" + EncodeColor(colorYellow) + WriteIf(C>Output, EncodeColor(colorLime) + "Stock Moving Up" ,
//EncodeColor(colorRed) + "Stock Moving down"));
_SECTION_BEGIN("Color Bollinger Bands");
P = ParamField("Price field",-1);
Period = Param("Short Periods", 20, 15, 30, 1 );
Width = Param("Short Width", 2, 1, 10, 1 );
TopCond=BBandTop( P, Period, Width )>Ref(BBandTop( P, Period, Width ),-1);
MidCond=MA(C,Period)>Ref(MA(C,Period),-1);
BotCond=BBandBot( P, Period, Width )>Ref(BBandBot( P, Period, Width ),-1);
UpColor=IIf(TopCond AND MidCond,colorDarkBlue,colorDarkRed);
DownColor=IIf(MidCond AND BotCond,colorDarkBlue,colorDarkRed);
PlotOHLC(BBandTop( P, Period, Width ),BBandTop( P,Period, Width ),MA(C,Period),MA(C,Period), "", UpColor, styleCloud+styleNoLabel+styleNoTitle, Null, Null, Null, -2 );
PlotOHLC(MA(C,Period),MA(C,Period),BBandBot( P, Period, Width ),BBandBot( P, Period, Width ), "", DownColor, styleCloud+styleNoLabel+styleNoTitle, Null, Null, Null, -2 );
Plot(BBandBot( P, Period, Width ),"",colorLime,styleThick+styleNoTitle, Null, Null, Null, -1);
Plot(BBandTop( P, Period, Width ),"",colorLime,styleThick+styleNoTitle, Null, Null, Null, -1);
Plot(MA(C,Period),"",colorLime,styleThick+styleNoTitle, Null, Null, Null, -1);
Title=Name();
_SECTION_END();