Volume + MA

Overview

This is an indicator used in charts and technical analysis. It refers to the average volume of a security, commodity or index constructed in a period as short as a few minutes or as long as several years and showing trends for the latest interval.

AnyChart Stock allows you to add Volume MA with desired period and Moving Average type 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

Volume MA indicator needs Data Provider with Value or Close and Volume fields.

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

XML/JSON Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <stock xmlns="http://anychart.com/products/stock/schemas/1.9.0/schema.xsd">
03   <data>
04     <data_providers>
05       <general_data_providers>
06         <data_provider data_set="dataSet1" id="dpMsft">
07           <fields>
08             <field type="Volume" column="5" approximation_type="Average" />
09           </fields>
10         </data_provider>
11       </general_data_providers>
12     </data_providers>
13   </data>
14 </stock>
01{
02  data: {
03    dataProviders: {
04      generalDataProviders: [
05        {
06          dataSet: "dataSet1",
07          id: "dpMsft",
08          fields: [
09            {
10              type: "Volume",
11              column: 5,
12              approximationType: "Average"
13            }
14          ]
15        }
16      ]
17    }
18  }
19}

In the above sample approximation type for Volume field is set to "Average", but for Volume+MA indicator you may find useful to set it to "Sum", like that:

XML/JSON Syntax
Plain code
01 <data_provider data_set="dataSet1" id="dpMsft">
02   <fields>
03     <field type="Volume" column="5" approximation_type="Sum" />
04   </fields>
01{
02  dataSet: "dataSet1",
03  id: "dpMsft",
04  fields: [
05    {
06      type: "Volume",
07      column: 5,
08      approximationType: "Sum"
09    }
10  ]
11}

You can learn more about approximation types in Data Grouping and Values Approximation article.

to top

Indicator Declaration

As soon as Data Provider is ready you can add an indicator to a chart.

Volume MA indicator is usually shown on the chart below the chart with data (stock data). So we should declare it in another chart. Learn more about charts and layout in Chart Layout article.

XML for Volume MA declaration, note that there are two charts defined - one is used to show the stock data, and another one contains technical indicator:

XML/JSON Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <stock xmlns="http://anychart.com/products/stock/schemas/1.9.0/schema.xsd">
03   <settings>
04     <charts>
05       <chart>
06         <series_list>
07           <series type="Line" data_provider="dpMsft" />
08         </series_list>
09       </chart>
10       <chart>
11         <technical_indicators>
12           <technical_indicator type="VolumeMA" data_provider="dpMsft" />
13         </technical_indicators>
14       </chart>
15     </charts>
16   </settings>
17 </stock>
01{
02  settings: {
03    charts: [
04      {
05        seriesList: [
06          {
07            type: "Line",
08            dataProvider: "dpMsft"
09          }
10        ]
11      },
12      {
13        technicalIndicators: [
14          {
15            type: "VolumeMA",
16            dataProvider: "dpMsft"
17          }
18        ]
19      }
20    ]
21  }
22}

Live Sample:

Live Sample:  Technical Indicators - Adding VolumeMA Indicator

to top

Indicator parameters

Volume MA has two type specific parameters - period and moving average type. Both are set in <volume_ma_indicator> node, where all settings for Volume MA indicator are set.

XML for setting Volume MA parameters:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="VolumeMA" data_provider="dpMsft">
04       <volume_ma_indicator ma_period="50" ma_type="SMA" />
05     </technical_indicator>
07 </chart>
01{
03    {
04      type: "VolumeMA",
05      dataProvider: "dpMsft",
06      volumeMaIndicator: {
07        maPeriod: 50,
08        maType: "SMA"
09      }
10    }
11  ]
12}

As you can see you just need to set period attribute in <volume_ma_indicator> node, this attribute accepts any integer greater than 1, and ma_type which can be either SMA or EMA.

Live sample below shows Volume MA with Simple Moving Average and period set to 50:

Live Sample:  Technical Indicators - VolumeMA Parameters

to top

Values Scaling

Due to the nature of Volume MA indicator it is supposed to show large values - millions and billions, but very long labels with big numbers are very hard to read and use that is why it may be useful to use values scaling in labels formatting, like we do in all samples in this article:

XML/JSON Syntax
Plain code
01 <primary>
02   <labels>
03     <format><![CDATA[{%Value}{scale:(1000)(1000)(1000)|( K)( M)( B),numDecimals:2,trailingZeros:false}]]></format>
04   </labels>
05   <scale minimum_mode="CustomValue" minimum="0" />
06 </primary>
01{
02  labels: {
03    format: "{%Value}{scale:(1000)(1000)(1000)|( K)( M)( B),numDecimals:2,trailingZeros:false}"
04  },
05  scale: {
06    minimumMode: "CustomValue",
07    minimum: 0
08  }
09}

This elegant representation of big numbers allows us to see axis labels and conform them with general look and feel of compact charts. If you want to learn more about scaling and labels formatting, please see:

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 Volume MA is shown as series of Stick and Line types, but you can use almost any of available series types to show it on the chart - Spline, Area or Bar, for example.

Volume MA indicator settings are contained in <volume_ma_indicator> node, also in this node you can put <volume_series> and <ma_series> subnodes - these nodes define how exactly indicator is displayed on the chart. These nodes are 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 <chart>
03     <technical_indicator type="VolumeMA" data_provider="dpMsft">
04       <volume_ma_indicator ma_period="30" ma_type="EMA">
05         <volume_series type="Bar" color="Green">
06           <name><![CDATA[Volume]]></name>
07         </volume_series>
08         <ma_series type="SplineArea" color="DarkRed">
09           <name><![CDATA[MA(30)]]></name>
10           <area_series>
11             <line color="%Color" thickness="1" />
12             <fill color="%Color" opacity="0.3" />
13           </area_series>
14         </ma_series>
15       </volume_ma_indicator>
16     </technical_indicator>
18 </chart>
01{
03    {
04      type: "VolumeMA",
05      dataProvider: "dpMsft",
06      volumeMaIndicator: {
07        maPeriod: 30,
08        maType: "EMA",
09        volumeSeries: {
10          type: "Bar",
11          color: "Green",
12          name: "Volume"
13        },
14        maSeries: {
15          type: "SplineArea",
16          color: "DarkRed",
17          name: "MA(30)",
18          areaSeries: {
19            line: {
20              color: "%Color",
21              thickness: 1
22            },
23            fill: {
24              color: "%Color",
25              opacity: 0.3
26            }
27          }
28        }
29      }
30    }
31  ]
32}

Live sample below shows settings shown above:

Live Sample:  Technical Indicators - VolumeMA Visualization Settings

to top