3.3.1Overview of trading requests

The request definition which you submit as a parameter to SendOrder() always has one compulsory property: tradingAction. It then has other compulsory or optional properties depending on the type of trading action.

Useful note! The Run Script widget in the MyTrader platform provides interactive help on constructing the properties for trading requests. If you use Create From > Trading Action it will show you the script and request settings corresponding to a set of options in the deal ticket.

For the purposes of trading requests, the FXB.OrderTypes enumeration has values which are not applicable in the context of an FXB.Order. These extra values are described in the sections below.

Particularly when opening orders and trades, some options can be specified in multiple forms. This saves your code from doing its own calculations, and makes it easier to translate from user interface fields to properties in a trading request. For example, all the following (and others listed below) are valid ways of specifying the volume when opening a new order or trade:

Example

Description

volume: 10000

Standard request, defining volume in terms of cash/units

volume: {lots: 0.1}

Framework converts the specified lots quantity to cash/units using the contractSize of the FXB.Instrument

volume: {equityPercent: 0.5}

Can only be used in combination with a stop-loss. The framework calculates the trade volume such that the cash value of hitting the stop-loss is (a maximum of) the specified percentage of current account equity

In other words, the framework lets you send a request saying "stop-loss at 50 pips and risking 1% of account equity" without needing to do all the accompanying calculations yourself in your own code:

Framework.SendOrder({

sl: {pips: 50},

volume: {equityPercent: 1},

The asynchronous MsgResult from SendOrder() contains a result object which has isOkay and isError properties. If the request was unsuccessful, result will contain a non-zero code property specifying the error.