Use OrderTicket() instead of nTicket
hth
Russell
--edit--
a sell should be closed by Ask in general
void manageOpenTrade(int iMagicNumber, double dSL, double dTP, int iSlippage){ int liOT = OrdersTotal(); RefreshRates(); for(int i = liOT; i >= 0; i--){ if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==TRUE) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == iMagicNumber){ if (OrderType() == OP_SELL){ if(Ask >= (OrderOpenPrice()+ (dSL * Point)) || Ask <= (OrderOpenPrice()-(dTP*Point))){ OrderClose(OrderTicket(),OrderLots(),Ask,iSlippage,Red); } } if (OrderType() == OP_BUY){ if(Bid <= (OrderOpenPrice()-dSL*Point) || Bid >= (OrderOpenPrice()+dTP*Point) ){ OrderClose(OrderTicket(),OrderLots(),Bid,iSlippage,Green); } } } } } }
Just to say that if an order is already in history, then it's history. It means that it is already closed/deleted.
lol that caught me of guard :)
abstract_mind:
Just to say that if an order is already in history, then it's history. It means that it is already closed/deleted.
Just to say that if an order is already in history, then it's history. It means that it is already closed/deleted.
MMM.. could be hey. Thanks. Did not see that.
Russell:
lol that caught me of guard :)
lol that caught me of guard :)
Thanks for the info. Appriciate it. :)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey there.
I'm bit stuck en closing orders.
I get en error "unknown ticket", but I've tried a lot of ways and got a lot of different errors.
Can someone help?
Thanks a lot. :)
OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY);
if ((updown==1)&&(OrderType()==OP_SELL))
OrderClose(nTicket,LOT,Bid,Red);
if ((updown==0)&&(OrderType()==OP_BUY))
OrderClose(nTicket,LOT,Bid,Red);