How to trade divergence ? and where to put stops?

#22
Dear Zunayed,

The Buy/ sell condition for RSI divergence afl which you have given are not working.
If its working with you, please post the entire code.

Thank you, MoHaN.
Dear Mohan, Here you go.....

//***************************************************

_SECTION_BEGIN("RSI divergence");

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

Length = 100;
Lapse = 3;

fUp = VRSI > Ref(VRSI, -1) & VRSI > Ref(VRSI, 1) & VRSI >70;
fDown = VRSI < Ref(VRSI, -1) & VRSI < Ref(VRSI, 1) & VRSI < 30;

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 = "ZUNAYED "+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);

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

//**************************************************
 

mohan.sic

Well-Known Member
#23
Dear Zunayed,

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
#24
Dear Zunayed,

One more thing is this code is not giving any signals on last days data. That is Current days data. what could be the reason. If there are no signals on latest data how to use this code for Next day trading.

Regards, MoHan.
 
#25
The code is designed in such a way that it looks into the future data to generate signal. This is not actually for instant buy signal. Therefore, you will not get the buy signal on the same day and rather one day later.
 

mohan.sic

Well-Known Member
#26
Dear Zunayed,

Thank you very much for the clarification. Is it possible to edit the code so that it gives signals on latest day's data.

regards,mohaN.
 
#27
hi
when i started this thread i wanted to know how to place stops and hot to trade it, till this point i dont have the satisfaction by this answers.

i request the moderators to delit the thread
regards
ali
 

AW10

Well-Known Member
#28
Ali, have u read the pdf of "teach a man to fish...".. It does talk about the pivot points where mkt confirms to use the change of trend or continuation of trend.

There is no single answer to place stops. Basic rule that u can use is
- as soon as the reason that gave u signal to take the trade are not valid, it is time to close that trade.
Say if you enter as soon as price > 20 dma .. fine.
The moment price comes below 20 dma, this reason is no more valid..so get out of the trade.

You can also adopt different approach based on the pivot points as per the pdf I have mentioned above.

If you want to keep it simple and away form all mumbo jumbo of charts..then place stop at a level based on your risk limit. Say if you decide to risk 1000 rs. on a trade. and u are trading nifty futures, then keep stop 20 pts below the cmp. you might decide to update your stop at close of 5 min bar / or 15 min bar or anything similar to it.

whatever approach u decide.. plz test it on prev charts.. for entry/stop etc and make sure that it makes money for you on prev data.. If it is loosing money on past data then what makes you belive that it will work in future ..

Hope this gives u some ideas to relook at your trading. I have also replied to your post on money mgmt rules in other thread..

If you place these basic rules in place.. and consistently follow them.. you will see the change in your results..
Consistency is the key in trading.. and we as human can't be consitent until we have clear cut defined rules/steps.

Happy Trading
 

tvrssvk

Active Member
#29
whatever approach u decide.. plz test it on prev charts.. for entry/stop etc and make sure that it makes money for you on prev data.. If it is loosing money on past data then what makes you belive that it will work in future ..

Consistency is the key in trading.. and we as human can't be consitent until we have clear cut defined rules/steps.



Hi AW10


Nice one....
 

rkpo

New Member
#30
Hi

A very valid question indeed. I recommend you to read a wonderful book on DIVERGENCES - Bullish & Bearish .It will explain in detail in simple manner all you want to know
 

Similar threads