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

 

There is an ArrayTemp[100] in which all elements are of type integer and sorted in ascending order from 1 to 100.

I need to remove first 1-50 elements and reduce array size to [50].

Thought to do it by copying 2nd half of array to temporary, resizing original and then copying back, from temporary to original.

- Is there a simpler way?

Thanks!

 
chief2000:

There is an ArrayTemp[100] in which all elements are of type integer and sorted in ascending order from 1 to 100.

I need to remove first 1-50 elements and reduce array size to [50].

Thought to do it by copying 2nd half of array to temporary, resizing original and then copying back, from temporary to original.

- Is there a simpler way?

Thanks!



You could sort in descending order and then just resize the array. I think that would be faster. Who knows though ?)
 
Figar0:

You could sort in descending order and then just resize the array. I think that would be faster. Who knows though ?)

Thank you!

 
Vinin:

Good first steps, Olga Alexandrovna. 330 lines of code


Good day! I don't know whether to accept it as a praise or vice versa, but in any case, thanks for the answer.

I cannot find the solution, unfortunately, that is why I consider it so - the main thing is quality and literacy, and with it, as I understand, I have a gap, because the code does not go.

Very much waiting for an answer to my question.....

 

Good people help who can

Here is the code in which the warrant should be removed after the expiration of time, this is the condition

MyCurrentTime >= OrderExpiriation && OrderMagicNumber() == MagicNumber

Why is it that if I insert this condition into the first if operator, then the other operator which is inside it doesn't take this condition into account?

That is, this code doesn't work and deletes all pending orders at once.

  for(int counter=0;counter<OrdersTotal();counter++)
    {
    if(OrderSelect(counter,SELECT_BY_POS,MODE_TRADES) == false) break;

    if(MyCurrentTime >= OrderExpiriation && OrderMagicNumber() == MagicNumber) //Если текущее время больше чем время истечения
      {
        
        
      if(OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)
        {
        OrderDelete(OrderTicket());
        }
        
      }
    }

And this code works and does not delete orders at once.

  for(int counter=0;counter<OrdersTotal();counter++)
    {
    if(OrderSelect(counter,SELECT_BY_POS,MODE_TRADES) == false) break;

    if(MyCurrentTime >= OrderExpiriation && OrderMagicNumber() == MagicNumber) //Если текущее время больше чем время истечения
      {
        
        
      if(OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP && MyCurrentTime >= OrderExpiriation && OrderMagicNumber() == MagicNumber)
        {
        OrderDelete(OrderTicket());
        }
        
      }
    }
 

Can you tell me what breakpoints are used for? I've searched the forum but can't find any information. How do I use it?

 
chief2000:

There is an ArrayTemp[100] in which all elements are of type integer and sorted in ascending order from 1 to 100.

I need to remove first 1-50 elements and reduce array size to [50].

Thought to do it by copying 2nd half of array to temporary, resizing original and then copying back, from temporary to original.

You could do nothing and consider the 50th element as the starting element. ArrayCopy will take some time anyway.
 
sss2019:

Good people help who can

Here is the code in which the warrant should be removed after the expiration of time, this is the condition

Why is it that if I insert this condition into the first if operator, then the other operator which is inside it doesn't take this condition into account?

That is, this code doesn't work and deletes all pending orders at once.

And this code works and does not delete orders at once.

It is generally a good idea to look through the orders starting from the last one. In the second case, do not be afraid to add parentheses in the condition.

 
fore-x:

Can you tell me what breakpoints are used for? I've searched the forum but can't find any information. How do I use it?

It doesn't work. Made it thinking it would be a proper debugger, but it doesn't.
 
splxgf:
You can do nothing and consider the 50th element as the initial one. ArrayCopy will take some time in any case.

The point is that the array must periodically include more elements (expand), which affects the speed of optimization/testing. Therefore, at "favourable" moments I return it back to initial state.

Figar0' s solution : turned out to be simpler than mine and works fine.

Thank you!

Reason: