1Framework fundamentals

MyTrader lets you build widgets, scripts, and user-defined indicators. A trading algo can be any of these - see below for a comparison and when to prefer each.

Widgets. All the built-in tools in MyTrader - charts, quote board, trade list etc - are widgets, and any widgets which you create — whether tools, dashboards, or algos — have access to all the same features as built-in widgets. You can open a widget temporarily by clicking the Widgets icon and selecting External Widget. To load one more permanently, add a page in MyTrader and choose External Widget as the component. As a shortcut, in newer versions of the platform you can also drop a widget file (.htm or .html) directly onto an empty container in a page.

Scripts. You can create and save scripts using the Run Script widget in MyTrader. Scripts can be given icons in the platform's banner, and can be set to start automatically when the platform is loaded. (Scripts can also be given a context, so that they become available in specific places within the MyTrader platform.)

User-defined indicators, for charts. You can add a user-defined indicator to a chart by choose Advanced > Add UDI from the chart's indicator menu.

User-defined indicators subdivide into two types:

Standard indicators (UDI), which only have access to the chart on which they run.

Enhanced indicators (UDIX) which also have access to the MyTrader framework described here. They can see data such as the trade list, and they can carry out actions such as placing trades.

It is usually best to write a trading algo as a widget, because most algos have inputs the user wants to adjust, status the user wants to see, and activity worth keeping on screen — HTML fields for entering parameters, a log of activity, and typically Start and Stop buttons. In a widget, the HTML is the algo's control panel. A widget can also display its activity by embedding a trading chart and then decorating it with drawings, event markers etc - for example, to visualize signals it has detected, or to mark its entries and exits on the chart. However, it is also possible to write an algo as a script - particularly if it is a one-shot action, a scheduled task, an algo whose parameters are fixed at creation time. A UDIX is a third option, well suited to algos that are fundamentally about chart analysis: it reads the same bars the chart displays, it can draw arrows, lines, and markers directly onto the chart where signals trigger, and it can still place trades through the Framework. The chart becomes the algo's canvas in the same way that a widget's HTML is its control panel.

Creating indicators is described elsewhere, at https://www.fxblue.com/mytrader/udi/help. A UDIX is simply an indicator which also has a Framework object, in addition to the indicator features which are described separately. You choose whether to give a UDI access to the Framework, turning it into a UDIX, when you add it to a chart.

In terms of the web browser environment:

Widgets are iframes (sandboxed). A widget is simply an HTML document which integrates with MyTrader by including the framework script and CSS.

Scripts and UDIXes are web workers. They have no user interface of their own, but they can create dialogs and interact with the platform.

MyTrader is a web-based platform, and therefore the programming language for creating widgets, scripts, and UDIXes is simply Javascript. You can also write your code in any language such as TypeScript or CoffeeScript which compiles to Javascript.

You can use any development environment, from Notepad to Visual Studio or Eclipse. You can paste HTML/Javascript into the Run Script and External Widget windows in MyTrader. You don't have to write your code inside the MyTrader platform.

Note: in addition to the facilities described here for extending the MyTrader platform, it is also possible to use the Excel RTD widget to write code outside the MyTrader platform, in any language of your choice such as Node.js, C#, or Python, communicating with the web browser using HTTP or websockets. It is even possible to download data directly into Excel without any programming. For more information, see the document about the Excel RTD widget:

https://www.fxblue.com/mytrader/excel-rtd/help