// Downloaded From https://www.WiseStockTrader.com
function RSIUP( period )
{
av = Param("EMA",10,1,100,1);
P = N = 0;
EM = EMA(C,av);

result = Null;
K = 2/(period + 1);
for( i = 1; i < BarCount; i++ )
{

diff = EM[ i ] - EM[ i - 1 ];
W = S = 0;
if( diff > 0 ) 
	W = diff;
if( diff < 0 ) 
	S = -diff;



P = ( ( period -1 ) * P + W ) / period;
N = ( ( period -1 ) * N + S ) / period;

if( i >= period )
result[ i ] = P;
}
return result;

} 

function RSIDN( period )
{
av = Param("EMA",10,1,100,1);
P = N = 0;
EM = EMA(C,av);

result = Null;
K = 2/(period + 1);
for( i = 1; i < BarCount; i++ )
{

diff = EM[ i ] - EM[ i - 1 ];
W = S = 0;
if( diff > 0 ) 
	W = diff;
if( diff < 0 ) 
	S = -diff;



P = ( ( period -1 ) * P + W ) / period;
N = ( ( period -1 ) * N + S ) / period;


if( i >= period )
result[ i ] = N;
}
return result;

} 


Title = "RSI Up Down";
pr = Param("Period",14,1,100,1);



Plot( RSIUP( pr ), "RSI UP", colorGreen );
Plot( RSIDN( pr ), "RSI Down", colorRed );

Buy = Cross( RSIUP( pr ),RSIDN( pr ));
Sell = Cross(RSIDN( pr ),RSIUP( pr ));
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ) );