RSI Prediction-Buy/Sell Signals at 30 & 70

#1
Hi All

I have the following code that predicts price at RSI at 70 and 30. I would be greatful if someone can help me plot Buy signal at RSI Crossing over 30 and Sell signal when RSI touches 70. Also need exploration bit for Analysis.

---------------------------
_SECTION_BEGIN("RSI_Next_Bar");
Value1 = Param("RSI BearResistance", 70, 1, 100, 0.1 );
Value2 = Param("RSI BullSupport", 30, 1, 100, 0.1 );
WildPer = Param("Time periods", 15, 1, 100 );
ExpPer = 2 * WildPer - 1;
AUC = EMA( Max( C - Ref( C, -1 ), 0 ), ExpPer );
ADC = EMA( Max( Ref( C, -1 ) - C, 0 ), ExpPer );
x1 = (WildPer - 1) * ( ADC * Value1 / (100-Value1) - AUC);
RevEngRSI1 = IIf( x1 >= 0, C + x1, C + x1 * (100-Value1)/Value1 );
x2 = (WildPer - 1) * ( ADC * Value2 / (100-Value2) - AUC);
RevEngRSI2 = IIf( x2 >= 0, C + x2, C + x2 * (100-Value2)/Value2 );

Plot( Close, Date()+", Close ", colorWhite, styleCandle );
Plot( RevEngRSI1, "RSIBearResistance( "+WriteVal(WildPer,1.0)+", "+ WriteVal(Value1, 1.2)+" )", colorRed );
Plot( RevEngRSI2, "RSIBullSupport( "+WriteVal(WildPer,1.0)+", "+ WriteVal(Value2, 1.2)+" )", colorGreen );

_SECTION_END();

--------------------------

I know it might sound dumbed or may be too easy to do, but i am just starting to get a hang of AmiBroker. So need your help on this.

Cheers.....
 
#3
I know sir, this is one of the parameters for me to ascertain the resistance and support in the extreme side. Once I identify the stocks above 70 or below 30, then would study other indicators like MACD, STO, & BB and Candlesticks.

Thanks for your concern. regards
 

casoni

Well-Known Member
#4
Hi All

I have the following code that predicts price at RSI at 70 and 30. I would be greatful if someone can help me plot Buy signal at RSI Crossing over 30 and Sell signal when RSI touches 70. Also need exploration bit for Analysis.

---------------------------
_SECTION_BEGIN("RSI_Next_Bar");
Value1 = Param("RSI BearResistance", 70, 1, 100, 0.1 );
Value2 = Param("RSI BullSupport", 30, 1, 100, 0.1 );
WildPer = Param("Time periods", 15, 1, 100 );
ExpPer = 2 * WildPer - 1;
AUC = EMA( Max( C - Ref( C, -1 ), 0 ), ExpPer );
ADC = EMA( Max( Ref( C, -1 ) - C, 0 ), ExpPer );
x1 = (WildPer - 1) * ( ADC * Value1 / (100-Value1) - AUC);
RevEngRSI1 = IIf( x1 >= 0, C + x1, C + x1 * (100-Value1)/Value1 );
x2 = (WildPer - 1) * ( ADC * Value2 / (100-Value2) - AUC);
RevEngRSI2 = IIf( x2 >= 0, C + x2, C + x2 * (100-Value2)/Value2 );

Plot( Close, Date()+", Close ", colorWhite, styleCandle );
Plot( RevEngRSI1, "RSIBearResistance( "+WriteVal(WildPer,1.0)+", "+ WriteVal(Value1, 1.2)+" )", colorRed );
Plot( RevEngRSI2, "RSIBullSupport( "+WriteVal(WildPer,1.0)+", "+ WriteVal(Value2, 1.2)+" )", colorGreen );

_SECTION_END();

--------------------------

I know it might sound dumbed or may be too easy to do, but i am just starting to get a hang of AmiBroker. So need your help on this.

Cheers.....
add this below your code

Buy=Cross(C,RevEngRSI2);
Short=Cross(RevEngRSI1,C);
BuyPrice=ValueWhen(Buy,C,1);
ShortPrice=ValueWhen(Short,C,1);
PlotShapes(Buy*shapesmallUpTriangle, colorGreen,0,L,-15);
PlotShapes(Short*shapesmallDownTriangle, colorRed,0,H,-15);

Filter = 1;// Buy OR Short ;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Ticker", 1, 2,colorGrey40,100);
AddColumn(close, "Close",1.2, colorDefault,2,50);
AddColumn(RevEngRSI2,"LongAbove:",1.2,colorpaleGreen,colorBlack,70);
AddColumn(RevEngRSI1,"ShortBelow ",1.2, colorRed,colorBlack,70) ;
AddColumn(IIf(Buy,BuyPrice,Null),"Buy", 1.2,1,colorGreen,50);
AddColumn(IIf(Short,ShortPrice,Null),"Sell " ,1.2,1,colorOrange,50);
 
#5
Hi casoni

Really appreciate your help.

I have incorporated the codes suggested and I get the chart (attached here), which is great.

However I am still finding problem during exploration. If you see the chart:

PFS at 70 RSI has a predictable price of 69.03
PFS at 30 RSI has a predictable price of 38.24

PFS is currently trading at 69.85

What i want from the explorer is

Current Price, Volume, Price (when RSI is 70), (Price when RSI is 30)

ie. 69.85, 3720050, 69.03, 38.24

I will then export it to excel and identify extremes.

I hope I am able to describe my problem.

Incorporated Code is given below:
------------------------------------
_SECTION_BEGIN("RSI_Next_Bar");
Value1 = Param("RSI BearResistance", 70, 1, 100, 0.1 );
Value2 = Param("RSI BullSupport", 30, 1, 100, 0.1 );
WildPer = Param("Time periods", 15, 1, 100 );
ExpPer = 2 * WildPer - 1;
AUC = EMA( Max( C - Ref( C, -1 ), 0 ), ExpPer );
ADC = EMA( Max( Ref( C, -1 ) - C, 0 ), ExpPer );
x1 = (WildPer - 1) * ( ADC * Value1 / (100-Value1) - AUC);
RevEngRSI1 = IIf( x1 >= 0, C + x1, C + x1 * (100-Value1)/Value1 );
x2 = (WildPer - 1) * ( ADC * Value2 / (100-Value2) - AUC);
RevEngRSI2 = IIf( x2 >= 0, C + x2, C + x2 * (100-Value2)/Value2 );

Plot( Close, Date()+", Close ", colorWhite, styleCandle );
Plot( RevEngRSI1, "RSIBearResistance( "+WriteVal(WildPer,1.0)+", "+ WriteVal(Value1, 1.2)+" )", colorRed );
Plot( RevEngRSI2, "RSIBullSupport( "+WriteVal(WildPer,1.0)+", "+ WriteVal(Value2, 1.2)+" )", colorGreen );


Buy=Cross(C,RevEngRSI2);
Short=Cross(RevEngRSI1,C);
BuyPrice=ValueWhen(Buy,C,1);
ShortPrice=ValueWhen(Short,C,1);
PlotShapes(Buy*shapeSmallUpTriangle, colorGreen,0,L,-15);
PlotShapes(Short*shapeSmallDownTriangle, colorRed,0,H,-15);

Filter = 1;// Buy OR Short ;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Ticker", 1, 2,colorGrey40,100);
AddColumn(Close, "Close",1.2, colorDefault,2,50);
AddColumn(RevEngRSI2,"LongAbove:",1.2,colorPaleGreen,colorBlack,70);
AddColumn(RevEngRSI1,"ShortBelow ",1.2, colorRed,colorBlack,70) ;
AddColumn(IIf(Buy,BuyPrice,Null),"Buy", 1.2,1,colorGreen,50);
AddColumn(IIf(Short,ShortPrice,Null),"Sell " ,1.2,1,colorOrange,50);
_SECTION_END();

-----------------------------------

Many Thanks
 
Last edited:

bunti_k23

Well-Known Member
#6
How accurate are the levels predicted by afl ? Have anyone used it on rt charts.:)
 
#7
I am using it on EOD Charts and extremes identified are analyzed with Candlestick and volume and Sto patterns. Seems to give predictable result.

However feel free to dissect it. It would be for general good.
 

casoni

Well-Known Member
#8
Current Price, Volume, Price (when RSI is 70), (Price when RSI is 30)

ie. 69.85, 3720050, 69.03, 38.24

I will then export it to excel and identify extremes.


Filter = 1;// Buy OR Short ;
AddColumn(Close, "Close",1.2, colorDefault,2,50);
AddColumn(volume, "Vol",1.2, colorDefault,2,50);
AddColumn(RevEngRSI1,"(Rsi 70) ",1.2, colorRed,colorBlack,70) ;
AddColumn(RevEngRSI2,"(Rsi 30)",1.2,colorPaleGreen,colorBlack,70);

//AddColumn(IIf(Buy,BuyPrice,Null),"Buy", 1.2,1,colorGreen,50);
//AddColumn(IIf(Short,ShortPrice,Null),"Sell " ,1.2,1,colorOrange,50);
 

casoni

Well-Known Member
#10
Thanks casoni

can you post the final code as my exploration is giving different result than your screenshot. Regards
its the same code , difference is due to data ,[ i am using Subha downloader ] , you Explore at your end and telly the result with your chart , it will be the same.
 

Similar threads