3.3.2.7Candle-based prices in order definitions

The definition of the openPrice, sl, and tp in an order or trade can instruct the framework to calculate a price from historic candle data. For example: "open price at the high of yesterday's D1 [daily] candle, plus 1 pip".

Note: this can lead to a significant delay in processing a request unless the framework has already been asked to collect this candle data.

To use candle-based prices, the trading request must include a timeframe. The definitions of the open price, stop-loss, and take-profit must use the same timeframe (or none); you cannot mix definitions from different timeframes within the same request.

The definition of the openPrice, sl, and/or tp can then include the following values. The index and price are compulsory. The offsetPips is optional.

Bar-based price

Description

index

Zero-based candle index. Zero means "the current candle"; 1 means "the last complete candle" etc.

price

The price to use from the candle: one of o, h, l, c

offsetPips

Optional offset in pips to add (note: always add) to the candle price

For example, the following request specifies the following:

Buy-limit pending order

Open price at the high of yesterday's D1 candle

Stop-loss at the low of yesterday's D1 candle, minus 5 pips

Take-profit at 30 pips from the current price (not candle-based)

Framework.SendOrder({

tradingAction: FXB.OrderTypes.BUY_LIMIT,

timeframe: 86400, // Timeframe for candle-based open price and stop-loss

openPrice: {bar: {index: 1, price: "h"}},

sl: {bar: {index: 1, price: "l", offsetPips: -5}},

tp: {pips: 30},