// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Panel Color",colorLightGrey));
SetChartBkGradientFill(ParamColor("Upper Chart",colorLightGrey),ParamColor("Lower Chart",colorLightGrey));
dec=(Param("Decimals",2,0,7,1)/10)+1;
GraphXSpace=Param("GraphXSpace",20,-10,25,1);

BarTime1=LastValue(TimeNum() - Now(4));  
DataError=IIf(Now(4) > TimeNum(),True,False); 
TimeBase=IIf(Interval(1)>0,1,0); 
_N(StrBarTime=NumToStr(BarTime1,1.0,False)); 
BT_Length=StrLen(StrBarTime); 
_N(TimeLeft_= 
WriteIf(BT_Length==1,"0:0"+StrBarTime,WriteIf(BT_Length==2,"0:"+StrBarTime, 
WriteIf(BT_Length==3,StrLeft(StrBarTime,1)+":"+StrRight(StrBarTime,2), 
StrLeft(StrBarTime,2)+":"+StrRight(StrBarTime,2))))); 
TimeLeft=WriteIf(TimeBase==1,TimeLeft_,"N/A"); 
Title= EncodeColor(16)+ " High = "+ EncodeColor(27) + WriteVal(H,dec) +
EncodeColor(16)+ "   Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
EncodeColor(16) +"  TimeLeft = "+ EncodeColor(29) +TimeLeft  +
EncodeColor(16)+ "   Volume = "+ EncodeColor(18)+ WriteVal(V,1);
_SECTION_END();

_SECTION_BEGIN("TSKPScoreCardColors");
Ctmpl= E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
total=0;
total=total+ IIf(tskp_colortmplcnd0 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd1 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd2 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd3 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd4 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd5 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd6 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd7 > 0, 1,-1); 
total=total+ IIf(tskp_colortmplcnd8 > 0, 1,-1); 

for(i=0; i < BarCount; i++ ) 
{
if( total[i] >= 5 )
Color[i]= colorBlue;
else if(total[i] <= -5 )
Color[i]=colorRed;
else
Color[i]=colorYellow;
} 
CO = Open;
CH = High;
CL = Low;
CC = Close;
PlotOHLC( CO,CH,CL,CC, "Price", color, styleCandle );//Plot Selected Ticker
_SECTION_END();

_SECTION_BEGIN("KP DynSupRes");
sw = E_TSKPSWINGLINE(High,Low,Close);
//tskp_sw, tskp_swmean,tskp_swupper,tskp_swlower
Plot(tskp_swmean,"Mean",ParamColor("MeanColor",colorBlack),ParamStyle("MeanStyle",styleThick) ); 
Plot(tskp_swupper,"Resistance",ParamColor("ResistanceColor",colorDarkRed),ParamStyle("ResistanceStyle",styleThick) ); 
Plot(tskp_swlower,"Support",ParamColor("SupportColor",colorDarkGreen),ParamStyle("SupportStyle",styleThick) ); 
_SECTION_END();

_SECTION_BEGIN("KP MeanSwingLine");
sw = E_TSKPSWINGLINE(High,Low,Close);
Plot(tskp_swmean,"Fat MeanSwing",ParamColor("FatColor",colorLightYellow),ParamStyle("FatStyle",styleLine),0,0,0,0,4); 
_SECTION_END();

_SECTION_BEGIN("KP TrendBias");
/* TSKPTrendBias with TSKPSEB */
Disp1=ParamToggle("Trend Bias","Show|Hide",1);
parmTBStyle = ParamStyle("Trend Bias Style", styleLine | styleThick, maskAll);
parmTBColor = ParamColor("Trend Bias Color", colorRed);
parmTBSlowStyle = ParamStyle("Trend Bias Slow Style", styleLine | styleThick, maskAll);
parmTBSlowColor = ParamColor("Trend Bias Slow Color", colorBlue);
dummy =  E_TSKPTRENDBIAS(High,Low,Close);
KPTB = tskp_sb;
KPTBSlow = tskp_tbxavg;
if(Disp1){
Plot(KPTB, "TB", parmTBColor, parmTBStyle); 
Plot(KPTBSlow, "TBSlow", parmTBSlowColor, parmTBSlowStyle); }
_SECTION_END();

_SECTION_BEGIN("KPAutoStop-KPA900 Trend");
Disp2=ParamToggle("KPAutoStop-KPA900 Trend","Show|Hide",0);
parmASStyle = ParamStyle("AutopStop Style", styleLine | styleThick, maskAll);
parmASColor = ParamColor("AutoStop Color", colorYellow);
parmPA900Style = ParamStyle("KP A900 Style", styleLine | styleThick, maskAll);
parmPA900Color = ParamColor("KP A900 Color", colorWhite);
if(Disp2){
Plot( E_TSKPAUTOSTOP(High,Low,Close) ,"KP AutoStop",parmASColor, parmASStyle);
Plot( E_TSKPA900(Close) , "KP A900", parmPA900Color, parmPA900Style);}
_SECTION_END();

_SECTION_BEGIN("KPStopLine-KPTriggerLine");
Disp3=ParamToggle("KPStopLine-KPTriggerLine","Show|Hide",0);
parmSLStyle = ParamStyle("KPStopLine Style", styleLine | styleThick, maskAll);
parmSLColor = ParamColor("KPStopLine Color", colorRed);
parmTLStyle = ParamStyle("KPTriggerLine Style", styleLine | styleThick, maskAll);
parmTLColor = ParamColor("KPTriggerLine Color", colorBlue);
sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
if(Disp3){
Plot( E_TSKPSTOPLINE(High,Low,Close) , "KPStopLine", parmSLColor,parmSLStyle ); 
Plot( tskp_triggerline, "KPTriggerLine", parmTLColor,parmTLStyle ); }
_SECTION_END();

_SECTION_BEGIN("KP Pivots");
Disp4=ParamToggle("KP Pivots","Show|Hide",1);
parmKPPivotHighColor = ParamColor("KP Pivot High",colorBlack);
parmKPPivotLowColor = ParamColor("KP Pivot Low",colorBlack);
CHiPr=0; CLoPr=9999999; blsLong=0;
PrevCOBar=0; NumBars=0; PrePP=0;
PrevLowVal=9999999; BuySig=0; blsShort=0;
PrevHiVal=0; blsNewCO=0; BarDif=0;

KPA900Val = E_TSKPA900(Close);
KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);
// -- Create 0-initialized arrays the size of barcount
aHPivs= H - H; aLPivs= L - L;
aHiVal= H - H; aLoVal= L - L;

Ctmpl= E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal= 0;
sctotal= sctotal+ IIf(tskp_colortmplcnd0 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd1 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd2 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd3 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd4 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd5 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd6 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd7 > 0, 1, -1); 
sctotal= sctotal+ IIf(tskp_colortmplcnd8 > 0, 1, -1);

for (curBar=0; curBar < BarCount-1; curBar++)
{
if ( curBar == 0 )
{
CHiPr=High[curBar];
CHiBar=curBar;
CLoPr=Low[curBar];
CLoBar=curBar;
blsLong=0; blsShort=0;
blsNewCO=0; PrePP=0;
PrevCOBar=0;
PrevHiVal=High[curBar];
PrevLowVal=Low[curBar];
BuySig=0; SellSig=0; blsLL=0;
}
if (High[CurBar] >= CHiPr) {
CHiPr = High[CurBar];
ChiBar = CurBar;
}
if (Low[CurBar] <= CLoPr) {
CLoPr = Low[CurBar];
CLoBar = CurBar;
}
if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){
BarDif = CurBar - PrevCOBar;
if (BarDif >= NumBars) {
blsLong=1; blsShort=0;
blsNewCO=1; PrevCOBar = CurBar;}
}
if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){
BarDif = CurBar - PrevCOBar;
if (BarDif >= NumBars) {
blsLong=0; blsShort=1;
blsNewCO=1; PrevCOBar=CurBar;}
}
if ( (blsNewCO == 1) AND (sctotal[CurBar] >= 5) AND (blsLong == 1) ) {
LVal = CurBar - CLoBar;
for (j= CLoBar-1; j <= CLoBar+1; j++)
{
if (j >=0) {
aLPivs[j] = 1;
aLoVal[j] = CLoPr;}
}
PrePP=-1;
blsNewCO=0;
CHiPr=High[CurBar];
CHiBar=CurBar;
CLoPr=Low[Curbar];
CLoBar=CurBar;
} 
else if ((blsNewCO == 1) AND (sctotal[CurBar] <= -5) AND (blsShort == 1) ) {
HVal = CurBar - CHiBar;
for (j= CHiBar-1; j <= CHiBar+1; j++)
{		
if (j >=0) {
aHPivs[j] = 1;
aHiVal[j] = CHiPr;}
}
PrePP=1;
blsNewCO=0;
CHiPr=High[CurBar];
CHiBar=CurBar;
CLoPr=Low[Curbar];
CLoBar=CurBar;} 
}
if(Disp4){
PlotShapes(
IIf(aHPivs == 1,shapeSmallCircle,shapeNone),parmKPPivotHighColor,0,aHiVal+0.05,Offset=10);
PlotShapes(
IIf(aLPivs == 1,shapeSmallCircle,shapeNone),parmKPPivotLowColor,0,aLoVal-0.05,Offset=-10);}
_SECTION_END();

_SECTION_BEGIN("KP PivotPops");
Disp5=ParamToggle("KP PivotPops","Show|Hide",0);
parmKPPivPopBuyColor = ParamColor("KP PivotPop Buy",colorDarkBlue);
parmKPPivPopSellColor = ParamColor("KP PivotPop Sell",colorDarkRed);
BarCancl=Param("BarCancel",4,1,20,1);
frMeanSwing=Param("MeanSwing Filter",1,0,1,1); // 1- Use MeanSwing Filter, 0-Donot use MeanSwing Filter

KPA900Val = E_TSKPA900(Close);
KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);
//KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
KPFast2Val = IIf((tskp_fast2val1 > 0),1,-1);

UpperBand = BBandTop(Close,20,1);
LowerBand = BBandBot(Close,20,1);
swVal = E_TSKPSWINGLINE(High,Low,Close);
MeanSwingLnVal = tskp_swmean;

// -- Create 0-initialized arrays the size of barcount
aHPivs= H - H; aLPivs= L - L;
aHiVal= H - H; aLoVal= L - L;

Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1);

for (CurBar=1; CurBar < BarCount-1; CurBar++)
{
if ( CurBar == 1 )
{
CHiPr = High[CurBar]; CHiBar = CurBar;
CLoPr = Low[CurBar]; CLoBar = CurBar;
blsLong = 0; blsShort = 0;
blsNewCO = 0; PrePP = 0; PrevCOBar = 0;
PrevHiVal = High[CurBar]; PrevLowVal = Low[CurBar];
BuySig = 0; SellSig = 0; CanclBar = 0;
}
if (High[CurBar] >= CHiPr) {
CHiPr = High[CurBar];
ChiBar = CurBar;
}
if (Low[CurBar] <= CLoPr) {
CLoPr = Low[CurBar];
CLoBar = CurBar;
}
if ( (KPA900Val[CurBar] > KPAutoStopVal[Curbar]) ){
if ( (blsLong!= 1) ){
blsNewCO = 1; SellSig = 0; blsLong = 1; blsShort = 0;
BarDif = CurBar - PrevCOBar;
if ( (BarDif >= NumBars) AND (PrePP != -1) AND (CLoPr >= PrevLowVal)){
PrevCOBar = CurBar;
CanclBar = CurBar + BarCancl; BuySig = 1;}}
}
else {
if ((blsShort != 1)) {
blsNewCO = 1; BuySig = 0; blsLong = 0; blsShort = 1;
BarDif = CurBar - PrevCOBar;
if ((BarDif >= NumBars) AND (PrePP != 1) AND (CHiPr <= PrevHiVal) ){
PrevCOBar = CurBar;
CanclBar = CurBar + BarCancl;
SellSig = 1;}}
}
if( (BuySig ==1) AND (CurBar <= CanclBar) AND (KPA900Val[curBar] >= KPAutoStopVal[curbar]) ){
if( (KPFast2Val[CurBar]  == 1) AND  (sctotal[CurBar] >= 5) AND (blsLong == 1)
AND (((frMeanSwing ==1 ) AND (Close[Curbar] > MeanSwingLnVal[Curbar])) OR (frMeanSwing==0)) AND (Close[Curbar] > UpperBand[CurBar])
AND (Close[Curbar] > Open[Curbar]) ){
aLPivs[Curbar] = 1;
aLoVal[Curbar] = Low[Curbar];
BuySig = 0;
}
else {
if ( (BuySig == 1) AND ((CurBar > CanclBar) OR  (KPA900Val[CurBar] < KPAutoStopVal[Curbar]) ) ){
BuySig = 0;}}
}
else BuySig = 0;
if( (SellSig ==1) AND (CurBar <= CanclBar) AND (KPA900Val[CurBar] <= KPAutoStopVal[Curbar]) ){
if( (KPFast2Val[CurBar]  == -1) AND  (sctotal[CurBar] <= -5) AND (blsShort == 1) 
AND (((frMeanSwing ==1 ) AND (Close[Curbar] < MeanSwingLnVal[Curbar])) OR (frMeanSwing==0)) AND (Close[Curbar] < LowerBand[CurBar]) 
AND (Close[Curbar] < Open[Curbar]) ){

aHPivs[Curbar] = 1;
aHiVal[Curbar] = High[Curbar];
SellSig = 0;
}
else {
if ( (SellSig == 1) AND ((CurBar > CanclBar) OR  (KPA900Val[CurBar] > KPAutoStopVal[Curbar]) ) ){
SellSig = 0;}}
}
else SellSig = 0;
if ( (blsNewCO == 1) ) { 
if ((sctotal[CurBar] >= 5) AND (blsLong == 1) AND (PrePP != -1) ) {
blsNewCO = 0; PrePP = -1; PrevLowVal = CLoPr;
CHiPr = High[CurBar]; CHiBar = CurBar;
CLoPr = Low[Curbar]; CLoBar = CurBar;
} 
else 
if ( (sctotal[CurBar] <= -5) AND (blsShort == 1) AND (PrePP != 1) ) {
blsNewCO = 0; PrePP = 1;
PrevHiVal = CHiPr;
CHiPr = High[CurBar]; CHiBar = CurBar;
CLoPr = Low[CurBar]; CLoBar = CurBar;} }
}
if(Disp5){
PlotShapes(
IIf(aHPivs == 1,  shapeDownArrow,shapeNone), parmKPPivPopSellColor ,0, aHiVal+0.00, Offset = -20);
PlotShapes(
IIf(aLPivs == 1,  shapeUpArrow,shapeNone), parmKPPivPopBuyColor,0, aLoVal-0.00, Offset = -20);}
_SECTION_END();

_SECTION_BEGIN("KP MoMo's");
/**********************************************************************************************************
This is a  Price Study that displays a DOT based on the folowing:
For a long signal:
    ScoreCardColor is Blue
    KPMedium > Moving Average of KPMedium
    KPFast2 > 0
    KPFast3 > 0
    KPTriggerLine > KPStopLine
    
For a short signal:
    ScoreCardColor is Red
    KPMedium < Moving Average of KPMedium
    KPFast2 < 0
    KPFast3 < 0
    KPTriggerLine < KPStopLine

This signal will reassert itself i.e., display again if one of more of the conditions that trigger go away
and then return to the trigger state.

Note:  This indicator is calculated at the completion of a price bar.  This is different than 
some indicators where the values are calculated/updated upon the arrival
of every tick.  
************************************************************************************************************/

Disp6=ParamToggle("KP MoMo's","Show|Hide",0);
parmMoUpColor = ParamColor("MoUpColor", colorAqua);
parmMoDnColor = ParamColor("MoDnColor", colorRed);
blsLong = 0;
KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
// tskp_upsell, tskp_triggerline, tskp_triggerlinevma
sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
KPTriggerLine = tskp_triggerline;
KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
//tskp_fast2val1, tskp_fast2val2
dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1); 

// tskp_mediumma,tskp_mediumup,tskp_mediumdown
dummy = E_TSKPMEDIUM(Close);
KPMediumUP = tskp_mediumup;
KPMediumDwn = tskp_mediumdown;
KPMediumMA = tskp_mediumma;

for (curBar=5; curBar < BarCount-1; curBar++)
{
if( (blsLong == -1) OR (blsLong == 0))
{
if ((sctotal[CurBar]  >= 5) AND (KPMediumUP[CurBar]  > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == 1) AND 
(KPFast2Val[CurBar]  == 1) AND (KPTriggerLine[CurBar]  >= KPStopLine[CurBar] ))
{
blsLong = 1;
aLPivs[CurBar] = 1;
aLoVal[CurBar] = Low[CurBar];}
}
if( (blsLong == 1) OR (blsLong == 0))
{
if ((sctotal[CurBar]  <= -5) AND (KPMediumDwn[CurBar]  < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == -1) AND 
(KPFast2Val[CurBar]  == -1) AND (KPTriggerLine[CurBar]  <= KPStopLine[CurBar] ))
{
blsLong = -1;
aHPivs[Curbar] = 1;
aHiVal[Curbar] = High[Curbar];}
}
if ((blsLong == 1) AND ((sctotal[CurBar]  < 5) OR (KPMediumUP[CurBar]  < KPMediumMA[CurBar] )  OR  
(KPFast2Val[CurBar]  < 1)  OR  (KPFast3Val[CurBar]  < 1) OR (KPTriggerLine[CurBar]  < KPStopLine[CurBar] )) )
{
blsLong= 0;
}
if ((blsLong == -1) AND ((sctotal[CurBar]  > -5)  OR  (KPMediumDwn[CurBar] > KPMediumMA[CurBar] )  OR  
(KPFast2Val[CurBar]  > -1)  OR (KPFast3Val[CurBar]  > -1)  OR 
(KPTriggerLine[CurBar]  > KPStopLine[CurBar] )) )
{
blsLong = 0;}}
if(Disp6){
PlotShapes(
IIf(aHPivs == 1,shapeDownArrow,shapeNone),parmMoDnColor,0,aHiVal+0.00,Offset=-30);
PlotShapes(
IIf(aLPivs == 1,shapeUpArrow,shapeNone),parmMoUpColor,0,aLoVal-0.00,Offset=-30);}
_SECTION_END();

_SECTION_BEGIN("KP PushDots");
Disp7=ParamToggle("KP PushDots","Show|Hide",0);
parmPDBuyColor = ParamColor("PDBuyColor", colorWhite);
parmPDSellColor = ParamColor("PDSellColor", colorDarkRed);
Combo = E_TSKPCOMBO(Open,High,Low,Close,Volume);
NewUpDown = E_TSKPNEWUPDOWN(Open,High,Low,Close,Volume);
UpDown7 = 0.5*(High+Low) - E_TSKPSTOPLINE(High,Low,Close);
if(Disp7){
PlotShapes( IIf( ((Combo>0) AND (NewUpDown > 0) AND (UpDown7 > 0)),shapeSmallCircle,shapeNone), parmPDBuyColor,0, Low, -10);
PlotShapes( IIf( ((Combo<0) AND (NewUpDown < 0) AND (UpDown7 < 0)),shapeSmallCircle,shapeNone), parmPDSellColor,0, High, 10);}
_SECTION_END();

_SECTION_BEGIN("KP PowerPops");
Disp8=ParamToggle("KP PowerPops","Show|Hide",0);
parmPPHighColor = ParamColor("PPHighColor", colorYellow);
parmPPLowColor = ParamColor("PPLowColor", colorYellow);
blsLong = 0;

KP115Val = E_TSKP115SPLIT(High,Low,Close);
KP104Val = E_TSKP104(High,Low,Close); 
dummy = E_TSKPMEDIUM(Close);
KPMediumUpVal = tskp_mediumup;
KPMediumDnVal = tskp_mediumdown;
UpperBand = BBandTop(Close,20,1);
LowerBand = BBandBot(Close,20,1);
swVal = E_TSKPSWINGLINE(High,Low,Close);
MeanSwingLnVal = tskp_swmean;

for (curBar=5; curBar < BarCount-1; curBar++)
{
if (blsLong != 1) {
if( (sctotal[curBar] >= 5) AND (KPMediumUpVal[curBar] > 1.75) AND (Close[curBar] > UpperBand[curBar]) 	
AND (Close[curBar] > KP115Val[curBar]) AND (Close[curBar] > KP104Val[curBar]) 
AND (High[curBar] > High[curBar-3]) AND (Close[curBar] > Close[curBar-3]) 
AND (Close[CurBar] > MeanSwingLnVal[CurBar] ) ){
blsLong = 1;
aLPivs[curBar] =1;
aLoVal[curBar] = Low[curBar];}
}
else if (blsLong != -1) {
if( (sctotal[curBar] <= -5) AND (KPMediumDnVal[curBar] < -1.75) AND (Close[curBar] < LowerBand[curBar]) 	
AND (Close[curBar] < KP115Val[curBar]) AND (Close[curBar] < KP104Val[curBar]) 
AND (Low[curBar] < Low[curBar-3]) AND (Close[curBar] < Close[curBar-3])
AND (Close[curBar] < MeanSwingLnVal[curBar] ) ){
blsLong = -1;
aHPivs[curBar] =1;
aHiVal[curBar] = High[curBar];}}}
if(Disp8){
PlotShapes(
IIf(aHPivs == 1,shapeDownArrow,shapeNone),parmPPHighColor,0,aHiVal+0.00, Offset = -35);
PlotShapes(
IIf(aLPivs == 1,shapeUpArrow,shapeNone),parmPPLowColor,0,aLoVal-0.00, Offset = -35);}
_SECTION_END();

_SECTION_BEGIN("KP Combo");
Disp9=ParamToggle("KP Combo","Show|Hide",0);
Combo = E_TSKPCOMBO(Open,High,Low,Close,Volume);
if(Disp9){
PlotShapes(
IIf( Combo>0, shapeUpArrow, 
IIf(combo<0,shapeDownArrow,shapeNone)), 
IIf(combo>0,colorBlue,colorRed),0,IIf( Combo>0, Low, High ) ); }
_SECTION_END();

_SECTION_BEGIN("KP New UpDown");
Disp10=ParamToggle("KP NewUpDown","Show|Hide",1);
NewUpDown = E_TSKPNEWUPDOWN(Open,High,Low,Close,Volume);
if(Disp10){
PlotShapes( 
IIf( NewUpDown >0, shapeSmallCircle, IIf(NewUpDown <0, shapeSmallCircle+shapePositionAbove,shapeNone)), 
IIf(NewUpDown >0,colorBlue,colorRed),0,IIf( NewUpDown >0, Low, High ) ); }
_SECTION_END();

_SECTION_BEGIN("KP UpDown");
Disp11=ParamToggle("KP UpDown","Show|Hide",0);
updown7 = 0.5*(High+Low) - E_TSKPSTOPLINE(High,Low,Close);
if(Disp11){
PlotShapes( 
IIf( updown7 >0, shapeUpArrow, IIf(updown7 <0,shapeDownArrow,shapeNone)), 
IIf(updown7 >0,colorBlue,colorRed),0,IIf( updown7 >0, Low, High ) ); }
_SECTION_END();

_SECTION_BEGIN("KP Standard Error Bands");
Disp12=ParamToggle("KP Standard Error Bands","Show|Hide",1);
Periods=Param("Standard Error",30,3,200,1); 
Smooth=Param("Smooth",20,2,100,1);

LRCurve=LinearReg( C, periods ); 
MALRCurve=MA(LRCurve, Smooth);
SEValue=StdErr( C, periods ); 
SErrorAvg=MA(SEValue, Smooth);

LowerBand= MALRCurve - SErrorAvg ;
UpperBand= MALRCurve + SErrorAvg ;
if(Disp12){
Plot(MALRCurve,"MidBand",ParamColor("ColorMB",colorViolet),ParamStyle("StyleMB",styleLine|styleThick)); 
Plot(UpperBand,"UpperBand",ParamColor("ColorUp",colorViolet),ParamStyle("StyleUp",styleDashed,maskDefault));
Plot(LowerBand,"LowerBand",ParamColor("ColorLo",colorViolet),ParamStyle("StyleLow",styleDashed,maskDefault));
PlotOHLC( UpperBand,UpperBand,LowerBand,LowerBand,"Band",ColorRGB(238,207,161),styleCloud|styleNoLabel);}
_SECTION_END();

_SECTION_BEGIN("KP M Range");
mp=0.5*(High + Low);
tightstop=E_TSKPTIGHTSTOP(High,Low,Close);
stopline=E_TSKPSTOPLINE(High,Low,Close);
Color=colorWhite;
for( i = 0; i < BarCount; i++ ) 
{ 
if( mp[i] > stopline[i] && mp[i] > tightstop[i]  )
Color[i] = colorBlue;
else if(  mp[i] < stopline[i] && mp[i] < tightstop[i])
Color[i] = colorRed;
else
Color[i] = colorWhite;
} 
Plot(0,"MRange0",Color,styleOwnScale|styleArea|styleNoLabel,0, 90 );
Plot(1,"MRange1",Color,styleOwnScale|styleArea|styleNoLabel,0, 90 );
_SECTION_END();

_SECTION_BEGIN("KP TrendBias BackGround");
//Plot Tone
parmToneColorUp=ParamColor("Tone Color Up", colorLightBlue );
parmToneColorDn=ParamColor("Tone Color Dn", colorTan);
RibbonSize=Param("Ribbon Size",10,0.5,10,0.5);
Plot( RibbonSize,"Tone",IIf(KPTB > KPTBSlow,parmToneColorUp,parmToneColorDn),styleOwnScale|styleArea|styleNoLabel,0,10);
_SECTION_END();