"TimeOut + Breakeven Code" Help Needed

 

Hi,

I want to modify my TakeProfit order 12 Hour after to OrderOpenPrice(Breakeven point) if there is no profit.Below code doesn't work.Please help...

int timeout=12; // hours

if (OrderProfit() < 0 )
{
OrderSelect(i, SELECT_BY_POS);
if ( (TimeCurrent()-OrderOpenTime())>=(60*60*timeout) && OrderType() == OP_SELL)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid+StopLoss*Point,(OrderOpenPrice() ),0,0 );
if ((TimeCurrent()-OrderOpenTime())>=(60*60*timeout) && OrderProfit() <= 10 && OrderType() == OP_BUY)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-StopLoss*Point,(OrderOpenPrice() ),0,0 );
return;
}

}
}

 

i used ibarshift on the orderopentime to get the bars passed

u can try it


somehow lost the code

 
ataba:

I want to modify my TakeProfit order 12 Hour after to OrderOpenPrice(Breakeven point) if there is no profit.Below code doesn't work.Please help...

For starters, you're calling OrderProfit() before OrderSelect(). You're asking to check the profitability without having specified which order you are interested in. OrderProfit() is almost certainly returning zero, and therefore the rest of the code isn't getting called at all.

 
jjc:

For starters, you're calling OrderProfit() before OrderSelect(). You're asking to check the profitability without having specified which order you are interested in. OrderProfit() is almost certainly returning zero, and therefore the rest of the code isn't getting called at all.

Thanks for replies.I changed the code as you said.( I took OrderProfit after OrderSelect)But still nothing changed.My code does not change takeprofit order.Shouldn't I use OrderOpenPrice for my new takeprofit level ??? Any idea?