Using the RSI coded as basis, I tried to create an indicator that would plot on
the price chart a pricevalue-for-next-bar that would cause the RSI(n) to equal
70. So I would know one day in advance at which price (in this case, closing
price) I could consider my position as being overbought.
My algebric knowledge seems insufficient to pull out the right AFL code from
the below RSI function (provided by Tomasz in the past and which gives
identical result to the built in RSI:
function BuiltInRSIEquivalent( period )
{
P = N = 0;
result = Null;
for( i = 1; i < BarCount; i++ )
{
diff = C[ i ] - C[ 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 ] = 100 * P / ( P + N );
}
return result;
}
Plot( BuiltInRSIEquivalent( 14 ), "RSI 1", colorRed );
Plot( RSI( 14 ), "RSI 2", colorBlue );
Any help appreciated - this indicator would allow one to exit MOC by adding a
condition to your order: exit at close if price > x.
Carl