Adaptive Moving Average (AMA)

Overview

An Adaptive Moving Average (AMA) is one more moving average overlay, just like EMA. It changes its sensitivity to price fluctuations. The Adaptive Moving Average becomes more sensitive during periods when price is moving in a certain direction and becomes less sensitive to price movement when price is volatile.

AnyChart Stock allows you to add AMA with desired period to any of your charts.

Mathematical description of the indicator please see at: Mathematical Description of Technical Indicators

to top

Adding indicator

To add any indicator to the chart, you need to use Data Provider with the fields required by the indicator. When such Data Provider is ready - you can add indicator to the chart.

Preparing Data Provider

AMA indicator needs Data Provider with Value or Close fields.

Sample XML of Data Provider, which can be used to create AMA indicator:

XML/JSON Syntax
Plain code
03     <data_provider data_set="dataSet1" id="dpMsft">
04       <fields>
05         <field type="Close" column="4" approximation_type="Close" />
06       </fields>
07     </data_provider>
01{
03    {
04      dataSet: "dataSet1",
05      id: "dpMsft",
06      fields: [
07        {
08          type: "Close",
09          column: 4,
10          approximationType: "Close"
11        }
12      ]
13    }
14  ]
15}

In case if you use Data Provider for OHLC or Candlestick, XML looks like that:

XML/JSON Syntax
Plain code
03     <data_provider data_set="dataSet1" id="dp1">
04       <fields>
05         <field type="Open" column="1" approximation_type="Open" />
06         <field type="High" column="2" approximation_type="High" />
07         <field type="Low" column="3" approximation_type="Low" />
08         <field type="Close" column="4" approximation_type="Close" />
09       </fields>
10     </data_provider>
01{
03    {
04      dataSet: "dataSet1",
05      id: "dp1",
06      fields: [
07        {
08          type: "Open",
09          column: 1,
10          approximationType: "Open"
11        },
12        {
13          type: "High",
14          column: 2,
15          approximationType: "High"
16        },
17        {
18          type: "Low",
19          column: 3,
20          approximationType: "Low"
21        },
22        {
23          type: "Close",
24          column: 4,
25          approximationType: "Close"
26        }
27      ]
28    }
29  ]
30}

to top

Indicator Declaration

As soon as Data Provider is ready you can add it to the chart.

AMA indicator is usually used as an Overlay indicator and displayed on the same chart with data series (stock data). So we should declare it in the chart where series is displayed.

XML for AMA declaration:

XML/JSON Syntax
Plain code
01 <chart>
02   <series_list>
03     <series type="Line" data_provider="dpMsft" color="#0066DD">
04       <line_series thickness="2" />
05       <name><![CDATA[MSFT]]></name>
06     </series>
07   </series_list>
09     <technical_indicator type="AMA" data_provider="dpMsft" />
11 </chart>
01{
02  seriesList: [
03    {
04      type: "Line",
05      dataProvider: "dpMsft",
06      color: "#0066DD",
07      lineSeries: {
08        thickness: 2
09      },
10      name: "MSFT"
11    }
12  ],
14    {
15      type: "AMA",
16      dataProvider: "dpMsft"
17    }
18  ]
19}

As you can see AMA type is set to indicator using type attribute, and data_provider attribute specifies Data Provider with series and indicator data.

Live sample of the chart with AMA indicator:

Live Sample:  Technical Indicators - Adding AMA to a Chart

to top

Indicator parameters

Adaptive Moving Average Indicator has three type-specific parameters - period, fast period and slow period. All of them are set in <ama_indicator> node, where all settings for AMA indicator are set.

XML for setting AMA period:

XML/JSON Syntax
Plain code
01{
02  type: "AMA",
03  dataProvider: "dpMsft",
04  amaIndicator: {
05    period: 10,
06    slowPeriod: 30,
07    fastPeriod: 2
08  }
09}

As you can see you just need to set period, fast_period and slow_period attributes in <ama_indicator> node, these attributes accept any integer greater than 1.

Live sample below shows two AMAs: AMA(20,4,50) and AMA(10,2,30):

Live Sample:  Technical Indicators - AMA Parameters

to top

Visualization

To visualize and tune visualization of technical indicators AnyChart Stock Component uses the same methods as for the data series.

By default AMA is shown as series of Line type, but you can use almost any of available series types to show it on the chart - Spline, Area or Stick, for example.

AMA indicator settings are contained in <ama_indicator> node, also in this node you can put <series> subnode - this node defines how exactly indicator is displayed on the chart. This node is identical to <series> node used to describe data series, so you can do with indicator anything you can do with series.

Sample XML for changing indicator visualization:

XML/JSON Syntax
Plain code
01 <technical_indicator type="AMA" data_provider="dpMsft">
02   <ama_indicator>
03     <series type="Spline" color="Green">
04       <line_series thickness="2" />
05       <name><![CDATA[AMA(10,2,30)]]></name>
06     </series>
07   </ama_indicator>
01{
02  type: "AMA",
03  dataProvider: "dpMsft",
04  amaIndicator: {
05    series: {
06      type: "Spline",
07      color: "Green",
08      lineSeries: {
09        thickness: 2
10      },
11      name: "AMA(10,2,30)"
12    }
13  }
14}

As you can see we set period, color, series type is set to Spline, line width is set to 2px, and name is set to "AMA(10,2,30)".

Live sample below shows settings described above:

Live Sample:  Technical Indicators - AMA Visualization Settings

Another example of changing visualization of AMA indicator - it is shown as SplineArea:

Live Sample:  Technical Indicators - Show AMA as SplineArea

to top