- Your code (that we can not see) is broken. Fix your broken code.
- You must count down when closing/deleting in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
thanks for your answer
my code checks if i have any open Order
then when i have for example a buy position, it checks for pending orders and closes them:
for(counter=0;counter<OrdersTotal();counter++)
{OrderSelect(counter, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == magicNumber)
{
if (OrderType() == OP_BUY)
{
for(counter1=0;counter1<OrdersTotal();counter1++)
{
OrderSelect(counter1, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == magicNumber)
{
if (OrderType() == OP_SELLSTOP)
{
bet=OrderDelete(OrderTicket());
if(bet==true)
{
Print("delete performed correctly");
}
if(bet==false)
{
Print("delete didnt operate well be cause of ", GetLastError());
}
}
}
}
}
}
}
in demo and back test it works and prints "delete performed correctly"
but in real it does not print anything and it does not delete anything
my question is how is it possible that a code works properly in demo and back test, while it does not get i to the delete section
if there is any problem it should be considered in demo and back test too
dont you think so?
does order select recognize pending orders?
if yes how can i recognize and delete them?
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- What part of "You must count down when closing/deleting in a position loop" was unclear?
- Check your return codes (OrderSelect) 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
jiomanjy:
does order select recognize pending orders? if yes how can i recognize and delete them? |
|
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi every one
i have an EA which works completely OK when i run in in demo environment
it is the same when i run back testing. it works great with back test
but in real it does not delete pending orders when it should
have you encountered such problem so far?