Please add Buy/Sell variables to this RSI divergence code.

mohan.sic

Well-Known Member
#11
Very nice that its working. Please post the entire code with the additions ( buy/sell conditions) u made to it. I mean the one which u used to scan the above results.

Thanks, MoHaN.
 

mohan.sic

Well-Known Member
#15
:cool: haha..nice quote at the end.
Sage, anyways i/o all these, can u put down the afl entirely. May be i dont know even where to make the changes. pls let us not drag it anymore.

Thanks.
 
#16
:cool: haha..nice quote at the end.
Sage, anyways i/o all these, can u put down the afl entirely. May be i dont know even where to make the changes. pls let us not drag it anymore.

Thanks.
Here you go,

// RSI divergence
// Backgraund color White


P = Param("Priod 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, 48, IIf(Div == -1, 14, 1));

Color = IIf(fUp == 1, 48, IIf(fDown == 1, 14, 1));

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

Buy = Col > 4.50 AND fon == 1 AND Ref(RSI(14),-1) < 35;
Sell = Col < 4.50 AND Fon == 1 AND Ref(RSI(14),-1) > 65;

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, MinValue = 0, MaxValue = 1);
 

mohan.sic

Well-Known Member
#17
Dear Sage,

Thank you very much and very sorry for the late reply.
Yes its good and working but with little differences.

When the code is scanned, its not picking up all the signals. Like if the code is showing 10 Buy signals when displayed as indicator, its giving only 3 or 4 signals when scanned. Other Buy signals are missing. Please look after.

Thanks.
 

mohan.sic

Well-Known Member
#19
Dear Sage,

Yes this is not giving signals on current day. If No signals on current day data how to use it for Next day? Why is this RSI divergence code not working on current day data.


Regards, MoHan.
 

Similar threads