⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stochastic.aspx

📁 掌握学习.net开发的非常好的资料
💻 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 Stochastic Sample</TITLE>
		<script runat="server">


Sub Page_Load(sender As [Object], e As EventArgs)
   
   ' This sample demonstrates the use of the K% Stochastic and D% Stochastic
   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 = "Financial Chart"
   FinancialChart.TempDirectory = "temp"
   FinancialChart.Debug = True
   FinancialChart.ShadingEffect = True
   FinancialChart.LegendBox.Template = "%icon %name"
   FinancialChart.Size = "800X600"
   FinancialChart.XAxis.Scale = Scale.Time
   FinancialChart.XAxis.FormatString = "MMM d"
   FinancialChart.XAxis.TimeInterval = TimeInterval.Day
   FinancialChart.YAxis.Label.Text = "Price (USD)"
   FinancialChart.YAxis.FormatString = "currency"
   FinancialChart.YAxis.ScaleRange.ValueLow = 11
   FinancialChart.PaletteName=Palette.Three
   
   ' Here we load data samples from the FinancialDELL 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, 8, 1)
   priceDataEngine.EndDate = New DateTime(2001, 9, 30)
   priceDataEngine.SqlStatement = "SELECT [Date], [High], [Low],[Open],[Close] FROM FinancialDELL WHERE Date >= #STARTDATE# AND Date <= #ENDDATE# ORDER BY Date "
   priceDataEngine.DataFields = "xAxis=Date,High=High,Low=Low,Open=Open,Close=Close"
   
   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.ShowValue = True
   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, 8, 1)
   volumeDataEngine.EndDate = New DateTime(2001, 9, 30)
   volumeDataEngine.SqlStatement = "SELECT [date],[volume] FROM FinancialDELL WHERE date >= #STARTDATE# AND date <= #ENDDATE# ORDER BY Date"
   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)
   
   FinancialChart.DefaultSeries.DefaultElement.Marker = New ElementMarker(ElementMarkerType.None)
   FinancialChart.ChartAreaLayout.Mode = ChartAreaLayoutMode.Vertical
   FinancialChart.DefaultSeries.Type = SeriesType.Spline
   
   ' Here we display the financial exponentially moving average for the prices series over five days
   FinancialChart.SeriesCollection.Add(FinancialEngine.ExponentiallyWeightedMovingAverage(prices, ElementValue.High, 0.2, 5))
   ' Here we display the statistical exponentially moving average for the Volumes Series over five days
   volumeChartArea.SeriesCollection.Add(StatisticalEngine.ExponentiallyWeightedMovingAverage(volumes, 0.2, 5))
   
   ' Create a new chart area for KFastStochastic and DStochastic.
   Dim stochasticChartArea As New ChartArea("Stochastic")
   stochasticChartArea.HeightPercentage = 20
   stochasticChartArea.YAxis = New Axis()
   FinancialChart.ExtraChartAreas.Add(stochasticChartArea)
   
   ' Here we display the kFastStochastic over a period of ten days for the Prices Series
   Dim kFast As Series = FinancialEngine.KFastStochastic(prices, 10)
   kFast.Type = SeriesType.Spline
   kFast.DefaultElement.Color = Color.FromArgb(255, 99, 49)
   If kFast.Elements.Count > 0 Then
      stochasticChartArea.SeriesCollection.Add(kFast)
   Else
      Console.WriteLine("The series kfast is empty")
   End If 
   ' Here we display the DStochastic over a period of ten days.
   ' For the calculation of DStochastic we use ExponentiallyMovingAverage over 5 days.
   Dim dStochastic As Series = FinancialEngine.DStochastic(prices, 10, 4, 5)
   dStochastic.Type = SeriesType.Spline
   dStochastic.DefaultElement.Color = Color.FromArgb(0, 255, 0)
   If dStochastic.Elements.Count > 0 Then
      stochasticChartArea.SeriesCollection.Add(dStochastic)
   Else
      Console.WriteLine("The series dStochastic is empty")
   End If 
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 + -