When you calculate your PNL, you need to account for the fees that you pay on the exit and entry orders as well as for funding on perpetual contracts.


Net PNL = Gross PNL - (Fees Paid)

Fees Paid = Entry Fees + Exit Fees + Funding Fees


The close price past which your position is in profit is called a break-even price. The break-even price of your position will be different for each contract as the fees for each contract differ. You can confirm the fees for each contract traded on BitMEX here.


For example, if you open and close an XBTUSD position using market orders, you will pay a 0.075% fee on the entry and exit order value. Your exit price should be 2 * 0.075% = 0.15% away from the entry price in a profitable direction to be break-even.


If you pay the taker fee on the entry order and get the maker rebate on the exit order, your break-even price will be 0.075% - 0.025% = 0.05% in a profitable direction. 


If you get the maker rebate on both entry and exit orders, your break-even price will be your average-entry price.


After opening a position, you can refer to the breakEvenPrice field from the https://www.bitmex.com/api/explorer/#!/Position/Position_get endpoint to get the break-even price of your position. This price is calculated on the assumption that both entry and exit orders pay the taker fee and the position has not paid any funding fees.