Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

RSI Closing value by Alvarez for Amibroker (AFL)
c62
about 4 years ago
Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:
amibroker, oscillator, rsi

Determines the closing value of a stock need to reach a particular RSI value
function ReverseRSI(nLen, rsiTarget)

Indicator / Formula

Copy & Paste Friendly
// Provided as is by www.AlvarezQuantTrading.com 

///////////////////  Reverse RSI Calculator  ////////////////////////
// Determines the closing value of a stock need to reach a particular RSI value
function ReverseRSI(nLen, rsiTarget)
{
	gain = Max(C-Ref(C,-1), 0);     
	loss = -Min(C-Ref(C,-1), 0);
	
	rsGain = IIf(BarIndex() < nLen-1,Null,   
				IIf(BarIndex()==nLen-1, MA(gain, nLen), gain));
	rsLoss = IIf(BarIndex() < nLen-1,Null,  
				IIf(BarIndex()==nLen-1, MA(Loss,nLen), Loss));
				
	rsGain = AMA(rsGain, 1/nLen); 
	rsLoss = AMA(rsLoss, 1/nLen);  
	
	RSIcalc = IIf(BarIndex()<nLen-1, Null, 100*rsGain/(rsGain+rsLoss));

	targetPrice = IIf( (rsiTarget < RSI(nLen)),
						C-100*(((nLen-1)*rsGain)/rsiTarget)+((nLen-1)*rsGain)+((nLen-1)*rsLoss),
						C+((rsiTarget/(100-rsiTarget)*((nLen-1)*rsLoss))-((nLen-1)*rsGain)) 
					 );
					 
	return targetPrice;
}
 
	
Filter = TRUE ;
AddColumn(C,"Close");
AddColumn(RSI(2), "RSI2");
AddColumn(ReverseRSI(2, 30),"RSI30-Next Day Price",1.3);
AddColumn(ReverseRSI(2, 70),"RSI70-Next Day Price",1.3);

3 comments

1. Arwall19

Hello c62
This AFL shows nothing. All blank.
Would you please tell how to use it.
Thanks.

2. administrator

It’s an exploration only. No chart.

3. ujjwal

hey man thanks for the code.. can you guide me how to plot the rsi using this formula and can we apply the range of rsi here ?

Leave Comment

Please login here to leave a comment.

Back