closing an order based on my price in if condition

 

i want to close an order in EA with if condition

eg

present=Bid;

BP=OrderOpenPrice();

SL=BP-TrailingStop*Point; // Order stop
Alert("stoploss==",SL);
if (NormalizeDouble(SL,Digits)== // If it is equal than we want
NormalizeDouble(present,Digits))
{
bool Ans=OrderClose(OrderTicket(),OrderLots(),Bid,2);// Order closing

}

its not working can any one help me in this

 

What exactly are you trying to do?

What is your closing condition in simple words?

Do you use it to close both long and short positions?

Closing a short position by trying to use the "Bid" price will not work.

 
TuTBaluT wrote >>

What exactly are you trying to do?

What is your closing condition in simple words?

Do you use it to close both long and short positions?

Closing a short position by trying to use the "Bid" price will not work.

i want to close the open buy position

i ll give my price if that price equals to the current bid price i want to close that position

if (myprice==bid)

closeorder

 

I had a similar problem once, I don't know if it is the same.

You might want to try using "<=" instead of "==".

There might be gaps.

Also, why do you use the "NormalizeDouble" on the "present"?

Reason: