// Downloaded From https://www.WiseStockTrader.com

_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
ParamColor("BgBottom", colorBlack),ParamColor("titleblock",colorGrey40));
_SECTION_END();


_SECTION_BEGIN("Three Shift Indicator");

EMAPeriod = Param("Fast EMA",3,1,25,1);
DisplacementPeriod = Param("Shift",-3,-25,25,1);

//Plot the Lines
Plot(Ref(EMA(Close,EMAPeriod),-DisplacementPeriod),"DEMA1",colorYellow,styleLine) ;
Plot(EMA(Close, 5 ), "5 Wk EMA", colorBlue, styleLine);
Plot(EMA(Close, 15 ), "15 Wk EMA", colorRed, styleLine);
Title = Name() + " " + Date() + EncodeColor(colorIndigo) + " " + C + WriteVal(ROC( Close, 1) ) + "%" + EncodeColor(colorBlack) + " Three Shift Indicator ";
_SECTION_END();

_SECTION_BEGIN("Background");
SetChartOptions(0,chartShowArrows|chartShowDates);
priceTitle=StrFormat("---- {{NAME}} ---------- {{VALUES}}");
Title ="Averages" + priceTitle;

if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}

SetChartBkColor(ParamColor("Outer panel color ",colorBlack)); // color of outer border
SetChartBkGradientFill( ParamColor("Inner panel color upper half",colorBlack),ParamColor("Inner panel color lower half",colorBlack)); // color of inner panel
_SECTION_END();

Buy1=Cross(Ref(EMA(Close,EMAPeriod),-DisplacementPeriod),EMA(Close,5));
Buy2=Cross(C,Ref(EMA(Close,EMAPeriod),-DisplacementPeriod))AND Ref(EMA(Close,EMAPeriod),-DisplacementPeriod)>EMA(Close,5);
Buy=Buy1 OR Buy2;
Sell1=Cross(EMA(Close,5),Ref(EMA(Close,EMAPeriod),-DisplacementPeriod));
Sell2=Cross(Ref(EMA(Close,EMAPeriod),-DisplacementPeriod),C) AND Ref(EMA(Close,EMAPeriod),-DisplacementPeriod)<EMA(Close,5);
Sell=Sell1 OR Sell2;
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorRed,0,H,-15);