Skip to content

HookTradeRequestOpen

HookTradeRequestOpen

A hook for adding a validated trade request to open a trade into the processing queue.

Warning

This hook is highly sensitive — it can affect the operation of the entire server. Do not use this hook unless absolutely necessary.

virtual int HookTradeRequestOpen(
    const TradeRecord&      trade,        // reference to the trade request object
    const GroupRecord&      group,        // reference to the group configuration object
    const SymbolRecord&     symbol,       // reference to the symbol configuration object
    const AccountRecord&    user,         // reference to the account object
    const MarginLevel&      margin,       // reference to the margin state object
    TradeDiffRecord&        trade_dif     // [in/out] reference to the trade difference object that must be applied as a result of executing the trade request (see below)
);

Parameters

  • trade
    [in] Reference to the TradeRecord object representing the trade request.

  • group
    [in] Reference to the GroupRecord object representing the client group configuration for which the request is processed.

  • symbol
    [in] Reference to the SymbolRecord object representing the symbol configuration for which the request is processed.

  • user
    [in] Reference to the AccountRecord object representing the current account associated with the request.

  • margin
    [in] Reference to the MarginLevel object representing the current margin state associated with the request.

  • trade_dif
    [in/out] Reference to the TradeDiffRecord object that should be created as a result of executing the trade request.
    This is filled only for requests related to the creation of a new order (see the list below). The order is fully prepared to be added to the trading database (all fields are filled except for the ticket). The creation of the new order and assignment of the ticket happens only after MT_RET_OK is returned from the hook.


Return Value

  • If RET_OK is returned, the operation is confirmed.
  • Otherwise, the request will be rejected with the corresponding code.

Notes

Depending on the type of trade request, the hook allows you to: - modify the request, - reject the request, - accept the request without changes.

The value of trade_dif is only filled for the following request types (EnTradeActions):

  • TA_REQUEST
  • TA_INSTANT
  • TA_MARKET
  • TA_EXCHANGE
  • TA_PENDING
  • TA_DEALER_POS_EXECUTE
  • TA_ACTIVATE_SL
  • TA_ACTIVATE_TP
  • TA_STOPOUT_POSITION

For all other request types, changes to trade_dif will not be applied.