Help adding Buy Sell arrows to the SMOOTHED RSI DIVERGENCE Indicator......

#1
This is the Smoothed RSI indicator by KarthikMaran......I've just removed some lines and added Divergence detection code to it.......I need a little help from you guys........I've attached the screenshots of the indicator.....Can someone plz add the code sothat a buy arrow is shown when divergence is detected upwards and sell arrow when divergence detected downwards......and also please add the exploration code.....It will be very helpful.








SetChartOptions(0,0,chartGrid30|chartGrid70);
Period = Param("RSI Period",12,6,30,1);
smooth1 = Param("First Smoothing period",40,40,100,1);
smooth2 = Param("Second Smoothing Period",9,2,15,1);
trsi = RSI(Period);
x = MA(trsi, smooth1)-trsi;
y = MA(50 - x, smooth2) ;
z = MA(y,9); //signal
Plot(z,"Signal",colorOrange,styleThick);


QQEDivergance=ParamToggle("Shows QQEDivergance", "No|Yes",1);
if(QQEDivergance)
{
_SECTION_BEGIN("Trendlines_Wedge");
G=0;// set G=1, 2, 3, ... to see previous Resistance trendlines
GG=0;// set G=1, 2, 3, ... to see previous Support trendlines
x = Cum(1);
per = 1;// sensitivity calibration
s1=z;s11=z;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1+GG ));
startt=LastValue(ValueWhen( pS, x, 2+GG ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1+GG ) );
startS = LastValue( ValueWhen( pS, s1, 2+GG ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;// the Support trendline equation
Plot(IIf(x>startt-6 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10),"Support",IIf(as>0,5,4),8);
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1+G ));
startt1=LastValue(ValueWhen( pR, x, 2+G ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1+G ) );
startR = LastValue( ValueWhen( pR, s11, 2 +G ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;// the Resistance trendline equation
Plot(IIf(x>startT1-6 AND TRENDLINER>0 AND TRENDLINER<100,trendlineR,-1e10),"Resistance",IIf(Ar>0,5,4),8);
Ascwedge=Ar>0.5 AND As>sqrt(2)*Ar AND trendlineR>trendlineS;
Descwedge= As<-0.5 AND As>Ar/sqrt(2) AND trendlineR>trendlineS;
_SECTION_END();
}
 
Last edited:
#4


please check the code below. i've added buy & sell signals. arrows are not available on chart but set your scrips on auto analyzer and see buy or short signals there.

SetChartOptions(0,0,chartGrid30|chartGrid70);
Period = Param("RSI Period",12,6,30,1);
smooth1 = Param("First Smoothing period",40,40,100,1);
smooth2 = Param("Second Smoothing Period",9,2,15,1);
trsi = RSI(Period);
x = MA(trsi, smooth1)-trsi;
y = MA(50 - x, smooth2) ;
z = MA(y,9); //signal
Plot(z,"Signal",colorOrange,styleThick);


QQEDivergance=ParamToggle("Shows QQEDivergance", "No|Yes",1);
if(QQEDivergance)
{
_SECTION_BEGIN("Trendlines_Wedge");
G=0;// set G=1, 2, 3, ... to see previous Resistance trendlines
GG=0;// set G=1, 2, 3, ... to see previous Support trendlines
x = Cum(1);
per = 1;// sensitivity calibration
s1=z;s11=z;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1+GG ));
startt=LastValue(ValueWhen( pS, x, 2+GG ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1+GG ) );
startS = LastValue( ValueWhen( pS, s1, 2+GG ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;// the Support trendline equation
Plot(IIf(x>startt-6 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10),"Support",IIf(as>0,5,4),8);
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1+G ));
startt1=LastValue(ValueWhen( pR, x, 2+G ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1+G ) );
startR = LastValue( ValueWhen( pR, s11, 2 +G ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;// the Resistance trendline equation
Plot(IIf(x>startT1-6 AND TRENDLINER>0 AND TRENDLINER<100,trendlineR,-1e10),"Resistance",IIf(Ar>0,5,4),8);
Ascwedge=Ar>0.5 AND As>sqrt(2)*Ar AND trendlineR>trendlineS;
Descwedge= As<-0.5 AND As>Ar/sqrt(2) AND trendlineR>trendlineS;

SetPositionSize(50,spsShares);

Buy=z>Ref(z,-1);
Sell=z<Ref(z,-1);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Short=Sell;
Cover=Buy;

shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,colorGreen, colorRed),0,IIf(Buy,Low,High));

_SECTION_END();
}
 
#5


please check the code below. i've added buy & sell signals. arrows are not available on chart but set your scrips on auto analyzer and see buy or short signals there.

SetChartOptions(0,0,chartGrid30|chartGrid70);
Period = Param("RSI Period",12,6,30,1);
smooth1 = Param("First Smoothing period",40,40,100,1);
smooth2 = Param("Second Smoothing Period",9,2,15,1);
trsi = RSI(Period);
x = MA(trsi, smooth1)-trsi;
y = MA(50 - x, smooth2) ;
z = MA(y,9); //signal
Plot(z,"Signal",colorOrange,styleThick);


QQEDivergance=ParamToggle("Shows QQEDivergance", "No|Yes",1);
if(QQEDivergance)
{
_SECTION_BEGIN("Trendlines_Wedge");
G=0;// set G=1, 2, 3, ... to see previous Resistance trendlines
GG=0;// set G=1, 2, 3, ... to see previous Support trendlines
x = Cum(1);
per = 1;// sensitivity calibration
s1=z;s11=z;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1+GG ));
startt=LastValue(ValueWhen( pS, x, 2+GG ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1+GG ) );
startS = LastValue( ValueWhen( pS, s1, 2+GG ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;// the Support trendline equation
Plot(IIf(x>startt-6 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10),"Support",IIf(as>0,5,4),8);
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1+G ));
startt1=LastValue(ValueWhen( pR, x, 2+G ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1+G ) );
startR = LastValue( ValueWhen( pR, s11, 2 +G ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;// the Resistance trendline equation
Plot(IIf(x>startT1-6 AND TRENDLINER>0 AND TRENDLINER<100,trendlineR,-1e10),"Resistance",IIf(Ar>0,5,4),8);
Ascwedge=Ar>0.5 AND As>sqrt(2)*Ar AND trendlineR>trendlineS;
Descwedge= As<-0.5 AND As>Ar/sqrt(2) AND trendlineR>trendlineS;

SetPositionSize(50,spsShares);

Buy=z>Ref(z,-1);
Sell=z<Ref(z,-1);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Short=Sell;
Cover=Buy;

shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,colorGreen, colorRed),0,IIf(Buy,Low,High));

_SECTION_END();
}
Thanks for giving it a try.........but the analysis report does not match with the actual graph.......in graph if the last signal generated is SELL then in analysis its showing as BUY......signal is so confusing but still anyway thanks for the try.
 

Abhi1284

Active Member
#6


please check the code below. i've added buy & sell signals. arrows are not available on chart but set your scrips on auto analyzer and see buy or short signals there.

SetChartOptions(0,0,chartGrid30|chartGrid70);
Period = Param("RSI Period",12,6,30,1);
smooth1 = Param("First Smoothing period",40,40,100,1);
smooth2 = Param("Second Smoothing Period",9,2,15,1);
trsi = RSI(Period);
x = MA(trsi, smooth1)-trsi;
y = MA(50 - x, smooth2) ;
z = MA(y,9); //signal
Plot(z,"Signal",colorOrange,styleThick);


QQEDivergance=ParamToggle("Shows QQEDivergance", "No|Yes",1);
if(QQEDivergance)
{
_SECTION_BEGIN("Trendlines_Wedge");
G=0;// set G=1, 2, 3, ... to see previous Resistance trendlines
GG=0;// set G=1, 2, 3, ... to see previous Support trendlines
x = Cum(1);
per = 1;// sensitivity calibration
s1=z;s11=z;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1+GG ));
startt=LastValue(ValueWhen( pS, x, 2+GG ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1+GG ) );
startS = LastValue( ValueWhen( pS, s1, 2+GG ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;// the Support trendline equation
Plot(IIf(x>startt-6 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10),"Support",IIf(as>0,5,4),8);
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1+G ));
startt1=LastValue(ValueWhen( pR, x, 2+G ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1+G ) );
startR = LastValue( ValueWhen( pR, s11, 2 +G ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;// the Resistance trendline equation
Plot(IIf(x>startT1-6 AND TRENDLINER>0 AND TRENDLINER<100,trendlineR,-1e10),"Resistance",IIf(Ar>0,5,4),8);
Ascwedge=Ar>0.5 AND As>sqrt(2)*Ar AND trendlineR>trendlineS;
Descwedge= As<-0.5 AND As>Ar/sqrt(2) AND trendlineR>trendlineS;

SetPositionSize(50,spsShares);

Buy=z>Ref(z,-1);
Sell=z<Ref(z,-1);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Short=Sell;
Cover=Buy;

shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,colorGreen, colorRed),0,IIf(Buy,Low,High));

_SECTION_END();
}
sir if u have or u can make it on macd (not on histograme) divergence then it will more helpfull for us


Abhishek
 

Similar threads