periods = Param( "Periods", 14, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
myStochD = StochD( periods , Ksmooth, DSmooth );
myStochK = StochK( periods , Ksmooth );
Overbought = 80 ;
Oversold = 20 ;
Center = 50 ;
Plot( myStochD, "Stochastic %D" + _PARAM_VALUES( ), ParamColor( "ColorD", colorRed ), ParamStyle( " StyleD" ) );
Plot( myStochK, "Stochastic %K", ParamColor( "ColorK", colorLightOrange ), ParamStyle( " StyleK" ) );
Plot( Overbought, "", colorRed ) ;
Plot( Oversold, "", colorGreen ) ;
Plot( Center, "", colorWhite, styleDashed ) ;
PlotOHLC( myStochK, myStochK, 50, myStochK, "", IIf(myStochK <= oversold, colorGreen, colorRed), styleCloud | styleNoLabel | styleClipMinMax, Oversold , Overbought );
PlotOHLC( myStochD, myStochD, 50, myStochD, "", IIf(myStochD <= oversold, colorGreen, colorRed), styleCloud | styleNoLabel | styleClipMinMax, Oversold , Overbought );