PositionGetDouble(POSITION_PRICE_OPEN) retrieve wrong open price

 

Hello,

Im writing an EA which I want to keep an position's open price in double 2d array. (Please focus on the highlighted price)


from the above log, the value on the left is the expected price which I would like to keep it as an index. The value on the right is the actual price that I find the latest price by comparing time and put it in the array. You can see the code below that I use it to insert value in my array. The prices in the log are in open position already.

 //find latest price
for(int j=0; j<PositionsTotal(); j++)
{
        ulong loopTicket = PositionGetTicket(j);
        datetime currentTicketTime = PositionGetInteger(POSITION_TIME);
        if(currentTicketTime > time)
        {
                time = currentTicketTime;
                positionIndex = index
        }
}
ulong ticket = PositionGetTicket(positionIndex);
double latestOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN);
orderBuyList.AddActualValue(index,latestOpenPrice);

Please note that orderBuyList variable is an 2d array.

The problem is when I use the code below to see open price for from the openned position. I got different value.

//print all sell open price
Alert("All open sell price position");
for(int i=0; i<PositionsTotal(); i++)
{
        int ticket = PositionGetTicket(i);
        if(PositionGetInteger(POSITION_TYPE) == 1)
        {
                Alert(PositionGetDouble(POSITION_PRICE_OPEN));
        }
}

below is the result from the code above


If you follow what I have told you, you will see that the actual price in an array is 1.48934, but the price which I print to see all open position is 1.4893. Other price are correct, but only this one is incorrect. I will use price in an array to compare with the openned position's price to make a decision to open or not to open position. When I got wrong value, my EA works incorrectly.

Please Help

 
Please help me. If you need more information, feel free to ask. 
 

I think it's needs to be

positionIndex = j;
 
lippmaje:

I think it's needs to be

It is correct to use positionIndex = index because index is just a index and its not actual price. The problem is the open position price in the array is not equals to the open price that I loop and print to see all open price of openned position

Thank for your comment
 
Still need answer. Please help. I have tried to solve this problem all day, but I can't .
 
Tanitsak Jirawuttanakit:
Still need answer. Please help. I have tried to solve this problem all day, but I can't .
You need to show all of your code.