[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 52

 
first_may:
Is there an example function for working with dates, i.e. to determine the difference between two dates, is it greater than zero or not?

and what is a date in your understanding and in the understanding of MQL ?
 

People, help me understand the code. The main task is to delete a pending order when a certain level is reached.

if (OrdersTotal()!=0 && Bid == Delete_Level)
   {
   for (int i=1; i<=OrdersTotal(); i++) //Cycle for all orders..
      { 
         if(OrderSelect(i-1,SELECT_BY_POS)==true)//If there is the next one
            { 
               if(OrderType()>1) 
                  {
                  if(OrderDelete(OrderTicket())==true)
                  {
                  Alert ("Ордера удалены");
                  }
                  }
            } 
      }
   }

The Delete_Level is determined by the position of MA 30 on 3 bars up to the current moment.

double MA3 = iMA(NULL, 0, MA_Period_2, 0, MODE_SMA, PRICE_CLOSE, 2); //определение уровня MA

double Delete_Level = MA3;// Определение значения переменной

But the order is not deleted at this Delete_Level. Help me to understand what is my error.

 
where does the algorithm reach ? Print the code and check it.
 
What do you mean by "where does the algorithm go?"
 
vovan-gogan:
What do you mean by "where does the algorithm go?"

You say it's not deleted, which means it doesn't go to OrderDelete.

So the question is, where does it go? What condition is blocking it?

 
sergeev:

You say that it is not deleted, which means that it does not reach OrderDelete.

The question is where does it reach? What condition blocks it?


I understand the logic. I will try to fix it now.
 

Something has cleared up. But I still can't figure out how to solve it. Using Alert, I find that the condition

if (OrdersTotal()!=0 && Bid == Delete_Level)

is not satisfied. Just "if(OrdersTotal()!=0" separately yes, but not together with "Bid == Delete_Level". What is the reason for this? Why when the Delete_Level is reached, the pending order is not deleted. Please suggest something or suggest an alternative solution to delete a pending order when it reaches the Delete_Level.

 
vovan-gogan:

Something has cleared up. But I still can't figure out how to solve it. Using Alert, I find that the condition

is not satisfied. Just "if(OrdersTotal()!=0" separately yes, but not together with "Bid == Delete_Level". What is the reason for this? Why when the Delete_Level is reached, the pending order is not deleted. Please suggest something or suggest an alternative solution to delete a pending order when it reaches the Delete_Level.


Normalise these variables, "reduce them to a common denominator" - for example, use some tolerance (+/-) of Delete_Level variable value, because there is no exact equality as you have it now - Bid == Delete_Level.
 
vovan-gogan:

Something has cleared up. But I still can't figure out how to solve it. Using Alert, I find that the condition

is not satisfied. Just "if(OrdersTotal()!=0" separately yes, but not together with "Bid == Delete_Level". What is the reason for this? Why when the Delete_Level is reached, the pending order is not deleted. Please suggest something or suggest an alternative solution to delete a pending order when it reaches the Delete_Level.


For example,
if(Bid-MarketInfo(Symbol(),MODE_SPREAD)*Point< Delete_Level && Bid+MarketInfo(Symbol(),MODE_SPREAD)*Point > Delete_Level) - считать за 
if( Bid == Delete_Level )  
 

Sorry, but could you take it easy?) Help me understand the error in

Bid == Delete_Level