# MQL4 OrderProfit()

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderprofit, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Returns the profit of the order now selected, before swaps and commission.

- Function: `OrderProfit()`
- Interface: MQL4
- Group: Reading the selected order
- Status: verified. Source: [docs.mql4.com](https://docs.mql4.com/trading/orderprofit), checked 2026-10-12.

This is an MQL4 function, not an HTTP endpoint. It has no method, no path and no address to send a request to: it runs inside the MetaTrader 4 terminal, in a program written in MQL4. It is in no OpenAPI file on this site and the request builder does not list it.

Note: The page says the order has to be selected first with OrderSelect().

## Signature

The form of the call on the vendor's page, with the vendor's comments taken out.

```mql4
double OrderProfit()
```

## Arguments

The function takes no arguments.

## Return value

- Type: `double`
- What comes back: The net profit without swaps or commission. For an open order it is the unrealised figure as it stands, for a closed order the fixed one.

## Sample

Written by this site from the signature and arguments recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. It holds no credential and needs none: the program runs inside a terminal that is already logged in to an account. Nothing is entered on this site.

```mql4
void OnStart()
  {
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         Print(OrderProfit());
     }
  }
```

## Related MQL4 functions: Reading the selected order

- [OrderLots()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderlots): Returns the size, in lots, of the order now selected.
- [OrderMagicNumber()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordermagicnumber): Returns the magic number of the order now selected, the identifier a program gave it when it was sent.
- [OrderOpenPrice()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderopenprice): Returns the open price of the order now selected.
- [OrderStopLoss()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderstoploss): Returns the stop loss level of the order now selected.
- [OrderSymbol()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordersymbol): Returns the symbol of the order now selected.
- [OrderTakeProfit()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordertakeprofit): Returns the take profit level of the order now selected.
- [OrderTicket()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderticket): Returns the ticket number of the order now selected.
- [OrderType()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordertype): Returns the operation type of the order now selected, which says whether it is a buy or a sell and whether it is open or pending.

## More on MetaTrader 4

- [All MetaTrader 4 functions](https://openbrokerapi.com/platforms/metatrader-4/functions): 28 documented here, grouped by what they do.
- [All MetaTrader 4 error codes](https://openbrokerapi.com/errors/mt4)
- [MetaTrader 4 API page](https://openbrokerapi.com/platforms/metatrader-4): The full record: access, authentication, limits and the source for each.

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: MQL4 OrderProfit(). Broker API Hub, https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderprofit, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
