Looking for "RSI Divergence AFL" without lag/forward looking/repainting

suri112000

Well-Known Member
#1
I expect some of the AFL experts to have this AFL.

RSI Divergence AFL without any lag, should not look forward and should not repaint.

I have the following code.......which I think repaints or adjusts to future bars.

GraphXSpace=7;
//n=Param("% Reverse ",12,0,100,1);
n=Optimize("ZIG",9,5,50,1);
per=Optimize("rsi",28,5,50,1);
Buy=Sell=0;
Var = Zig(RSI(per), n);
t= Trough(RSI(per), n, 1);
p= Peak(RSI(per), n, 1);
x[0] =Var[0];
price[0] = C[0];
j=0;

// bearish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == p)
{

j++;
x[j] =Var;
price[j] =C;
if(x[j] <x[j-1] && price[j-1]< price[j])
Sell =1;
}
}

// bullish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == t)
{
j++;
x[j] =Var;
price[j] =C;
if(x[j] >x[j-1] && price[j]<price[j-1])
Buy =1;
}
}
Short=Sell;
Cover=Buy;

Plot(Var, "", 39);
PlotShapes ( IIf(Sell, shapeSmallCircle, shapeNone), colorRed, 0 , Var,0);
PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone), colorBrightGreen, 0, Var,0);

Title ="RSI Divergence" ;
_SECTION_END();

_SECTION_BEGIN("TEMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( TEMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
 
#2
_SECTION_BEGIN("rsi divergance");
GraphXSpace=7;
n=Param("% Reverse ",20,0,100,1);

Buy=Sell=0;
Var = Zig(RSI(), n);
t= Trough(RSI(), n, 1);
p= Peak(RSI(), n, 1);
x[0] =Var[0];
price[0] = C[0];
j=0;

// bearish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == p)
{

j++;
x[j] =Var;
price[j] =C;
if(x[j] <x[j-1] && price[j-1]< price[j])
Sell =1;
}
}

// bullish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == t)
{
j++;
x[j] =Var;
price[j] =C;
if(x[j] >x[j-1] && price[j]<price[j-1])
Buy =1;
}
}

Plot(Var, "",colorYellow,styleLine|styleThick);
PlotShapes ( IIf(Sell, shapeHollowStar, shapeNone), colorRed, 0 , Var,15);
PlotShapes( IIf(Buy, shapeHollowStar, shapeNone), colorBrightGreen, 0, Var,-15);


Title ="RSI Divergence" ;
_SECTION_END();
 
#4
/// PROGRAMME CREATED BY PRASAD RAO FOR MASTER PLOTTER MACD DIVERGENGE DETECTOR///
_SECTION_BEGIN(“BACK COLR”);
_SECTION_BEGIN(“PRASAD SYSTEMS”);
ParamStr(“DEDICATED TO MY FATHER”, “BALKRISHNA RAO”);
_SECTION_END();
SetChartBkColor( ParamColor(“Chart Color”, colorBlack));
_SECTION_BEGIN(“BACKGROUD LTRS”);
SetChartOptions(0,chartShowArrows|chartShowDates);
GfxSetOverlayMode(1);
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor(“Text Color”, ColorHSB( 42, 42, 42 ) ));
GfxSetBkMode(0); // transparent
GfxSelectFont(“Tahoma”, Status(“pxheight”)/12);
GfxTextOut( “PRASAD ANALYTICS ©”, Status(“pxwidth”)/2, Status(“pxheight”)/14);
GfxSelectFont(“Tahoma”, Status(“pxheight”)/9 );
GfxTextOut( Name(), Status(“pxwidth”)/2, Status(“pxheight”)/4.1 );
GfxSelectFont(“Arial Narrow”, Status(“pxheight”)/28 );
GfxTextOut( “[email protected]”, Status(“pxwidth”)/2, Status(“pxheight”)/1.5);
GfxSelectFont(“arial narrow”, Status(“pxheight”)/27 );
GfxTextOut( “Dedicated to MY FATHER : BALKRISHNA RAO”, Status(“pxwidth”)/2, Status(“pxheight”)/1.15);
_SECTION_END();
k = (GetPerformanceCounter()/100)%256;
printf(“GetPerformance Counter %g”,k);
GfxSelectFont(“Arial Narrow”, 10,700 );
GfxSetBkMode(1);
GfxSetTextColor(colorYellow);
//GfxTextOut(“Dedicated to the loving memory of MY FATHER on his 75th Birth Anniversay – LATE BALKRISHNA RAMCHANDRA RAO 13.10.1935″,100+k ,26);
RequestTimedRefresh(1);
_SECTION_END();
_SECTION_BEGIN(” MACD”);
MACDw = MACD( 12, 26 ) – Signal( 12, 26, 9 );
MACDwLINE = MACD( 12, 26 ) ;
MACDwSignal = Signal( 12, 26, 9 );
Plot(MACDw,”MACD Weekly”,colorLavender,styleHistogram);
_SECTION_END();
WeekHistRising = Ref(MACDw , -1) < Ref(MACDw , 0);
WeekHistFalling = Ref(MACDw , -1) > Ref(MACDw , 0);
Lastbarindex = Param(“last”,EndValue(BarIndex()),1,EndValue(BarIndex()),1);
Line02=MACDw[Lastbarindex];
Thisbarindex = SelectedValue(BarIndex());
Line01 = SelectedValue(MACDw);
//Line02 = SelectedValue(MACDw);
//GfxTextOut(“lINE01″+Line01,10,10);
//GfxTextOut(“lINE02″+Line02,200,10);
PriceLine1= LineArray(Thisbarindex,Line01 ,Lastbarindex,Line02,0,1);
Plot(PriceLine1,”", colorYellow,styleLine|styleDots);
GfxSetTextAlign( TA_left = 0);
GfxSelectFont(“Tahoma”, 11, 700 );
GfxSetTextColor(ColorRGB(209,191,255));
GfxTextOut(“PRASAD ANALYTICS – MACD DIVERGENCE DETECTOR”,07, 0);
GfxSetTextAlign( TA_LEFT = 0 );
GfxSelectFont(“Tahoma”, 11, 700 );
GfxSetTextColor(ColorRGB(255,180,61));
GfxTextOut(Name()+ ” ” + Date(),07,25);
Title = ” “;

AFL by Prasadbrao.
 

suri112000

Well-Known Member
#5
_SECTION_BEGIN("rsi divergance");
GraphXSpace=7;
n=Param("% Reverse ",20,0,100,1);

Buy=Sell=0;
Var = Zig(RSI(), n);
t= Trough(RSI(), n, 1);
p= Peak(RSI(), n, 1);
x[0] =Var[0];
price[0] = C[0];
j=0;

// bearish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == p)
{

j++;
x[j] =Var;
price[j] =C;
if(x[j] <x[j-1] && price[j-1]< price[j])
Sell =1;
}
}

// bullish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == t)
{
j++;
x[j] =Var;
price[j] =C;
if(x[j] >x[j-1] && price[j]<price[j-1])
Buy =1;
}
}

Plot(Var, "",colorYellow,styleLine|styleThick);
PlotShapes ( IIf(Sell, shapeHollowStar, shapeNone), colorRed, 0 , Var,15);
PlotShapes( IIf(Buy, shapeHollowStar, shapeNone), colorBrightGreen, 0, Var,-15);


Title ="RSI Divergence" ;
_SECTION_END();


This indicator is pointing to divergence very late. I am looking for indicator which is not late or looking forward while forming.
 
#6
GraphXSpace=7;
n=Param("% Reverse ",20,0,100,1);

Buy=Sell=0;
Var = Zig(RSI(), n);
t= Trough(RSI(), n, 1);
p= Peak(RSI(), n, 1);
x[0] =Var[0];
price[0] = C[0];
j=0;

// bearish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == p)
{

j++;
x[j] =Var;
price[j] =C;
if(x[j] <x[j-1] && price[j-1]< price[j])
Sell =1;
}
}

// bullish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == t)
{
j++;
x[j] =Var;
price[j] =C;
if(x[j] >x[j-1] && price[j]<price[j-1])
Buy =1;
}
}

Plot(Var, "", 39);
PlotShapes ( IIf(Sell, shapeSmallCircle, shapeNone), colorRed, 0 , Var,0);
PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone), colorBrightGreen, 0, Var,0);
/////////////////////////////////////////////////
AlertIf( Buy, "SOUND C:\\Windows\\Media\\chimes.wav", "Audio alert", 1, 1+8 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\ding.wav", "Audio alert", 2, 1+8 );





Title ="RSI Divergence" ;
_SECTION_END();
 

suri112000

Well-Known Member
#8
Previous ZEEL was a winner.


ZEE 350 CE march series LTP was 5.70 on the date of spotting divergence. It zoomed to 22 in just 8 trading days.
Lot size 1000. Invested capital Rs.5,700. Return : Rs.16,300. 300% appreciation.

Now, eyeing another scrip.



Eying 260 CE April series -------- LTP 5.30
Lot size 1000. Invested capital Rs.5,300. Lets wait and see.
 
Last edited:

suri112000

Well-Known Member
#9
Update on BHEL

Today's downfall in the scrip has negated Positive Divergence in RSI Indicator.
But, the Stochastics is still holding it. Lets wait and see one more day to decide the trade. I entered at Rs. 4.05 today and todays LTP was Rs.3.20. If the stochastics also negates Divergence on EOD basis, I will exit the trade and move on to other trades.

 

suri112000

Well-Known Member
#10
Update of BHEL

Stochs is holding on the divergence continuously for 2nd day. Let us hold the trade for 5-6 trading sessions.

Watching Adani Ports

Lot size : 1000 320 CE april series LTP 9.85. Capital required : 9,800.

 

Similar threads