[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 504

 
prom18:
The graph should look like an increasing straight line.

Why do you think so?
 
Vinin:

Why did you decide that?
Well each bar has a volume greater than zero and I need their total, which is recalculated when a new bar appears.
 

to sergeev:

Ah, now I see what you mean. For remembers exactly what value the counter should be compared to, and doesn't change it. That is, if OrdersTotal returned 2, then for will remember this and work with 2.

 
Solree:

to sergeev:

Ah, now I see what you mean. For remembers exactly what value the counter should be compared to, and doesn't change it. So, if OrdersTotal returned 2, then for will remember this and will work with 2.


No. That's not what I'm saying.

The loop stopping condition (in your case, OrdersTotal()) is calculated !at each iteration!

so at first iteration =2
at second iteration =1

Are you a programmer or what? You can't understand elementary things.

 

to sergeev:

You've opened my eyes. I even purposely opened the IDE for C++ to check it out. And it turns out you're doubly right! Thank you! :) But... The order is still not selected, even if you do it this way:

int someA = OrdersTotal();
for (int a = 0; a < someA; a++)
    if (OrderSelect(a, SELECT_BY_POS, MODE_TRADES))
        if (OrderComment() == "Aelit" && OrderType() == OP_SELL)
            OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), 0);
 
prom18:
Well each bar has a volume greater than zero and I need their sum recalculated when a new bar appears.

The total volume can both rise and fall.
 
Vinin:

The total volume can both rise and fall.
I don't understand. Volume is the number of ticks within a bar. The volume of the first one is 30, the second one 20, the third one 10. The sum would be 60. Or is it not?
 
Solree:

to sergeev:

You've opened my eyes. I even purposely opened the IDE for C++ to check it out. And it turns out you're doubly right! Thank you! :) But... The order is still not selected, even if you do it this way:


Always delete orders by counting down

int someA = OrdersTotal();
for (int a = someA-1;a>=0 a--)
    if (OrderSelect(a, SELECT_BY_POS))
        if (OrderComment() == "Aelit" && OrderType() == OP_SELL)
            OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0);
 
Solree:

But... the order is still not selected, even if you make it so:

and it won't!

you do OrderSelect by position number.

in the first iteration, you select the first order, order position a=0

when this order is closed, the number of orders becomes OrdersTotal=1.
This means that the former second order from position 1 becomes position 0.

But at the second iteration of your order, a = 1, not 0! So the OrderSelect on the now non-existing position=1 will return an error.

-------

Now think for a minute before writing your next post. What two options can you suggest to avoid this dynamic.

 
prom18:
I don't get it. Volume is the number of ticks within a bar. The volume of the first is 30, the second 20, the third 10. The sum will be 60. Or is it?


Take a time series with volumes and recalculate with pens

For example there are the following volumes

10, 15, 25, 8, 11, 24, 30

Here are the sums of three

50, 48, 44, 55

There's a rise, there's a fall.

It's just like in life.

Reason: