MyTrader lets you build widgets, scripts, and user-defined indicators. A trading algo can be any of these — see §1 for a comparison and when to prefer each.
An overview of development for the MyTrader platform is available at https://www.fxblue.com/mytrader/mytrader-development.md
Documentation sections:
- Section 1 - Framework fundamentals
- Section 1.1 - Examples
- Section 1.1.1 - Canonical widget skeleton
- Section 1.1.2 - Full example widget
- Section 1.1.3 - Guidance for LLMs building MyTrader widgets
- Section 1.2 - Framework access
- Section 1.2.1 - Linking to the framework's Javascript and CSS in a widget
- Section 1.2.2 - Creating an instance of the framework in a widget
- Section 1.2.2.1 - Alternative, class-based framework access in widgets
- Section 1.2.3 - Waiting for the framework to become available in a widget
- Section 1.2.4 - Reloading or navigation in widgets
- Section 1.3 - Browser environment
- Section 1.3.1 - Scripts and UDIXes - web workers
- Section 1.3.2 - Browser modals
- Section 1.3.3 - Widget sandboxing
- Section 1.4 - Asynchronous operation
- Section 1.5 - Javascript Promises
- Section 1.5.1 - Async functions and await syntax
- Section 1.6 - Component lifecycle
- Section 1.6.1 - Script lifecycle
- Section 1.6.2 - UDIX lifecycle
- Section 1.6.3 - Widget lifecycle
- Section 1.6.3.1 - Permanent widgets
- Section 1.7 - External data and hosting
- Section 1.7.1 - Requesting external data (news etc)
- Section 1.7.2 - Hosting external content for the MyTrader platform
- Section 1.8 - Trading account capabilities
- Section 1.9 - Data representations and standards
- Section 1.9.1 - Dictionaries
- Section 1.9.2 - Times
- Section 1.9.3 - Time zones
- Section 1.9.4 - Trade volumes
- Section 1.9.5 - Candle data
- Section 1.9.6 - Chart timeframes
- Section 1.10 - Runtime environment assumptions
- Section 1.11 - Common pitfalls
- Section 1.12 - Future additions to the framework
- Section 1.12.1 - Undocumented members of the framework
- Section 2 - Collections, objects, and properties in the framework
- Section 2.1 - Framework collections
- Section 2.2 - Framework objects
- Section 2.3 - Framework properties
- Section 2.4 - Framework.Instruments collection
- Section 2.4.1 - Instruments.get(), Instruments.getOrBlank(), and standardisation
- Section 2.4.2 - Instruments.GetTradeableInstruments()
- Section 2.4.3 - Instruments.GetInstrumentCategories()
- Section 2.5 - FXB.Instrument object
- Section 2.5.1 - FXB.Instrument properties
- Section 2.5.2 - Market categories (categoryId of FXB.Instrument)
- Section 2.5.3 - Market data on spread-betting accounts
- Section 2.5.4 - FXB.Instrument helper functions
- Section 2.6 - Framework.Orders collection
- Section 2.7 - FXB.Order object
- Section 2.7.1 - Order types
- Section 2.7.2 - Order-type helper functions
- Section 2.8 - Framework.Positions collection
- Section 2.9 - FXB.Position object
- Section 2.10 - Framework.TradeHistory collection
- Section 2.11 - Framework.Account object
- Section 2.11.1 - Framework.Account properties
- Section 2.11.2 - Account features
- Section 2.12 - Framework.Environment object
- Section 2.13 - Framework.Translation object
- Section 2.13.1 - List of available language variables
- Section 2.13.2 - Framework.Translation.TranslateDOM()
- Section 2.13.3 - Framework.Translation.TranslateItem() and Framework.$T()
- Section 2.13.4 - Framework.Translation.TranslateError()
- Section 2.13.5 - Framework.Translation.TranslateTimeframe()
- Section 2.13.6 - Framework.Translation.TranslateInstrumentCategory()
- Section 2.14 - Framework.Theme object
- Section 2.15 - FXB.Result object
- Section 3 - Functions in the framework
- Section 3.1 - Price requests
- Section 3.2 - Historic candle data
- Section 3.2.1 - Candle response messages
- Section 3.2.2 - Terminating streaming requests
- Section 3.2.3 - Time zones for candle requests
- Section 3.3 - Trading
- Section 3.3.1 - Overview of trading requests
- Section 3.3.2 - New pending orders and trades
- Section 3.3.2.1 - Volume on order and trade requests
- Section 3.3.2.2 - Open price on pending orders
- Section 3.3.2.3 - Stop-loss on orders and trades
- Section 3.3.2.4 - Take-profit on orders and trades
- Section 3.3.2.5 - Trailing stop on orders and trades
- Section 3.3.2.6 - Expiry on pending orders
- Section 3.3.2.7 - Candle-based prices in order definitions
- Section 3.3.3 - Modifying open trades and pending orders
- Section 3.3.3.1 - Break-even exit on open trades
- Section 3.3.4 - Closing individual trades and orders
- Section 3.3.5 - Closing all open trades or pending orders on a single market
- Section 3.3.6 - Closing all open trades or pending orders on the whole account
- Section 3.3.7 - Asynchronous result callback for SendOrder()
- Section 3.3.8 - Optional settings for trading requests
- Section 3.3.9 - Forcing confirmation of all subsequent trading
- Section 3.3.10 - Validating trading requests without execution
- Section 3.4 - Account history
- Section 3.5 - Dialogs
- Section 3.5.1 - Standard dialog behaviour and settings
- Section 3.5.2 - Common information/alert/question dialogs
- Section 3.5.2.1 - Button styles for common dialogs
- Section 3.5.2.2 - Callbacks from common dialogs
- Section 3.5.2.3 - Manually destroying common dialogs
- Section 3.5.2.4 - Floating, non-modal common dialogs
- Section 3.5.3 - Selecting a market or timeframe
- Section 3.5.4 - Asking for a text value
- Section 3.5.5 - Selecting from a list
- Section 3.5.5.1 - Checkbox list
- Section 3.5.6 - Menu-list dialogs (with icons, sub-menus etc)
- Section 3.5.7 - Displaying a settings dialog
- Section 3.5.8 - Custom HTML dialogs
- Section 3.5.9 - Widget displaying itself as its own dialog
- Section 3.5.10 - Displaying the platform's standard deal ticket
- Section 3.5.10.1 - Opening the dealticket or trading-action dialogs
- Section 3.5.10.2 - Opening a chart with attached deal ticket
- Section 3.5.10.3 - Selecting an order template
- Section 3.5.11 - Notifying the user by generating mail
- Section 3.5.12 - Toast
- Section 3.5.12.1 - Creating toast
- Section 3.5.12.2 - Dialogs from toast clicks
- Section 3.5.12.3 - Destroying toast
- Section 3.5.13 - Opening widgets in dialogs
- Section 3.6 - Settings and state storage
- Section 3.6.1 - Types of framework storage: private and category
- Section 3.6.2 - Loading and saving category settings
- Section 3.6.3 - Loading and saving private settings
- Section 3.6.4 - Combining category settings and private settings
- Section 3.6.5 - Widget state (for new windows etc)
- Section 3.6.6 - Saving both private and category settings
- Section 3.7 - Interacting with the MyTrader page container and environment
- Section 3.7.1 - Handling context - synchronization in the page container
- Section 3.7.2 - Changing the market or timeframe of the current page
- Section 3.7.3 - Changing the current page displayed in MyTrader
- Section 3.7.4 - Chart sidebar/dock widgets
- Section 3.7.4.1 - Getting and setting the chart instrument and timeframe
- Section 3.7.4.2 - Chart widget dock title
- Section 3.7.4.3 - Chart widget height
- Section 3.7.4.4 - Chart bar data and events
- Section 3.7.4.5 - Creating drawings etc
- Section 3.8 - Displaying and embedding trading charts
- Section 3.8.1 - Displaying a chart as a dialog
- Section 3.8.2 - Embedding a trading chart in an iframe, inside a widget
- Section 3.8.3 - Instrument and timeframe context for trading charts
- Section 3.8.4 - Settings for displaying trading charts
- Section 3.8.4.1 - Changing the initial chart styles and options
- Section 3.8.4.2 - Loading indicators onto trading charts
- Section 3.8.4.3 - Loading drawings onto trading charts
- Section 3.8.4.4 - Loading event markers onto trading charts
- Section 3.8.4.5 - Loading bar highlights onto trading charts
- Section 3.8.4.6 - Populating the chart's deal ticket
- Section 3.8.5 - Modifying a chart dialog or embedded chart
- Section 3.8.5.1 - Getting the ID of a chart dialog or embedded chart
- Section 3.8.5.2 - Passing the ID of a trading chart to ChartChange()
- Section 3.9 - Interacting with trading charts
- Section 3.9.1 - Callback from ChartChange()
- Section 3.9.2 - Changing the market of a chart
- Section 3.9.3 - Changing the timeframe of a chart
- Section 3.9.4 - Loading an indicator onto a chart
- Section 3.9.5 - Removing an indicator from a chart
- Section 3.9.6 - Removing all indicators from a chart
- Section 3.9.7 - Adding a drawing to a chart
- Section 3.9.7.1 - Drawing properties
- Section 3.9.7.2 - Types of drawing
- Section 3.9.8 - Modifying or moving a drawing
- Section 3.9.9 - Removing a drawing
- Section 3.9.10 - Removing all drawings from a chart
- Section 3.9.11 - Adding an event marker to a chart
- Section 3.9.11.1 - Event marker properties
- Section 3.9.11.2 - Click notifications from event markers
- Section 3.9.12 - Removing an event marker
- Section 3.9.13 - Removing all event markers from a chart
- Section 3.9.14 - Adding a bar highlight to a chart
- Section 3.9.15 - Removing a bar highlight
- Section 3.9.16 - Removing all bar highlights
- Section 3.9.17 - Adding HTML to a chart
- Section 3.9.17.1 - HTML options
- Section 3.9.17.2 - Co-ordinates for the HTML
- Section 3.9.17.3 - Sending messages from the HTML to its creator
- Section 3.9.17.4 - Sending messages from the widget/script to the HTML
- Section 3.9.17.5 - Removing the HTML from the chart
- Section 3.9.18 - Populating a chart's deal ticket
- Section 3.9.18.1 - Hiding the deal ticket
- Section 3.9.19 - Retrieving data from a chart
- Section 3.9.20 - Loading named indicator studies and chart templates
- Section 3.9.20.1 - Loading an indicator study (replacing all existing indicators)
- Section 3.9.20.2 - Adding an indicator study (keeping existing indicators)
- Section 3.9.20.3 - Loading a chart template
- Section 3.10 - Communicating between widgets/scripts/UDIXes
- Section 3.11 - Time conversion functions
- Section 3.11.1 - Time zone definitions
- Section 3.11.2 - Getting the current time - Framework.Now()
- Section 3.11.2 - Converting between UTC and a different time zone
- Section 3.11.3 - The user's time zone preferences
- Section 3.12 - Helper functions for formatting values
- Section 3.12.1 - Framework.FormatNumber()
- Section 3.12.2 - Framework.FormatCash()
- Section 3.12.3 - Framework.FormatPercent()
- Section 3.12.4 - Framework.FormatVolume()
- Section 3.12.5 - Framework.FormatDate()
- Section 3.12.6 - Framework.DisplayPrice()
- Section 3.12.7 - Generating a textual description of an order or trading action
- Section 3.13 - Trading validators
- Section 3.14 - Market depth and order book
- Section 3.14.1 - Market depth
- Section 3.14.2 - Order book
- Section 3.15 - Economic calendar
- Section 3.16 - The MyTrader mail system
- Section 3.16.1 - Availability of the mail system
- Section 3.16.2 - Overview of the mail system
- Section 3.16.3 - Sending mail
- Section 3.16.4 - Receiving mail
- Section 3.17 - Logging
- Section 3.18 - Miscellaneous functions
- Section 3.18.1 - Generating downloads
- Section 3.18.2 - Copying text to the clipboard
- Section 4 - Messages and event handlers
- Section 4.1 - The FXB.Message object, and multiple types
- Section 4.2 - Extra data in each message
- Section 4.3 - Types of message
- Section 4.4 - FXB.MessageTypes.PRICE and OnPriceChange
- Section 4.4.1 - PRICE messages in OnMessage
- Section 4.4.2 - OnPriceChange handler
- Section 4.5 - FXB.MessageTypes.ORDER_x and OnOrderX handlers
- Section 4.5.1 - ORDER_x messages in OnMessage
- Section 4.5.2 - OnOrderX handlers
- Section 4.6 - FXB.MessageTypes.POSITION_CHANGE and OnPositionChange
- Section 4.6.1 - POSITION_CHANGE message in OnMessage
- Section 4.6.2 - OnPositionChange handler
- Section 4.7 - FXB.MessageTypes.ACCOUNT_METRICS and OnAccountMetrics
- Section 4.7.1 - ACCOUNT_METRICS message in OnMessage
- Section 4.7.2 - OnAccountMetrics handler
- Section 4.8 - FXB.MessageTypes.ACCOUNT_HISTORY
- Section 4.9 - FXB.MessageTypes.MARKET_DEPTH
- Section 4.10 - FXB.MessageTypes.ORDER_BOOK
- Section 4.11 - FXB.MessageTypes.MAILBOX
- Section 4.12 - FXB.MessageTypes.THEME
- Section 4.13 - FXB.MessageTypes.CATEGORY_SETTINGS_CHANGE
- Section 4.14 - FXB.MessageTypes.WIDGET_CONTEXT_CHANGE
- Section 4.15 - FXB.MessageTypes.WIDGET_INSTRUMENT_SELECTION
- Section 4.16 - FXB.MessageTypes.SHORTCUT_KEY
- Section 4.17 - FXB.MessageTypes.BROADCASTx and FXB.MessageTypes.GENERICx
- Section 5 - Working with candle data
- Section 5.1 - The FXB.CandleStore object
- Section 5.1.1 - Creating a candle store
- Section 5.1.2 - Loading data into the candle store
- Section 5.1.3 - Events in the candle store
- Section 5.1.4 - Reading data from the candle store
- Section 5.1.5 - Derived properties of each candle
- Section 5.1.6 - Technical analysis calculations in the candle store
- Section 5.1.7 - Aggregation to higher timeframes
- Section 5.2 - FXB.ta technical analysis library
- Section 5.2.1 - Calculation input: bar-based versus value-based calculations
- Section 5.2.2 - Creating and initialising technical analysis calculations
- Section 5.2.2.1 - The member parameter, and derived prices
- Section 5.2.3 - Loading data into a technical analysis calculation
- Section 5.2.3.1 - Loading candle data into a calculation
- Section 5.2.3.2 - Loading value data into a calculation
- Section 5.2.3.3 - Loading data in the calculation's initialisation
- Section 5.2.4 - Reading calculation output
- Section 5.2.5 - Indexing order and oldestFirst
- Section 5.2.6 - Combining arrays
- Section 5.2.7 - Moving averages
- Section 5.2.8 - List of technical analysis calculations
- Section Accumulative_Swing_Index_-_FXB.ta.ASI - Accumulative Swing Index - FXB.ta.ASI
- Section ADX_-_FXB.ta.ADX - ADX - FXB.ta.ADX
- Section Aroon_-_FXB.ta.Aroon - Aroon - FXB.ta.Aroon
- Section Aroon_oscillator_-_FXB.ta.AroonOsc - Aroon oscillator - FXB.ta.AroonOsc
- Section Average_True_Range_-_FXB.ta.ATR - Average True Range - FXB.ta.ATR
- Section Awesome_Oscillator_-_FXB.ta.AO - Awesome Oscillator - FXB.ta.AO
- Section Bear/Bull_power_-_FXB.ta.BearBull - Bear/Bull power - FXB.ta.BearBull
- Section Bollinger®_bands_-_FXB.ta.Bands - Bollinger® bands - FXB.ta.Bands
- Section Centre_of_Gravity_-_FXB.ta.COG - Centre of Gravity - FXB.ta.COG
- Section Commodity_channel_index_-_FXB.ta.CCI - Commodity channel index - FXB.ta.CCI
- Section Chaikin_Money_Flow_-_FXB.ta.CMF - Chaikin Money Flow - FXB.ta.CMF
- Section Chaikin_volatility_-_FXB.ta.ChaikinVolatility - Chaikin volatility - FXB.ta.ChaikinVolatility
- Section Chande_forecast_oscillator_-_FXB.ta.CFO - Chande forecast oscillator - FXB.ta.CFO
- Section Chande_momentum_oscillator_-_FXB.ta.CMO - Chande momentum oscillator - FXB.ta.CMO
- Section Coppock_curve_-_FXB.ta.CoppockCurve - Coppock curve - FXB.ta.CoppockCurve
- Section Derived_price_-_FXB.ta.DerivedPrice - Derived price - FXB.ta.DerivedPrice
- Section Detrended_price_oscillator_-_FXB.ta.DPO - Detrended price oscillator - FXB.ta.DPO
- Section Ease_of_movement_-_FXB.ta.EOM - Ease of movement - FXB.ta.EOM
- Section Ehler_Fisher_transform_-_FXB.ta.EFT - Ehler Fisher transform - FXB.ta.EFT
- Section Elder_Market_Thermometer_-_FXB.ta.EMT - Elder Market Thermometer - FXB.ta.EMT
- Section Elder_Force_Index_-_FXB.ta.EFI - Elder Force Index - FXB.ta.EFI
- Section Envelope_around_a_moving_average_-_FXB.ta.Envelope - Envelope around a moving average - FXB.ta.Envelope
- Section Fractal_bands_-_FXB.ta.FractalBands - Fractal bands - FXB.ta.FractalBands
- Section Gopalakrishnan_range_index_-_FXB.ta.GRI - Gopalakrishnan range index - FXB.ta.GRI
- Section Highest_of_the_last_N_values_-_FXB.ta.Highest - Highest of the last N values - FXB.ta.Highest
- Section Historical_Volatility_-_FXB.ta.HV - Historical Volatility - FXB.ta.HV
- Section Intraday_momentum_index_-_FXB.ta.IMI - Intraday momentum index - FXB.ta.IMI
- Section Keltner_channel_and_STARC_-_FXB.ta.Keltner - Keltner channel and STARC - FXB.ta.Keltner
- Section Klinger_volume_oscillator_-_FXB.ta.KVO - Klinger volume oscillator - FXB.ta.KVO
- Section Linear_regression_forecast_-_FXB.ta.LRF - Linear regression forecast - FXB.ta.LRF
- Section Linear_regression_intercept_-_FXB.ta.LRI - Linear regression intercept - FXB.ta.LRI
- Section Lowest_of_the_last_N_values_-_FXB.ta.Lowest - Lowest of the last N values - FXB.ta.Lowest
- Section MACD_-_FXB.ta.MACD - MACD - FXB.ta.MACD
- Section Market_facilitation_index_-_FXB.ta.MktFacilitation - Market facilitation index - FXB.ta.MktFacilitation
- Section Mass_index_-_FXB.ta.MassIndex - Mass index - FXB.ta.MassIndex
- Section Momentum_oscillator_-_FXB.ta.Momentum - Momentum oscillator - FXB.ta.Momentum
- Section Money_Flow_Index_-_FXB.ta.MoneyFlowIndex - Money Flow Index - FXB.ta.MoneyFlowIndex
- Section Moving_average_oscillator_-_FXB.ta.MAOscillator - Moving average oscillator - FXB.ta.MAOscillator
- Section On-balance_volume_-_FXB.ta.OBV - On-balance volume - FXB.ta.OBV
- Section Parabolic_stop_and_reverse_-_FXB.ta.PSAR - Parabolic stop and reverse - FXB.ta.PSAR
- Section Performance_-_FXB.ta.Performance - Performance - FXB.ta.Performance
- Section Pretty_Good_oscillator_-_FXB.ta.PGO - Pretty Good oscillator - FXB.ta.PGO
- Section Price_Oscillator_-_FXB.ta.PO - Price Oscillator - FXB.ta.PO
- Section QStick_-_FXB.ta.QStick - QStick - FXB.ta.QStick
- Section Rainbow_oscillator_-_FXB.ta.Rainbow - Rainbow oscillator - FXB.ta.Rainbow
- Section Random_Walk_Index_-_FXB.ta.RWI - Random Walk Index - FXB.ta.RWI
- Section Rank_-_FXB.ta.Rank - Rank - FXB.ta.Rank
- Section Rate_of_change_-_FXB.ta.ROC - Rate of change - FXB.ta.ROC
- Section RAVI_-_FXB.ta.RAVI - RAVI - FXB.ta.RAVI
- Section Relative_Strength_Index_-_FXB.ta.RSI - Relative Strength Index - FXB.ta.RSI
- Section Relative_Vigor_Index_-_FXB.ta.RVI - Relative Vigor Index - FXB.ta.RVI
- Section R-squared_-_FXB.ta.RSquared - R-squared - FXB.ta.RSquared
- Section Schaff_trend_cycle_-_FXB.ta.STC - Schaff trend cycle - FXB.ta.STC
- Section Slope_of_linear_regression_-_FXB.ta.Slope - Slope of linear regression - FXB.ta.Slope
- Section Standard_deviation_-_FXB.ta.Stdev - Standard deviation - FXB.ta.Stdev
- Section Stochastic_momentum_index_-_FXB.ta.SMI - Stochastic momentum index - FXB.ta.SMI
- Section Stochastic_oscillator_-_FXB.ta.Stochastic - Stochastic oscillator - FXB.ta.Stochastic
- Section Stochastic_RSI_-_FXB.ta.StochRSI - Stochastic RSI - FXB.ta.StochRSI
- Section Sum_-_FXB.ta.Sum - Sum - FXB.ta.Sum
- Section Swing_index_-_FXB.ta.SwingIndex - Swing index - FXB.ta.SwingIndex
- Section TRIX_-_FXB.ta.Trix - TRIX - FXB.ta.Trix
- Section True_range_-_FXB.ta.TrueRange - True range - FXB.ta.TrueRange
- Section Twiggs_Money_Flow_-_FXB.ta.TMF - Twiggs Money Flow - FXB.ta.TMF
- Section Ultimate_oscillator_-_FXB.ta.UO - Ultimate oscillator - FXB.ta.UO
- Section Vertical_horizontal_filter_-_FXB.ta.VHF - Vertical horizontal filter - FXB.ta.VHF
- Section Volume_Index_-_FXB.ta.VolumeIndex - Volume Index - FXB.ta.VolumeIndex
- Section Williams_Accumulation_Distribution_-_FXB.ta.WAD - Williams Accumulation Distribution - FXB.ta.WAD
- Section Williams_%R_-_FXB.ta.WilliamsPctR - Williams %R - FXB.ta.WilliamsPctR
- Section 6 - Widget HTML and CSS reference
- Section 6.1 - CSS reference
- Section 6.1.1 - Body classes
- Section 6.1.2 - Right-to-left reading order
- Section 6.1.3 - Button CSS classes
- Section 6.1.4 - FontAwesome icons
- Section 6.1.5 - CSS variables
- Section 6.2 - Standard HTML structure
- Section 6.2.1 - Standard dialog structure
- Section 6.2.2 - Reserved areas in the widget frame
- Section 6.3 - Pop-up menus
- Section 7 - FXB.utils and other helper functions
- Section 7.1 - FXB.utils.Dictionary()
- Section 7.2 - FXB.utils.Clone()
- Section 7.3 - FXB.utils.IsEmpty()
- Section 7.4 - FXB.utils.GenerateGuid()
- Section 7.5 - FXB.utils.GenerateHash()
- Section 7.6 - $$()
- Section 8 - Framework error codes
- Section 8.1 - Success/no-failure values
- Section 8.2 - Not-yet-implemented errors
- Section 8.3 - Failed internal validation of trading actions
- Section 8.4 - Trading requests blocked by user settings/preferences
- Section 8.5 - Rejection by trading validators
- Section 8.6 - Trading requests rejected by the broker platform
- Section 8.7 - Other (non-trading) errors
- Section 9 - Script contexts
- Section 9.1 - Quote Board script context
- Section 9.2 - Trade List script context
- Section 9.3 - Chart script context
- Section 9.4 - Order Menu script context
- Section 10 - Sending mail into MyTrader from outside the platform