// Downloaded From https://www.WiseStockTrader.com
       
 _SECTION_BEGIN("SIROC");

_SECTION_BEGIN("Background");
	SetChartOptions(0,chartShowArrows|chartShowDates);
	SetChartBkColor(ParamColor("Outer panel",colorCustom6)); 
// color of outer border 
	SetChartBkGradientFill( ParamColor("Inner panel 
upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
	tchoice=Param("Title Selection ",2,1,2,1);
GfxTextOut("NIFTYTIGER'S MAGIC LINES ", 760 , 100);

//////////////////////////////////////////////////////////////////
 
   
// --- Niftytiger's SIROC --- //   
prd1 = Param("First period",36,5,300,1);   
prd2 = Param("Second period",8,1,100,1);   
prdCrs = Param("Crossover",3,1,300,1);   
prd2 = prd2*2-1;   
Src= EMA((C-EMA(C,30)) /(Ref(EMA(C,30),-30)+0.000001),prd1);   
SIROC =100-100/(1   
+IIf(   
EMA(IIf(Src-Ref(Src,-1)<0,-(Src-Ref(Src,-1)),0),prd2)==0, 
1000000,   
EMA(IIf (Src-Ref(Src,-1)>0,Src-Ref(Src,-1),0),prd2)   
/(EMA(IIf(Src-Ref(Src,-1)< 0,-(Src-Ref(Src,-1)),0),prd2)+0.000001)));   
DTrigger = EMA(SIROC,prdCrs);   
Plot(siroc,"siroc",colorBlue,1);   
Plot(dtrigger,"trigger",colorBrown,1);   
Plot(90,"90",colorGrey40,1);   
Plot(10,"10",colorGrey40,1);   
GraphXSpace = 5;   
Buy=Cross(siroc,dtrigger); 
Sell=Cross(dtrigger,siroc);
PlotShapes(IIf(Buy, shapeUpArrow , shapeNone), colorGreen); 
PlotShapes(IIf(Sell, shapeDownArrow , shapeNone), colorRed);      
//--- end --- //   
_SECTION_END();


_SECTION_BEGIN("Stochastic Slow");
periods = Param( "Periods", 20, 1, 200, 1 );
Ksmooth = Param( "%K avg", 12, 1, 200, 1 );
Plot( StochK( periods , Ksmooth), "%K"+_PARAM_VALUES(), ParamColor( "%K color", colorCycle ), ParamStyle("%K style") );
Dsmooth = Param( "%D avg", 10, 1, 200, 1 );
Plot( StochD( periods , Ksmooth, DSmooth ), "%D"+_PARAM_VALUES(), ParamColor( "%D color", colorCycle ), ParamStyle("%D style",styleDashed) );

y0=LastValue(Trough(StochD(periods , Ksmooth, DSmooth ),1,2)); 
y1=LastValue(Trough(StochD(periods , Ksmooth, DSmooth ),1,1)); 
x0=BarCount - 1 - LastValue(TroughBars(StochD(periods , Ksmooth, DSmooth ),1,2));
price_start=Close[x0];
x1=BarCount - 1 - LastValue(TroughBars(StochD(periods , Ksmooth, DSmooth ),1,1)); 
price_end=Close[x1];
Line = LineArray( x0, y0, x1, y1, 0 );
Plot( Line, "Support line", colorBlack );
Buy = y1>y0 AND price_end<price_start;
PlotShapes(shapeUpArrow * Buy, colorGreen,0,Line);

y00=LastValue(Peak(StochD(periods , Ksmooth, DSmooth ),1,2)); 
y11=LastValue(Peak(StochD(periods , Ksmooth, DSmooth ),1,1)); 
x00=BarCount - 1 - LastValue(PeakBars(StochD(periods , Ksmooth, DSmooth ),1,2)); 
price_start1=Close[x00];
x11=BarCount - 1 - LastValue(PeakBars(StochD(periods , Ksmooth, DSmooth ),1,1));
price_end1=Close[x11]; 
Line = LineArray( x00, y00, x11, y11, 0 );
Plot( Line, "Resistance line", colorWhite );
Sell = y11<y00 AND price_end1>price_start1;
PlotShapes(shapeDownArrow * Sell, colorRed,0,Line);


if( Status("action") == actionCommentary )
{
 printf("(Interpretation is not available yet)");
}
_SECTION_END();