Gallery
Price Action Indicator
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender,EventArgs e)
{
// Demonstrates the use of financial indicators AveragePrice and PriceActionIndicator
// The Financial Chart
FinancialChart.Title="Company X Stock Price";
FinancialChart.TempDirectory="temp";
FinancialChart.Debug=true;
FinancialChart.LegendBox.Template ="%icon %name";
FinancialChart.Size="800X400";
FinancialChart.YAxis.Label.Text = "Price (USD)";
FinancialChart.YAxis.FormatString = "currency";
FinancialChart.YAxis.Scale = Scale.Range;
FinancialChart.DefaultSeries.DefaultElement.Marker.Visible = false;
FinancialChart.DefaultSeries.Type = SeriesType.Spline;
FinancialChart.ChartAreaLayout.Mode = ChartAreaLayoutMode.Vertical;
// Modify the x axis labels.
FinancialChart.XAxis.Scale = Scale.Time;
FinancialChart.XAxis.TimeInterval = TimeInterval.Week;
//FinancialChart.XAxis.TimeScaleLabels.DayFormatString = "o";
FinancialChart.XAxis.TimeScaleLabels.RangeIntervals.Add(TimeInterval.Month);
FinancialChart.XAxis.TimeScaleLabels.MonthFormatString = "MMM";
DataEngine priceDataEngine = new DataEngine ();
priceDataEngine.ChartObject = FinancialChart;
priceDataEngine.ChartType = ChartType.Financial;
priceDataEngine.ConnectionString = ConfigurationManager.AppSettings["DNCConnectionString"];
priceDataEngine.DateGrouping = TimeInterval.Day;
priceDataEngine.StartDate = new DateTime (2021,12,31,0,0,0);
priceDataEngine.EndDate = new DateTime (2022,2,28,23,59,59);
// Here we import data from the FinancialCompany table from within chartsample.mdb
priceDataEngine.SqlStatement = @"SELECT TransDate, HighPrice, LowPrice, OpenPrice, ClosePrice FROM FinancialCompany WHERE TransDate >= #STARTDATE# AND TransDate <= #ENDDATE# ORDER BY TransDate ";
priceDataEngine.DataFields = "xAxis=TransDate,High=HighPrice,Low=LowPrice,Open=OpenPrice,Close=ClosePrice";
SeriesCollection sc = priceDataEngine.GetSeries ();
Series prices = null;
if(sc.Count>0)
prices = sc[0];
else
return;
prices.Name = "Prices";
prices.DefaultElement.ShowValue=false;
prices.DefaultElement.ToolTip="L:%Low | H:%High";
prices.DefaultElement.SmartLabel.Text="O:%Open | C:%Close";
prices.Type = SeriesTypeFinancial.Bar;
CalendarPattern cp = new CalendarPattern (TimeInterval.Day, TimeInterval.Week, "0000001");
prices.Trim (cp, ElementValue.XDateTime);
FinancialChart.SeriesCollection.Add (prices);
// AveragePrice financial indicator which is arithmetic average of the High, Low, Close and Open price
// for a trading day.
Series averagePrice = FinancialEngine.AveragePrice(prices);
averagePrice.DefaultElement.Color = Color.FromArgb(49,99,49);
FinancialChart.SeriesCollection.Add (averagePrice);
// Create a new chart area for the Price Action Indicator(PAIN).
ChartArea painChartArea = new ChartArea ("Price Action Indicator");
painChartArea.HeightPercentage = 20;
painChartArea.YAxis = new Axis();
FinancialChart.ExtraChartAreas.Add(painChartArea);
// PriceActionIndicator financial indicator which has the following formula:
// PAIN = ((Close-Open)+(Close-High)+(Close-Low))/2.
Series priceActionIndicator = FinancialEngine.PriceActionIndicator(prices);
priceActionIndicator.DefaultElement.Color = Color.FromArgb(126,125,255);
painChartArea.SeriesCollection.Add (priceActionIndicator);
}
</script>
</head>
<body>
<div style="text-align:center">
<dotnet:Chart id="FinancialChart" runat="server"/>
</div>
</body>
</html>
<%@ 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 xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates the use of financial indicators AveragePrice and PriceActionIndicator
' The Financial Chart
FinancialChart.Title="Company X Stock Price"
FinancialChart.TempDirectory="temp"
FinancialChart.Debug=True
FinancialChart.LegendBox.Template ="%icon %name"
FinancialChart.Size="800X400"
FinancialChart.YAxis.Label.Text = "Price (USD)"
FinancialChart.YAxis.FormatString = "currency"
FinancialChart.YAxis.Scale = Scale.Range
FinancialChart.DefaultSeries.DefaultElement.Marker.Visible = False
FinancialChart.DefaultSeries.Type = SeriesType.Spline
FinancialChart.ChartAreaLayout.Mode = ChartAreaLayoutMode.Vertical
' Modify the x axis labels.
FinancialChart.XAxis.Scale = Scale.Time
FinancialChart.XAxis.TimeInterval = TimeInterval.Week
'FinancialChart.XAxis.TimeScaleLabels.DayFormatString = "o";
FinancialChart.XAxis.TimeScaleLabels.RangeIntervals.Add(TimeInterval.Month)
FinancialChart.XAxis.TimeScaleLabels.MonthFormatString = "MMM"
Dim priceDataEngine As DataEngine = New DataEngine ()
priceDataEngine.ChartObject = FinancialChart
priceDataEngine.ChartType = ChartType.Financial
priceDataEngine.ConnectionString = ConfigurationManager.AppSettings("DNCConnectionString")
priceDataEngine.DateGrouping = TimeInterval.Day
priceDataEngine.StartDate = New DateTime (2021,12,31,0,0,0)
priceDataEngine.EndDate = New DateTime (2022,2,28,23,59,59)
' Here we import data from the FinancialCompany table from within chartsample.mdb
priceDataEngine.SqlStatement = "SELECT TransDate, HighPrice, LowPrice, OpenPrice, ClosePrice FROM FinancialCompany WHERE TransDate >= #STARTDATE# AND TransDate <= #ENDDATE# ORDER BY TransDate "
priceDataEngine.DataFields = "xAxis=TransDate,High=HighPrice,Low=LowPrice,Open=OpenPrice,Close=ClosePrice"
Dim sc As SeriesCollection = priceDataEngine.GetSeries ()
Dim prices As Series = Nothing
If sc.Count>0 Then
prices = sc(0)
Else
Return
End If
prices.Name = "Prices"
prices.DefaultElement.ShowValue=False
prices.DefaultElement.ToolTip="L:%Low | H:%High"
prices.DefaultElement.SmartLabel.Text="O:%Open | C:%Close"
prices.Type = SeriesTypeFinancial.Bar
Dim cp As CalendarPattern = New CalendarPattern (TimeInterval.Day, TimeInterval.Week, "0000001")
prices.Trim (cp, ElementValue.XDateTime)
FinancialChart.SeriesCollection.Add (prices)
' AveragePrice financial indicator which is arithmetic average of the High, Low, Close and Open price
' for a trading day.
Dim averagePrice As Series = FinancialEngine.AveragePrice(prices)
averagePrice.DefaultElement.Color = Color.FromArgb(49,99,49)
FinancialChart.SeriesCollection.Add (averagePrice)
' Create a new chart area for the Price Action Indicator(PAIN).
Dim painChartArea As ChartArea = New ChartArea ("Price Action Indicator")
painChartArea.HeightPercentage = 20
painChartArea.YAxis = New Axis()
FinancialChart.ExtraChartAreas.Add(painChartArea)
' PriceActionIndicator financial indicator which has the following formula:
' PAIN = ((Close-Open)+(Close-High)+(Close-Low))/2.
Dim priceActionIndicator As Series = FinancialEngine.PriceActionIndicator(prices)
priceActionIndicator.DefaultElement.Color = Color.FromArgb(126,125,255)
painChartArea.SeriesCollection.Add (priceActionIndicator)
End Sub
</script>
</head>
<body>
<div style="text-align:center">
<dotnet:Chart id="FinancialChart" runat="server"/>
</div>
</body>
</html>
- Sample FilenamePriceActionIndicator.aspx
- Version3.4
- Uses DatabaseYes