Comments that do not relate to the "HistoryOrderSelect not working for executed pending order", have been moved into this topic.
- HistoryOrderSelect not working for executed pending order
- Open Buy Code issue.
- Multiple orders issue
Nguyen Nga:
your pending triggered, it become Positions.
then you must use PositionSelectByTicket to check, not use HistoryOrderSelect.
I have a similar issue but slightly different. It occurs occasionally during fast moving market. I notice a open pending order that could't be deleted by EA and the market have passed that price. When i try deleting it manually is say ''invalid '',but when i restart MT4 it appears to be an open position. Can any help me or i'm experiencing the same issue ?
This code creates new pending Orders
if( rateChange > VelocityTrigger * Point && avgSpread <= maxSpread && totalBuyStop < TradeDeviation ) {
if( AccountFreeMarginCheck( Symbol(), OP_BUY, lotSize() ) <= 0 || GetLastError() == 134 ) {
Print( "Notice: Not enough free margin to open trade. Expert is removed." );
ExpertRemove();
return ( 0 );
}
ticket = OrderSend( Symbol(), OP_BUYSTOP, lotSize(), Ask + ( totalBuyStop + 1.0 ) * ( Point * TradeDelta ), Slippage, 0, 0, TradeComment, MagicNumber, 0 );
}
if( rateChange < - VelocityTrigger * Point && avgSpread <= maxSpread && totalSellStop < TradeDeviation ) {
if( AccountFreeMarginCheck( Symbol(), OP_SELL, lotSize() ) <= 0 || GetLastError() == 134 ) {
Print( "Notice: Not enough free margin to open trade. Expert is removed." );
ExpertRemove();
return ( 0 );
}
ticket = OrderSend(Symbol(), OP_SELLSTOP, lotSize(), Bid - ( totalSellStop + 1.0 ) * ( Point * TradeDelta ), Slippage, 0, 0, TradeComment, MagicNumber, 0 );
}
This code check for order status
case OP_BUYSTOP:
if( avgSpread > maxSpread || MathAbs( rateChange ) < VelocityTrigger * Point )
r = OrderDelete( OrderTicket() );
totalBuyStop++;
break;
case OP_SELLSTOP:
if( avgSpread > maxSpread || MathAbs( rateChange ) < VelocityTrigger * Point )
r = OrderDelete( OrderTicket() );
totalSellStop++;
break;
Please don't hijack old (and not related) topic. Thanks.
Chike Assuzu: When i try deleting it manually is say ''invalid '',but when i restart MT4 it appears to be an open position.
- When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum ticket = OrderSend( Symbol(), OP_BUYSTOP, lotSize(), Ask + ( totalBuyStop + 1.0 ) * ( Point * TradeDelta ), Slippage, 0, 0, TradeComment, MagicNumber, 0 );
Check your return codes for errors and report them.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles- Pending order, once open, becomes buy/sell. You can't delete opened orders, they must be closed. The code you state "check for order status" is without context. We have no idea wether or how you selected the order before using OrderTicket.
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