private void LoadData() { DataAccess.Libs.ClearAnalysisDataCache(myData); myData.LoadData(); pricePane.myGraphObj.myOnViewportChanged += new Charts.Controls.myGraphControl.OnViewportChanged(this.Chart_OnViewportChanged); volumePanel.myGraphObj.myOnViewportChanged += new Charts.Controls.myGraphControl.OnViewportChanged(this.Chart_OnViewportChanged); pricePane.myGraphObj.myOnPointValue += new Charts.Controls.myGraphControl.OnPointValue(PointValueEventPrice); volumePanel.myGraphObj.myOnPointValue += new Charts.Controls.myGraphControl.OnPointValue(PointValueEventPrice); pricePane.myGraphObj.myGraphPane.CurveList.Clear(); pricePane.myGraphObj.SetSeriesX(myData.DateTime.Values, Charts.AxisType.DateAsOrdinal); switch (cbChartType.myValue) { case AppTypes.ChartTypes.CandleStick: candleCurve = pricePane.myGraphObj.AddCandleStick(myData.DataStockCode, myData.High.Values, myData.Low.Values, myData.Open.Values, myData.Close.Values, myData.Volume.Values, commonClass.Settings.sysChartBarUpColor, commonClass.Settings.sysChartBarDnColor, commonClass.Settings.sysChartBullCandleColor, commonClass.Settings.sysChartBearCandleColor); break; case AppTypes.ChartTypes.Line: lineCurve = pricePane.myGraphObj.AddCurveLine(myData.DataStockCode, myData.Close.Values, SymbolType.Circle, Color.Blue, 1); break; case AppTypes.ChartTypes.Bar: barCurve = pricePane.myGraphObj.AddCurveBar(myData.DataStockCode, myData.Close.Values, Color.Blue, Color.Blue, 1); break; } pricePane.myGraphObj.SetFont(14); pricePane.myGraphObj.DefaultViewport(); pricePane.myGraphObj.UpdateChart(); volumePanel.myGraphObj.myGraphPane.CurveList.Clear(); volumePanel.myGraphObj.SetSeriesX(myData.DateTime.Values, Charts.AxisType.DateAsOrdinal); barCurve = volumePanel.myGraphObj.AddCurveBar(myData.DataStockCode, myData.Volume.Values, Color.Navy, Color.Green, 1); volumePanel.myGraphObj.SetFont(14); volumePanel.myGraphObj.DefaultViewport(); volumePanel.myGraphObj.UpdateChart(); }
/// <summary> /// Add a japanesecandlestick graph (<see cref="JapaneseCandleStickItem"/> object) to the plot with /// the given data points (<see cref="IPointList"/>) and properties. /// </summary> /// <remarks> /// This is simplified way to add curves without knowledge of the /// <see cref="CurveList"/> class. An alternative is to use /// the <see cref="ZedGraph.CurveList" /> Add() method. /// Note that the <see cref="IPointList" /> /// should contain <see cref="StockPt" /> objects instead of <see cref="PointPair" /> /// objects in order to contain all the data values required for this curve type. /// </remarks> /// <param name="label">The text label (string) for the curve that will be /// used as a <see cref="Legend"/> entry.</param> /// <param name="points">A <see cref="IPointList"/> of double precision value pairs that define /// the X and Y values for this curve</param> /// <returns>A <see cref="CurveItem"/> class for the newly created curve. /// This can then be used to access all of the curve properties that /// are not defined as arguments to the /// <see cref="AddJapaneseCandleStick(string,IPointList)"/> method.</returns> public JapaneseCandleStickItem AddJapaneseCandleStick( string label, IPointList points ) { JapaneseCandleStickItem curve = new JapaneseCandleStickItem( label, points ); _curveList.Add( curve ); return curve; }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="JapaneseCandleStickItem"/> object from which to copy</param> public JapaneseCandleStickItem(JapaneseCandleStickItem rhs) : base(rhs) { _stick = rhs._stick.Clone(); }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="JapaneseCandleStickItem" /> object from which to copy</param> public JapaneseCandleStickItem(JapaneseCandleStickItem rhs) : base(rhs) { }
/// <summary> /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/> /// device as a candlestick at each defined point. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void Draw( Graphics g, GraphPane pane, JapaneseCandleStickItem curve, Axis baseAxis, Axis valueAxis, float scaleFactor) { //ValueHandler valueHandler = new ValueHandler( pane, false ); if (curve.Points == null) { return; } //float halfSize = _size * scaleFactor; var halfSize = GetBarWidth(pane, baseAxis, scaleFactor); var tColor = _color; var tFallingColor = _fallingColor; var tPenWidth = _width; var tRisingFill = _risingFill; var tFallingFill = _fallingFill; var tRisingBorder = _risingBorder; var tFallingBorder = _fallingBorder; if (curve.IsSelected) { tColor = Selection.Border.Color; tFallingColor = Selection.Border.Color; tPenWidth = Selection.Border.Width; tRisingFill = Selection.Fill; tFallingFill = Selection.Fill; tRisingBorder = Selection.Border; tFallingBorder = Selection.Border; } using (var risingPen = new Pen(tColor, tPenWidth)) using (var fallingPen = new Pen(tFallingColor, tPenWidth)) // Loop over each defined point for (var i = 0; i < curve.Points.Count; i++) { var pt = curve.Points[i]; var date = pt.X; var high = pt.Y; var low = pt.Z; var open = PointPairBase.Missing; var close = PointPairBase.Missing; if (pt is StockPt) { open = (pt as StockPt).Open; close = (pt as StockPt).Close; } // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if (curve.Points[i].IsInvalid3D || (date <= 0 && baseAxis._scale.IsLog) || ((high <= 0 || low <= 0) && valueAxis._scale.IsLog)) { continue; } float pixBase = (int)(baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date) + 0.5); //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date ); var pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high); var pixLow = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low); var pixOpen = PointPairBase.IsValueInvalid(open) ? Single.MaxValue : valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open); var pixClose = PointPairBase.IsValueInvalid(close) ? Single.MaxValue : valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close); if (!curve.IsSelected && _gradientFill.IsGradientValueType) { using (var tPen = GetPen(pane, scaleFactor, pt)) Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, (tPen), (close > open ? tRisingFill : tFallingFill), (close > open ? tRisingBorder : tFallingBorder), pt); } else { Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, (close > open ? risingPen : fallingPen), (close > open ? tRisingFill : tFallingFill), (close > open ? tRisingBorder : tFallingBorder), pt); } } }
/// <summary> /// Create a new curve item /// </summary> public CurveItem CreateCurveItem(Series series) { CurveItem item = null; switch (series.SeriesType) { case SeriesType.Candle: JapaneseCandleStickItem candle = new JapaneseCandleStickItem(series.Name, new StockPointList()); candle.Stick.IsAutoSize = true; candle.Stick.Color = Color.FromArgb(46, 56, 59); candle.Stick.RisingFill = new Fill(Color.FromArgb(140, 193, 118)); candle.Stick.FallingFill = new Fill(Color.FromArgb(184, 44, 12)); item = candle; break; case SeriesType.Line: LineItem line = new LineItem(series.Name, new DateTimePointList(), Color.DarkBlue, SymbolType.None); item = line; break; case SeriesType.Scatter: LineItem scatter = new LineItem(series.Name, new DateTimePointList(), Color.Black, SymbolType.Circle); scatter.Line = new Line(); scatter.Line.IsVisible = false; scatter.Symbol.Size = 10; scatter.Symbol.Fill = new Fill(Color.LightGreen); item = scatter; break; } return item; }
/// <summary> /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/> /// device as a candlestick at each defined point. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void Draw( Graphics g, GraphPane pane, JapaneseCandleStickItem curve, Axis baseAxis, Axis valueAxis, float scaleFactor ) { //ValueHandler valueHandler = new ValueHandler( pane, false ); float pixBase, pixHigh, pixLow, pixOpen, pixClose; if ( curve.Points != null ) { //float halfSize = _size * scaleFactor; float halfSize = GetBarWidth( pane, baseAxis, scaleFactor ); Color tColor = _color; Color tFallingColor = _fallingColor; float tPenWidth = _width; Fill tRisingFill = _risingFill; Fill tFallingFill = _fallingFill; Border tRisingBorder = _risingBorder; Border tFallingBorder = _fallingBorder; if ( curve.IsSelected ) { tColor = Selection.Border.Color; tFallingColor = Selection.Border.Color; tPenWidth = Selection.Border.Width; tRisingFill = Selection.Fill; tFallingFill = Selection.Fill; tRisingBorder = Selection.Border; tFallingBorder = Selection.Border; } using ( Pen risingPen = new Pen( tColor, tPenWidth ) ) using ( Pen fallingPen = new Pen( tFallingColor, tPenWidth ) ) { // Loop over each defined point for ( int i = 0; i < curve.Points.Count; i++ ) { PointPair pt = curve.Points[i]; double date = pt.X; double high = pt.Y; double low = pt.Z; double open = PointPair.Missing; double close = PointPair.Missing; if ( pt is StockPt ) { open = ( pt as StockPt ).Open; close = ( pt as StockPt ).Close; } // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if ( !curve.Points[i].IsInvalid3D && ( date > 0 || !baseAxis._scale.IsLog ) && ( ( high > 0 && low > 0 ) || !valueAxis._scale.IsLog ) ) { pixBase = (int) ( baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date ) + 0.5 ); //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date ); pixHigh = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, high ); pixLow = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, low ); if ( PointPair.IsValueInvalid( open ) ) pixOpen = Single.MaxValue; else pixOpen = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, open ); if ( PointPair.IsValueInvalid( close ) ) pixClose = Single.MaxValue; else pixClose = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, close ); if ( !curve.IsSelected && this._gradientFill.IsGradientValueType ) { using ( Pen tPen = GetPen( pane, scaleFactor, pt ) ) Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, ( tPen ), ( close > open ? tRisingFill : tFallingFill ), ( close > open ? tRisingBorder : tFallingBorder ), pt ); } else Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, ( close > open ? risingPen : fallingPen ), ( close > open ? tRisingFill : tFallingFill ), ( close > open ? tRisingBorder : tFallingBorder ), pt ); } } } } }
/// <summary> /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/> /// device as a candlestick at each defined point. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void Draw(Graphics g, GraphPane pane, JapaneseCandleStickItem curve, Axis baseAxis, Axis valueAxis, float scaleFactor) { //ValueHandler valueHandler = new ValueHandler( pane, false ); float pixBase, pixHigh, pixLow, pixOpen, pixClose; if (curve.Points != null) { Pen pen = new Pen(_color, _penWidth); //float halfSize = _size * scaleFactor; float halfSize = GetBarWidth(pane, baseAxis, scaleFactor); // Loop over each defined point for (int i = 0; i < curve.Points.Count; i++) { IPointPair pt = curve.Points[i]; double date = pt.X; double high = pt.Y; double low = pt.Z; double open = PointPair.Missing; double close = PointPair.Missing; if (pt is StockPt) { open = (pt as StockPt).Open; close = (pt as StockPt).Close; } // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if (!curve.Points[i].IsInvalid3D && (date > 0 || !baseAxis._scale.IsLog) && ((high > 0 && low > 0) || !valueAxis._scale.IsLog)) { pixBase = baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date); pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high); pixLow = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low); if (PointPair.IsValueInvalid(open)) { pixOpen = Single.MaxValue; } else { pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open); } if (PointPair.IsValueInvalid(close)) { pixClose = Single.MaxValue; } else { pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close); } Draw(g, pane, baseAxis is XAxis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, pen, (close > open ? _risingFill : _fallingFill), (close > open ? _risingBorder : _fallingBorder), pt); } } } }
/// <summary> /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/> /// device as a candlestick at each defined point. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void Draw(IGraphics g, GraphPane pane, JapaneseCandleStickItem curve, Axis baseAxis, Axis valueAxis, float scaleFactor) { //ValueHandler valueHandler = new ValueHandler( pane, false ); float pixBase, pixHigh, pixLow, pixOpen, pixClose; if (curve.Points != null) { //float halfSize = _size * scaleFactor; float halfSize = GetBarWidth(pane, baseAxis, scaleFactor); Color tColor = _color; Color tFallingColor = _fallingColor; float tPenWidth = _width; Fill tRisingFill = _risingFill; Fill tFallingFill = _fallingFill; Border tRisingBorder = _risingBorder; Border tFallingBorder = _fallingBorder; if (curve.IsSelected) { tColor = Selection.Border.Color; tFallingColor = Selection.Border.Color; tPenWidth = Selection.Border.Width; tRisingFill = Selection.Fill; tFallingFill = Selection.Fill; tRisingBorder = Selection.Border; tFallingBorder = Selection.Border; } using (Pen risingPen = new Pen(tColor, tPenWidth)) using (Pen fallingPen = new Pen(tFallingColor, tPenWidth)) { // Loop over each defined point for (int i = 0; i < curve.Points.Count; i++) { PointPair pt = curve.Points[i]; double date = pt.X; double high = pt.Y; double low = pt.Z; double open = PointPair.Missing; double close = PointPair.Missing; if (pt is StockPt) { open = (pt as StockPt).Open; close = (pt as StockPt).Close; } // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if (!curve.Points[i].IsInvalid3D && (date > 0 || !baseAxis._scale.IsLog) && ((high > 0 && low > 0) || !valueAxis._scale.IsLog)) { pixBase = (int)(baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date) + 0.5); //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date ); pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high); pixLow = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low); if (PointPair.IsValueInvalid(open)) { pixOpen = Single.MaxValue; } else { pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open); } if (PointPair.IsValueInvalid(close)) { pixClose = Single.MaxValue; } else { pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close); } if (!curve.IsSelected && this._gradientFill.IsGradientValueType) { using (Pen tPen = GetPen(pane, scaleFactor, pt)) Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, (tPen), (close > open ? tRisingFill : tFallingFill), (close > open ? tRisingBorder : tFallingBorder), pt); } else { Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, (close > open ? risingPen : fallingPen), (close > open ? tRisingFill : tFallingFill), (close > open ? tRisingBorder : tFallingBorder), pt); } } } } } }
/// <summary> /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/> /// device as a candlestick at each defined point. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="JapaneseCandleStick"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void Draw(Graphics g, GraphPane pane, JapaneseCandleStickItem curve, Axis baseAxis, Axis valueAxis, float scaleFactor) { //ValueHandler valueHandler = new ValueHandler( pane, false ); float pixBase, pixHigh, pixLow, pixOpen, pixClose; if (curve.Points != null) { //float halfSize = _size * scaleFactor; float halfSize = GetBarWidth(pane, baseAxis, scaleFactor); using (var risingPen = new Pen(_color, _penWidth)) using (var fallingPen = new Pen(_fallingColor, _penWidth)) { // Loop over each defined point for (int i = 0; i < curve.Points.Count; i++) { PointPair pt = curve.Points[i]; double date = pt.X; double high = pt.Y; double low = pt.Z; double open = PointPair.Missing; double close = PointPair.Missing; if (pt is StockPt) { open = (pt as StockPt).Open; close = (pt as StockPt).Close; } // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if (!curve.Points[i].IsInvalid3D && (date > 0 || !baseAxis._scale.IsLog) && ((high > 0 && low > 0) || !valueAxis._scale.IsLog)) { pixBase = baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date); pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high); pixLow = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low); if (PointPair.IsValueInvalid(open)) pixOpen = Single.MaxValue; else pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open); if (PointPair.IsValueInvalid(close)) pixClose = Single.MaxValue; else pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close); Draw(g, pane, baseAxis is XAxis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, (close > open ? risingPen : fallingPen), (close > open ? _risingFill : _fallingFill), (close > open ? _risingBorder : _fallingBorder), pt); } } } } }
public static void GetRangeY(JapaneseCandleStickItem curve, int fromId, int toId, ref ValueRange yRange) { for (int idx = fromId; idx <= toId; idx++) { StockPt item = (StockPt)curve.Points[idx]; if (item.Low < yRange.Min) yRange.Min = item.Low; if (item.High > yRange.Max) yRange.Max = item.High; } }
public void CreateGraph( ZedGraphControl zgc, StockPointList stlist, StockPointList ema11Plist,StockPointList ema22Plist) { GraphPane myPane = zgc.GraphPane; #region 初始化 myPane.Title.Text = "小日經 30分鐘"; myPane.XAxis.Title.Text = ""; myPane.YAxis.Title.Text = ""; myPane.XAxis.Type = AxisType.Date; myPane.XAxis.Scale.Format = "MM/dd HH:mm"; myPane.XAxis.Scale.FontSpec.Size = 12; myPane.XAxis.Scale.MajorUnit = DateUnit.Minute; myPane.XAxis.Scale.MajorStep = 30; myPane.XAxis.Scale.MinorUnit = DateUnit.Minute; myPane.XAxis.Scale.MinorStep = 10; myPane.YAxis.Scale.MagAuto = false; myPane.CurveList.numBarsToFocus = m_numBarFocused; #endregion #region K 棒繪製 : Once jpnCandle = myPane.AddJapaneseCandleStick("", stlist); jpnCandle.Stick.IsAutoSize = true; // 下跌K jpnCandle.Stick.FallingFill = new Fill(Color.Green); jpnCandle.Stick.FallingColor = Color.Green; jpnCandle.Stick.FallingBorder = new Border(false, Color.Green, 0); // 上漲K jpnCandle.Stick.RisingFill = new Fill(Color.Red); jpnCandle.Stick.Color = Color.Red; jpnCandle.Stick.RisingBorder = new Border(false, Color.Green, 0); #endregion #region 背景 : Once myPane.Chart.Fill = new Fill(Color.Black); // Color.LightGoldenrodYellow, 45F myPane.Fill = new Fill(Color.White); //, Color.FromArgb( 0, 0, 255 ), 45F myPane.XAxis.Type = AxisType.DateAsOrdinal; myPane.Chart.Fill = new Fill(Color.Black); #endregion #region Range 更新 : Once //左右Range XDate Min = new XDate(2015, 2, 25, 0, 0, 0, 0); XDate Max = new XDate(2015, 2, 26, 0, 0, 0, 0); myPane.XAxis.Scale.Min = Min; myPane.XAxis.Scale.Max = Max; //上下Range int min_rr = 16000; int max_rr = 19000; myPane.YAxis.Scale.Min = min_rr; myPane.YAxis.Scale.Max = max_rr; #endregion zgc.AxisChange(); zgc.Invalidate(); }