// Downloaded From https://www.WiseStockTrader.com
SetChartBkColor(ParamColor("backround color ",colorTeal)); 
SetChartOptions( Mode = 0, Flags = 0, gridFlags = 0) ;

Cnormal=Param( "CCI 14", 14, 9, 28, 1 );
Color =IIf (CCI(Cnormal) > 0 , ParamColor("CCi Up",colorPlum), ParamColor("CCi Down",colorOrange));

Plot(CCI(Cnormal),"CCI",color,styleLine,styleThick);
Plot(CCI(Cnormal),"",Color,styleHistogram|styleNoLabel);
//Plot(100,"", colorGrey50, styleLine | styleThick | styleNoLabel); 
//Plot(-100,"", colorGrey50, styleLine | styleThick | styleNoLabel);
Plot(200,"", colorRed , styleDots | styleNoLine ); 
Plot(-200,"", colorBlack  , styleDots | styleNoLine );
_SECTION_END();


_SECTION_BEGIN("Ergodic John's SMI");
/* William Blau's "Ergodic SMI" */

f0 = Param("StochMtn",8,1,1000,1);
f1 = Param("EMA 1",5,1,1000,1);
f2 = Param("EMA 2",1,1,1000,1);
f3 = Param("Signal",5,1,1000,1);

 
StMtm = Close - 0.5*(IIf(f0==1,H,HHV(Close,f0))+IIf(f0==1,L,LLV(Close,f0)));
Numer = EMA(EMA(StMtm,f1),f2);
Denom = 0.5 * EMA(EMA(IIf(f0==1,H,HHV(Close,f0))-IIf(f0==1,L,LLV(Close,f0)),f1),f2);

Multi = Param("Multi",135,50,400,2);
SMI = Multi*(Numer / Denom);
SMI_SignalLine = Multi*(MA(Numer,f3) / MA(Denom,f3));
BuySMI = SMI >= SMI_SignalLine;
SellSMI = SMI <= SMI_SignalLine;

PlotErgodic =ParamToggle("Ergodic SMI ","No|Yes",1); 
if (PlotErgodic ==1) Plot(SMI,"SMI("+f0+","+f1+","+f2+")",ParamColor(" SMI ",colorBlue) ,styleLine|styleThick);
PlotErgodicSignalLine  =ParamToggle("Ergodic SMI SignalLine ","No|Yes",1); 
if (PlotErgodicSignalLine  ==1) Plot(SMI_SignalLine ,"SMI SignalLine ("+f3+")",ParamColor(" SMI SignalLine",colorYellow),styleDashed);

Plot(1,"\nSMI",IIf( BuySMI, colorBlue, IIf( SellSMI, colorRed, 7 )), /* choose color*/styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); 

_SECTION_END();

_SECTION_BEGIN("Ergodic TSI Blau");
 /* Ergodic TSI Blau */
// The TSI is a smoothed True Strength indicator and the SMI is a smoothed Stochastic Momentum indicator.

Len1 = Param(" Long MA",8,1,200,1);; // Long MA
Len2 =  Param("Short MA",5,1,200,1);; // Short MA
Len3 =  Param("Smoothing",1,1,200,1); // Smoothing

Fac1 = 2 / (Len1 + 1); 		 Fac2 = 2 / (Len2 + 1);  			Fac3 = 2 / (Len3 + 1);

ROCx = C - Ref(C, -1);  
ROCy = abs(ROCx);

Value1 = 100 * AMA(AMA(AMA(ROCx, Fac1), Fac2), Fac3);
Value2 = 100 * AMA(AMA(AMA(ROCy, Fac1), Fac2), Fac3);

TSI = IIf(Value2 == 0, 0, Value1 / Value2);
Sig = AMA(TSI, Fac2);

PlotErgodicTSI =ParamToggle("Ergodic TSI","No|Yes",1); 
if (PlotErgodicTSI ==1) Plot(TSI, "TSI",ParamColor(" TSI ",colorBlueGrey) ,styleLine|styleThick|styleLeftAxisScale);
PlotErgodicSignalLineTSI  =ParamToggle("Ergodic TSI SignalLine ","No|Yes",1); 
if (PlotErgodicSignalLineTSI  ==1) Plot(Sig, "TSI Sig",ParamColor(" TSI SignalLine",colorYellow),styleDashed|styleLeftAxisScale);
Plot(0,"",colorBlack,styleLine);
 
Buy =TSI>Sig;
Sell = Sig>TSI;
Short=Sell;  Cover=Buy;
Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short);
//Plot(3,   /* defines the height of the ribbon in percent of pane width */"Ergodic TSI Blau ",IIf( Buy , colorBlue, IIf( Sell , colorRed, 0 )), /* choose color*/styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );