// Downloaded From https://www.WiseStockTrader.com
Area = 100;
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
K=StochK( periods , Ksmooth);

 

function pHigh( Area )
{
	HHVtemp = HHV( High, Area);
	result = HHVTemp;
		return result;
}

function pLow( Area )
{
	LLVtemp = LLV( Low, Area );
	result = LLVtemp;
	return result;
}

function NewpHigh( Area )
{
     ph = pHigh(  Area  );
         ph =  IIf(  K  >  80 , pHigh(  Area  ),  Ref( Nz( ph ), -1 ));   
  return ph; 
}

function NewpLow( Area )
{
    pl = pLow(  Area  );
      

    pl = IIf(  K  <  20 , pLow(  Area  ),  Ref( Nz( pl ), -1 ));  
       

  return pl;  
}

showPL=NewpLow( 100 );
showPH=NewpHigh( 100 );

Plot( showPL, "DL", colorRed );
Plot( showPH, "DH", colorGreen );