Buy sell arrows on RSI curve not coming

Hellow,

Wants help to plot buy sell arrows on the RSI curve. Now they are coming on RSI 50 line. How to the following AFL to get arrows on RSI curve. Aprreciate your hlep.

_SECTION_BEGIN("RSI");
//SetChartOptions(0,0,chartGrid20|chartGrid50|chartGrid80);
periods = Param( "Periods", 14, 1, 200, 1 );
maxClip = Param( "maxClip", 70, 1, 100, 1 );
minClip = Param( "minClip", 30, 1, 100, 1 );

Plot( 50, _DEFAULT_NAME(), colorBlack , styleDashed|styleNoTitle|styleNoLabel );
Plot( 70, _DEFAULT_NAME(), colorBlack , styleLine|styleNoTitle|styleNoLabel );
Plot( 30, _DEFAULT_NAME(),colorBlack , styleLine|styleNoTitle|styleNoLabel );

r = RSI(periods);
RSI_col= IIf ( r>=50, colorBlue, IIf ( r<50,colorred, colorBlack));
Plot( RSI( periods), _DEFAULT_NAME(), RSI_col,styleThick, 0,0,0,2,2);

_SECTION_BEGIN("Buy Sell Arrows");
shapesSignalswitch = ParamToggle("Cross Signal Arrows","On,Off");
UPcolor = ParamColor( "UP Color", colorBlue );
DOWNcolor = ParamColor( "Down Color", colordarkRed );

Buy= RSI(14) > 70 ;
Sell= RSI(14) < 30 ;

PlotShapes(IIf(Buy,shapehollowUpArrow,shapeNone),colorBlue,0 );
PlotShapes(IIf(Sell,shapehollowDownArrow,shapeNone),colorRed,0 );

Buy1= RSI(14) > 30 AND Ref( RSI( 14), -1 ) < 30;;
sell1= RSI(14) < 70 AND Ref( RSI( 14), -1 ) > 70;;

PlotShapes(IIf(Buy1,shapeUpArrow,shapeNone),colorBlue,0 );
PlotShapes(IIf(Sell1,shapeDownArrow,shapeNone),colorRed,0 );
_SECTION_END();

r = RSI(periods);
PlotOHLC( r,r,50,r, "", IIf( r > 50, colorBrightGreen, colordarkRed), styleCloud | styleNoLabel | styleClipMinMax, minClip, maxClip );

RSIStatus =
WriteIf (RSI(14) > 70 , " Over Bought",
WriteIf (RSI(14) < 30 , " Over Sold"," "));

RSIColor=
WriteIf ( RSI(14) > 70, EncodeColor(colorBlue),
WriteIf ( RSI(14) < 30, EncodeColor(colordarkRed),
EncodeColor(colorBlack) ));

_SECTION_END();
Title = EncodeColor(colorBlack) +"RSI Check for Over Bought Sold "

+" "

  • EncodeColor(colorWhite) + "{{INTERVAL}} "
    //+" "
    //+" "
  • EncodeColor(colorBlack)+ " RSI "
  • WriteIf(RSI(14) >= 50,EncodeColor(colorBlue),
    WriteIf(RSI(14) < 50,EncodeColor(colordarkRed)," ")) + WriteVal(RSI(14),format=1.2)
  • EncodeColor(colorBlack) + " " + RSIcolor + RSIStatus
    ;

@kv_maligi, first of all, I remember you that when posting some code, it is mandatory to use the code tags as explained in the [Enter the AFL code properly] (How to use this site) section of "How to use this site".

The formula you posted is a little mess (as it usually happens when doing paste & copy from multiple sources).
It needs a proper cleanup removing duplications, unneeded sections, replacing the repeated constant values with variables, or actually used parameters, etc.), but I leave that to you as a learning exercise.
Anyway, the part that you would fix, as per your topic title, are the calls to the PlotShapes() function.

If you study the documentation closely, you will see that there are additional parameters (yposition and the associated offset) that allows you to decide precisely where to position in the y-axis the arrows (in your case using the r variable calculated in the r = RSI(periods); line.

Moreover, you'll probably need to tale a look at the ExRem() function to remove excessive signals (to avoid drawing multiple sequences of arrows) or alternatively use the Cross() function to get fewer signals from the start.

3 Likes

Many Thanks Beppe, Issue solved.

Solution
PlotShapes(IIf(Buy,shapehollowUpArrow,shapeNone),colorBlue,0,70 );
PlotShapes(IIf(Sell,shapehollowDownArrow,shapeNone),colorRed,0,30 );