Entry Issue with Donchian Channel

 

My entry technique: I intend to enter long or short when the current price bar closes above or below a Donchian Channel (50 day market high or low)

......

double DonchianLowerEntry = iCustom(NULL,0,"DonchianChannel2",2400,3,-2,0,100,0,0); // Entry for Lower Donchian Channel - 50 days, 2400

double DonchianUpperEntry = iCustom(NULL,0,"DonchianChannel2",2400,3,-2,0,100,1,0); // Entry for Upper Donchian Channel - 50 days, 2400

double ClosingPrice = iClose(NULL,0,0); //Closing Price of current bar

......

if(ClosingPrice>DonchianUpperEntry) // Closing price is greater than the Donchian upper channel

{

if(trend>0) // Trend is up - MACD indicator filter

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TrailingStop,0,"Alcatraz: Long Order Placed",16384,0,Green); // Open Long order

.....

Expert Advisor is opening a trade when bar penetrates Donchian Channel, but does not close above the Channel. It should be opening trade only when it CLOSES above the channel. Does anyone know why this might be happening?

 

if(ClosingPrice>DonchianUpperEntry)

The ClosingPrice should be for bar 1 and not bar 0 (current tick)

I guess thats what causing the error ...

 
bossxero:
if(ClosingPrice>DonchianUpperEntry)The ClosingPrice should be for bar 1 and not bar 0 (current tick)I guess thats what causing the error ...

Good eyes Boss

FerruFx

 

You're right, Boss. That did the trick! Thanks!

 

hello Bossxero...

I have problem .cant you tell me why trading terminal metatrader disconnect..what is problem it?

Thank u...

 
mamee:
hello Bossxero...I have problem .cant you tell me why trading terminal metatrader disconnect..what is problem it?Thank u...

Check your internet connection or it is a broker server problem.

FerruFx