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

 

to artmedia70:

Well, the order is already closed when it comes to this condition.

 

to demlin:

Well I can see it disappearing from Trading.

 
demlin:

Hi all!

The indicator draws a line, which the next day breaks away from the bars and hangs to the side. When I restart the indicator it draws normally again. What can it be?


The indicator is crooked. We have to redo it.
 
Vinin:

The indicator is crooked. We have to redo it.
I understand that, but what could be the problem?
 
Solree:

to demlin:

Well I can see it disappearing from Trading.

How about organizing a search of orders from the history? When you find the right order you count the closing time
 

to delmin:

In order not to do such a thing, I use a ticket. Actually, we may rewrite the logic (at least, we may write the returned OrderClose() value in bool and then check it). I am just curious, why it doesn't return the right value for a closed order and I don't want to overload the program with unnecessary actions. I hope on your help :)

 
Solree:

to delmin:

In order not to do such a thing, I use a ticket. Actually, we may rewrite the logic (at least, we may write the returned OrderClose() value in bool and then check it). I am just curious, why it doesn't return the right value for a closed order and I don't want to overload the program with unnecessary actions. I hope on your help :)

I have already answered your question: you have to check the close time of an order by ticket right after its selection. Only for closed orders it is higher than zero. But in your case, the check of closing time goes after the block of closing other orders, and you, respectively, check the closing time of other orders. In general, you get such comprehensive answers to how much code you have shown.
 
demlin:
I understand that, but what could be the problem?

You need to look at the code, otherwise only telepaths can help
 
    if (tempWho == 0 && pos != -1)
    {
        if (OrderSelect(pos, SELECT_BY_TICKET))
        {
            if (OrderType() == OP_BUY)
            {
                if (who != 1)
                {
                    while(!OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), 0))
                        Sleep(3000);
                    
                    pos = -1;
                }
            }
            else if (OrderType() == OP_SELL)
            {
                if (who != 2)
                {
                    while(!OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), 0))
                        Sleep(3000);
                    
                    pos = -1;
                }
            }
            
            Alert(OrderCloseTime());
            
            if (OrderCloseTime() != 0)
            {
                if (OrderProfit() < 0)
                {
                    if (tempCount != 0)
                    {
                        tempLot += lot;
                        tempCount--;
                    }
                    else
                    {
                        tempLot = lot;
                        tempCount = countLot;
                    }
                }
                else
                {
                    tempLot = lot;
                    tempCount = countLot;
                }
            }
        }
    }

Here's the code for that block where the closing time checker does all the stuff.

Doesn't it matter when to call the function? The main thing is to have a closed order. Or not...?

Z.Y. Already changed it to more profitable in terms of productivity. But I still wonder what I do wrong with OrderCloseTime().

 
Solree:

Here's the code of the block where the closing time checker does all the stuff.

Doesn't it matter when to call the function? The main thing is to have a closed order. Or not...?

Z.Y. Already changed it to more profitable in terms of productivity. But I still wonder what I do wrong with OrderCloseTime().

You'd better write down what you want to achieve.
Reason: