The Entry Price of your position is calculated by taking the weighted average fill price of the orders that increased your position. The formula is as follows:
Size / ((Qty_1/Price_1)+(Qty_2/Price_2)...+(Qty_n/Price_n))
Size is the total quantity that you have gone Long or Short,
Qty_n is the quantity of your n'th order and
Price_n is the price of your n'th order.
If you are Long, only Long orders contribute to your Average Entry Price. Short orders can be ignored in this case.
If you are Short, only Short orders contribute to your Average Entry Price. Long orders can be ignored in this case.
You place an order to go Long 20,000 contracts at a price of 10,000. Your order gets filled, and a Long position is opened.
The Average Entry Price of this position is now:
(Size / (Qty_1/Price_1)) = (20,000/(20,000/10,000)) = 10,000.
You then place another order to go Long 40,000 contracts at a price of 12,000. The Average Entry Price is now:
(Size / (Qty_1/Price_1)+(Qty_2/Price_2)) = (60,000/(20,000/10,000)+(40,000/12,000)) = 11250.