📄 marketfacilitationindex.aspx
字号:
<%@ Page Language="VB" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING"%>
<HTML>
<HEAD>
<TITLE>.netCHARTING Financial Market Indicators Sample</TITLE>
<script runat="server">
Sub Page_Load(sender As [Object], e As EventArgs)
' This sample demonstrates the use of the Market Facilitation Index indicator
Dim connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("../../database/chartsample.mdb")
' First we declare a chart of type FinancialChart
' The Financial Chart
FinancialChart.Title = "Company X Stock Price"
FinancialChart.TempDirectory = "temp"
FinancialChart.Debug = True
FinancialChart.ShadingEffect = True
FinancialChart.LegendBox.Template = "%icon %name"
FinancialChart.Size = "800X500"
FinancialChart.TitleBox.Position = TitleBoxPosition.FullWithLegend
FinancialChart.XAxis.Scale = Scale.Time
FinancialChart.XAxis.FormatString = "MMM d"
FinancialChart.XAxis.TimeInterval = TimeInterval.Day
' For financial indicators the time scale is inverted (i.e. the first element of the series is the newest)
FinancialChart.XAxis.InvertScale = True
FinancialChart.YAxis.Label.Text = "Price (USD)"
FinancialChart.YAxis.FormatString = "currency"
FinancialChart.YAxis.ScaleRange.ValueLow = 40
' Here we load data samples from the FinancialMicrosoft table from within chartsample.mdb
Dim priceDataEngine As New DataEngine()
priceDataEngine.ChartType = ChartType.Financial
priceDataEngine.ConnectionString = connection
priceDataEngine.DateGrouping = TimeInterval.Day
priceDataEngine.StartDate = New DateTime(2001, 2, 1)
priceDataEngine.EndDate = New DateTime(2001, 5, 30)
priceDataEngine.SqlStatement = "SELECT [Date], [High], [Low],[Open],[Close],[Volume] FROM FinancialMicrosoft WHERE Date >= #STARTDATE# AND Date <= #ENDDATE# ORDER BY Date DESC "
priceDataEngine.DataFields = "xAxis=Date,High=High,Low=Low,Open=Open,Close=Close, Volume=Volume"
Dim sc As SeriesCollection = priceDataEngine.GetSeries()
Dim prices As Series = Nothing
If sc.Count > 0 Then
prices = sc(0)
Else
Return
End If
prices.DefaultElement.ToolTip = "L:%Low-H:%High"
prices.DefaultElement.SmartLabel.Font = New Font("Arial", 6)
prices.DefaultElement.SmartLabel.Text = "O:%Open-C:%Close"
prices.Type = SeriesTypeFinancial.CandleStick
Dim cp As New CalendarPattern(TimeInterval.Day, TimeInterval.Week, "0000001")
cp.AdjustmentUnit = TimeInterval.Day
prices.Trim(cp, ElementValue.XDateTime)
prices.Name = "Prices"
FinancialChart.SeriesCollection.Add(prices)
' Create the second chart area
Dim volumeChartArea As New ChartArea()
volumeChartArea.Label.Text = "Stock Volume"
volumeChartArea.YAxis.Label.Text = "Volumes"
volumeChartArea.Series.Name = "Stock Volume"
volumeChartArea.HeightPercentage = 17
volumeChartArea.Series.DefaultElement.ToolTip = "%YValue"
FinancialChart.ExtraChartAreas.Add(volumeChartArea)
' Add a volume series to the chart area
Dim volumeDataEngine As New DataEngine()
volumeDataEngine.ConnectionString = connection
volumeDataEngine.DateGrouping = TimeInterval.Days
volumeDataEngine.StartDate = New DateTime(2001, 2, 1)
volumeDataEngine.EndDate = New DateTime(2001, 5, 30)
volumeDataEngine.SqlStatement = "SELECT [date],[volume] FROM FinancialMicrosoft WHERE date >= #STARTDATE# AND date <= #ENDDATE# ORDER BY Date DESC"
volumeDataEngine.DataFields = "xAxis=date,yAxis=volume"
Dim volumes As Series = volumeDataEngine.GetSeries()(0)
volumes.Trim(cp, ElementValue.XDateTime)
volumes.Name = "Volumes"
volumes.Type = SeriesType.Bar
volumeChartArea.SeriesCollection.Add(volumes)
' Market Facilitation Index
FinancialChart.DefaultSeries.DefaultElement.Marker = New ElementMarker(ElementMarkerType.None)
FinancialChart.ChartAreaLayout.Mode = ChartAreaLayoutMode.Vertical
FinancialChart.DefaultSeries.Type = SeriesType.Spline
' Create a new char area for the indicator Market Facilitation Index
Dim mfiChartArea As New ChartArea()
mfiChartArea.Label.Text = "Market Facilitation Index"
mfiChartArea.YAxis = New Axis()
mfiChartArea.HeightPercentage = 20
FinancialChart.ExtraChartAreas.Add(mfiChartArea)
' Market Facilitation Index
Dim mfiSeries As Series = FinancialEngine.MarketFacilitationIndex(prices)
mfiSeries.Type = SeriesType.Spline
mfiSeries.DefaultElement.Color = Color.FromArgb(45, 125, 255)
mfiChartArea.SeriesCollection.Add(mfiSeries)
End Sub 'Page_Load
</script>
</HEAD>
<BODY>
<DIV align="center">
<dotnet:Chart id="FinancialChart" runat="server"/>
</dotnet:Chart>
</DIV>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -