problem with real trading

 

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?

 
jiomanjy: but in real it does not delete pending orders when it should
  1. Your code (that we can not see) is broken. Fix your broken code.
  2. 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?

 
jiomanjy: 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:
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. What part of "You must count down when closing/deleting in a position loop" was unclear?
  3. 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?

  1. Yes
  2. Look at the code of the post you replied to.