// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("TD Pressure Ratio");
SetChartBkColor(16);
Periods = Param("Periods",13,1,50,1);
function TDPressure (Periods)
{
for( i = 2; i < BarCount; i++ )

{
if((O[i] - C[i-1]) / C[i-1] > 0.15) // gapup
{
BP[i] = (H[i] - C[i-1] + C[i] - L[i]) * V[i];
}
else if((C[i-1]-O[i]) / O[i] > 0.15)// gapdown
{
SP[i] = (C[i-1] - L[i] + H[i] - C[i]) * V[i];
}
else
{
BP[i] = IIf(C[i] > O[i], C[i] - O[i],0) * V[i];
SP[i] = IIf(C[i] < O[i], C[i] - O[i],0) * V[i];
}
}
Result = 100 *Sum(BP,Periods)/ (Sum(BP,Periods) -
Sum(SP,Periods));
Result = IIf(Result < 0,0,Result);
Result = IIf(Result > 100,100,Result);
return Result;
}

TDP = TDPressure(Periods);
Plot(TDP ,"TD Pressure",colorLightBlue,1);
Plot( 25 , "", colorGreen,styleDashed);
Plot( 50 , "", colorLightGrey,styleDashed);
Plot( 75 , "", colorRed,styleDashed);
_SECTION_END();