Making These RSI divergence AFLs Non-Future Looking

#1
I would like to request the members to share any RSI/MACD Divergence plotting AFLs that do not reference future quotes, so that they may be relied to in trading!
Or maybe help me, by making these future referencing AFLs, non-future looking.

// RSI Divergence - Plot and Explore

_SECTION_BEGIN("RSI divergence");

P = Param("Period RSI", 14, 9, 14, 1);
VRSI = RSI(P);

Length = 100;
Lapse = 3;

fUp = VRSI > Ref(VRSI, -1) & VRSI > Ref(VRSI, 1) & VRSI >55;
fDown = VRSI < Ref(VRSI, -1) & VRSI < Ref(VRSI, 1) & VRSI < 45;

Div = 0;

for(i = Length; i < BarCount; i++)
{

// Down
if(fUp)
{
k = i-1;
do
{
if(VRSI[k] > VRSI & fUp & fUp[k])
{
if(C[k] < C & i-k > Lapse)
{
Div = 1;
}
k = i-Length;
}
else
k = k-1;
} while( k > i-Length );
}

////////////////////////////

// Up

if(fDown)
{
k = i-1;
do
{
if(VRSI[k] < VRSI & fDown & fDown[k])
{
if(C[k] > C & i-k > Lapse)
{
Div = -1;
}
k = i-Length;
}
else
k = k-1;
} while( k > i-Length );
}

}



Fon = IIf(Div == 0, 0, 1);

Col = IIf(Div == 1, 4, IIf(Div == -1, 5, 1));

Color = IIf(Div == 1, 32, IIf(Div == -1, 27, 1));

Color = IIf(fUp == 1, 32, IIf(fDown == 1, 27, 1));

Div = IIf(Div == 0, Null, abs(Div));
Fon = abs(Div);


// Title = EncodeColor(4)+"RSI(" + WriteVal(P, 2.0) + ")" + EncodeColor(1) + " ="+WriteVal(RSI(P));
// Plot( RSI(P), "RSI", Col, 5);
// Plot( 25,"", 4, 16+4096);
// Plot( 75,"", 4, 16+4096);
Plot(Fon, "", Color, 16384+32768+4096 | styleOwnScale, MinValue = 0, MaxValue = 1);
_SECTION_END();

Filter=Fon==1;
AddColumn
(C,"Close",1.2,Color);



/*---------------------------------------------------
RSI Divergence
Aron Pipa, March, 20 , 2006
--------------------------------------------------------*/

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);

Title ="RSI Divergence" ;



Thanks & Regards
 

Similar threads