Features

Overlays

Overlays

Overlays, like technical indicators, are a set of derived data that is calculated by applying one or more formulas to the original set of data.

Features

Chart Types
Interaction
Analytics
BOXBollinger Bands01/23/1501/27/1501/29/1502/02/1502/04/1502/06/1502/10/1502/12/1502/17/1502/19/1502/23/1502/25/1502/27/1503/03/1503/05/1503/09/1503/11/1503/13/1503/17/1503/19/1503/23/1503/25/1503/27/1503/31/1504/02/1504/07/1504/09/1504/13/1504/15/1504/17/1504/21/1504/23/1504/27/1504/29/1505/01/1505/05/1505/07/1505/11/1505/13/1505/15/1505/19/1505/21/1505/26/1505/28/1520

Settings

Description

Overlays, like technical indicators, are a set of derived data that is calculated by applying one or more formulas to the original set of data. Overlays are generally used to forecast an asset's market direction and generally plotted with the original data set since the the Y-axis scales are the same.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using FinancialChartExplorer.Models;
using System.Collections.Generic;
using System.Web.Mvc;
 
namespace FinancialChartExplorer.Controllers
{
    public partial class HomeController : Controller
    {
        //
        // GET: /Overlays/
        public ActionResult Overlays()
        {
            var model = BoxData.GetDataFromJson();
            return View(model);
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
@using FinancialChartExplorer.Models
 
@model List<FinanceData>
@{
    ViewBag.DemoSettings = true;
    var overlays = new List<AnalysisType> {
        new AnalysisType{Name = "Bollinger Bands", Abbreviation = "bollinger"},
        new AnalysisType{Name = "Envelopes", Abbreviation = "envelopes" }
    };
}
 
<script type="text/javascript">
    var overlayOpts = [@Html.Raw(string.Join(",", overlays.Select(ovl => "'" + ovl.Abbreviation + "'")))];
 
    function showOption(overlay) {
        for (var i = 0; i < overlayOpts.length; i++) {
            toggleGroup(overlayOpts[i], overlayOpts[i] == overlay);
        }
    }
 
    function toggleGroup(overlay, shown) {
        var optGroup = wijmo.getElement('#' + overlay);
        if (optGroup) {
            if (shown) {
                optGroup.style.display = '';
            } else {
                optGroup.style.display = 'none';
            }
        }
    }
 
    function showSeries(index) {
        var chart = wijmo.Control.getControl('#overlays');
 
        if (index == null || !chart) {
            return;
        }
 
        for (var i = 1; i < chart.series.length; i++) {
            chart.series[i].visibility = (index == i) ? wijmo.chart.SeriesVisibility.Visible : wijmo.chart.SeriesVisibility.Hidden;
        }
    }
 
    function updateOverlayType(combo) {
        showSeries(combo.selectedIndex + 1);
        showOption(combo.selectedValue);
    }
 
    function updateBBPeriod(number) {
        var chart = wijmo.Control.getControl('#overlays');
        if (!checkValue(number)) {
            return;
        }
        if (chart) {
            chart.series[1].period = number.value;
        }
    }
 
    function updateBBMultiplier(number) {
        var chart = wijmo.Control.getControl('#overlays');
        if (!checkValue(number)) {
            return;
        }
        if (chart) {
            chart.series[1].multiplier = number.value;
        }
    }
 
    function updateEnvelopePeriod(number) {
        var chart = wijmo.Control.getControl('#overlays');
        if (!checkValue(number)) {
            return;
        }
        if (chart) {
            chart.series[2].period = number.value;
        }
    }
 
    function updateEnvelopeSize(number) {
        var chart = wijmo.Control.getControl('#overlays');
        if (!checkValue(number)) {
            return;
        }
        if (chart) {
            chart.series[2].size = number.value;
        }
    }
 
    function envelopeTypeChanged(menu) {
        var chart = wijmo.Control.getControl('#overlays');
 
        menu.header = 'Type: <b>' + menu.selectedItem.Header + '</b>';
        if (chart) {
            chart.series[2].type = wijmo.chart.finance.analytics.MovingAverageType[menu.selectedItem.CommandParameter];
        }
    }
 
    function checkValue(number) {
        return number.value >= number.min && number.value <= number.max;
    }
 
    c1.documentReady(function () {
        var combo = wijmo.Control.getControl('#overlayComboBox');
        if (combo) {
            combo.selectedIndex = 0;
            updateOverlayType(combo);
        }
    });
</script>
 
 
@(Html.C1().FinancialChart()
.Id("overlays")
.Bind(Model)
.BindingX("X")
.SymbolSize(6)
.ChartType(C1.Web.Mvc.Finance.ChartType.Candlestick)
.Series(sers =>
    {
        sers.Add().Binding("High,Low,Open,Close").Name("BOX");
        sers.AddBollingerBands().Binding("Close").Period(20).Multiplier(2).Name("Bollinger Bands");
        sers.AddEnvelopes().Binding("Close").Period(20).Size(0.03).Type(C1.Web.Mvc.Finance.MovingAverageType.Simple).Name("Envelopes").Visibility(C1.Web.Mvc.Chart.SeriesVisibility.Hidden);
    })
.Tooltip(t => t.Content("tooltip")))
 
@section Settings{
<div class="panel-body">
    <!-- Overlay Selector -->
    <ul class="list-inline">
        <li>
            <label>Overlay</label>
            @(Html.C1().ComboBox().Id("overlayComboBox").Bind(overlays).SelectedValuePath("Abbreviation").DisplayMemberPath("Name").OnClientSelectedIndexChanged("updateOverlayType").IsEditable(false))
        </li>
    </ul>
 
    <!-- Bollinger Bands Properties -->
    <ul class="list-inline" id="bollinger">
        <li>
            <label>Period</label>
            @(Html.C1().InputNumber().Value(20).Min(2).Step(1).Max((Model.Count - 1)).Format("n0").OnClientValueChanged("updateBBPeriod"))
        </li>
        <li>
            <label>Multiplier</label>
            @(Html.C1().InputNumber().Value(2).Min(1).Step(1).Max(100).Format("n0").OnClientValueChanged("updateBBMultiplier"))
        </li>
    </ul>
 
    <!-- Envelope Properties -->
    <ul class="list-inline" id="envelopes">
        <li>
            <label>Period</label>
            @(Html.C1().InputNumber().Value(20).Min(2).Step(1).Max((Model.Count - 1)).Format("n0").OnClientValueChanged("updateEnvelopePeriod"))
        </li>
        <li>
            <label>Size</label>
            @(Html.C1().InputNumber().Value(0.03).Min(0).Step(0.01).Max(1).Format("p0").OnClientValueChanged("updateEnvelopeSize"))
        </li>
        <li>
            @(Html.C1().Menu().Header("Type: <b>Simple</b>")
            .MenuItems(mifb =>
            {
                mifb.Add().Header("Simple").CommandParameter("Simple");
                mifb.Add().Header("Exponential").CommandParameter("Exponential");
            })
            .OnClientItemClicked("envelopeTypeChanged"))
        </li>
    </ul>
</div>
}
 
@section Description{
    <p>
        Overlays, like technical indicators, are a set of derived data that is calculated by applying one or more formulas to the original set of data. Overlays are generally used to forecast an asset's market direction and generally plotted with the original data set since the the Y-axis scales are the same.
    </p>
}
@section Summary{
    <p>
        Overlays, like technical indicators, are a set of derived data that is calculated by applying one or more formulas to the original set of data.
    </p>
}