3.12.6Framework.DisplayPrice()

DisplayPrice() formats a price into an HTML element, rather than returning text. This is because it implements MyTrader's standard formatting of prices such as 1.23456 which requires HTML representation, with specific CSS classes, rather than plain text. (Therefore, DisplayPrice() is only relevant to a widget, not to a script or UDIX.)

Note: the DOM node which receives the output must be empty on first use of DisplayPrice().

The parameters for DisplayPrice() are as follows.

Parameter

Description

target

Either a DOM node into which to put the price, or the ID of a node. If target is a string, then the framework does $$(target).

instrument

The market to use for formatting the price. Can be specified either as an FXB.Instrument object or the instrumentId of a market

price

The price to format

options

Optional. Number-formatting options which are ultimately passed to FormatNumber(). For example, to suppress thousands-separators, set thousands_separator to a blank string

For example:

<!-- Note: the element which is the target of DisplayPrice() must be empty on the first call -->

<span id="bid"></span>

var market = Framework.Instruments.get("EUR/USD");

Framework.DisplayPrice("bid", market, market.bid);