Hey! Don't double post!! Please delete them all except one - its enough!
And use the SRC button for any kind of code!
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- Don't double post Don't triple post Don't quad post If you continue you will be ignored!
if(CheckOrderOpenBuy1M () == false)
Does that do an OrderSelect, thus invalidating your loop?OrderDelete(OrderTicket(),clrNONE);
Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles- See also deleting all pending if found one working order - MQL4 forum
You have wasted my time as I have had to delete your other 10 posts.
You have wasted other people's time by bringing 10 old posts to the top of the list.
If you do it again, you will be banned for flooding.
if(OrderSelect(b,SELECT_BY_TICKET,MODE_TRADES))
In a loop like this you do not select by ticket, select by position
First, I apologize for the multiple post, and thank you for the help. I did make some adjustments to the coding based on everyone's suggestions, but I am still having some more issues. the function is deleting the pending orders when a new position is opened. I only want the pending orders to delete when the open position that the pending order is attached to closes. here is the 2 functions that deal with these operations. can anyone tell me what I am doing wrong. thank you
bool CheckOrderOpenBuy1M () { for(int b= OrdersTotal()-1; b >= 0; b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber() == MagicNumber1M) if(OrderSymbol() == Symbol()) if(OrderType()==OP_BUY) return(true); else return(false); } return(0); } void CloseBuyStack1stLevelLimitOrder1M() { if(CheckOrderOpenBuy1M () == false) for(int b= OrdersTotal()-1; b >= 0; b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber() == Stack1stLevelMagicNumber1M) if(OrderSymbol() == Symbol()) if(OrderType()==OP_BUYLIMIT) OrderDelete(OrderTicket(),clrNONE); } }
jtubbs13791:
First, I apologize for the multiple post, and thank you for the help. I did make some adjustments to the coding based on everyone's suggestions, but I am still having some more issues. the function is deleting the pending orders when a new position is opened. I only want the pending orders to delete when the open position that the pending order is attached to closes. here is the 2 functions that deal with these operations. can anyone tell me what I am doing wrong. thank you
First, I apologize for the multiple post, and thank you for the help. I did make some adjustments to the coding based on everyone's suggestions, but I am still having some more issues. the function is deleting the pending orders when a new position is opened. I only want the pending orders to delete when the open position that the pending order is attached to closes. here is the 2 functions that deal with these operations. can anyone tell me what I am doing wrong. thank you
I have no idea what the highlighted text means
bool CheckOrderOpenBuy1M () { for(int b= OrdersTotal()-1; b >= 0; b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber() == MagicNumber1M) if(OrderSymbol() == Symbol()) if(OrderType()==OP_BUY) return(true); else return(false); } return(0); }
This only checks 1 order, remove the else
bool CheckOrderOpenBuy1M () { for(int b= OrdersTotal()-1; b >= 0; b--) { if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber() == MagicNumber1M) if(OrderSymbol() == Symbol()) if(OrderType()==OP_BUY) return(true); } return(false); }
WHRoeder:
What happens if you have a buy order but it is not in the highest position?
If there were not been pending orders(opened) than it is ok.
What happens if you have a buy order but it is not in the highest position?
:))))))))))))))))))))))))))))))
WHRoeder:
What happens if you have a buy order but it is not in the highest position?
What happens if you have a buy order but it is not in the highest position?
eevviill:
If there were not been pending orders(opened) than it is ok.
If there were not been pending orders(opened) than it is ok.
How can it be ok?
The loop only checks the first order, so there may be a buy order, but if it is not in the highest position, it will not be detected.
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
can someone help me please? I can get this function to delete a pending order. What am i doing wrong? the way I would like it to work is when a open order is closed. this function will then delete the pending order. I keep getting the error 4108 for invalid ticket. I really have issue if another order is opened. then the function tries to delete the open order. Need help.
Thank you