OxyPlot.Series.CandleStickAndVolumeSeries.ps1

Set-StrictMode -Version 3

<#
.DESCRIPTION
This cmdlet creates an OxyPlot.Series.CandleStickAndVolumeSeries object.
 
.SYNOPSIS
 
Represents a dual view (candlestick + volume) series for OHLCV bars
 
Note that to use this series, one *must* define two y-axes, one named "Bars" and the other named
"Volume". Typically would set up the volume on StartPosition =0, EndPosition = fraction and for
the bar axis StartPosition = fraction + delta, EndPosition = 1.0.
 
See link (http://www.mathworks.com/help/toolbox/finance/highlowfts.html)
 
.PARAMETER Parent
 
Gets the parent model of the element.
 
.PARAMETER ItemsSource
Sets the items source. The default is null.
 
.PARAMETER Background
Sets the background color of the series. The default is OxyColors.Undefined.
 
This property defines the background color in the area defined by the x and y axes used by this series.
 
.PARAMETER IsVisible
Sets a value indicating whether this series is visible. The default is true.
 
.PARAMETER Title
Sets the title of the series. The default is null.
 
.PARAMETER RenderInLegend
Sets a value indicating whether the series should be rendered in the legend. The default is true.
 
.PARAMETER TrackerFormatString
Sets a format string used for the tracker. The default depends on the series.
 
The arguments for the format string may be different for each type of series. See the documentation.
 
.PARAMETER TrackerKey
Sets the key for the tracker to use on this series. The default is null.
 
This key may be used by the plot view to show a custom tracker for the series.
 
.PARAMETER MaxX
Sets the maximum x-coordinate of the dataset.
 
.PARAMETER MaxY
Sets the maximum y-coordinate of the dataset.
 
.PARAMETER MinX
Sets the minimum x-coordinate of the dataset.
 
.PARAMETER MinY
Sets the minimum y-coordinate of the dataset.
 
.PARAMETER XAxis
 
Gets the x-axis.
 
.PARAMETER XAxisKey
Sets the x-axis key. The default is null.
 
.PARAMETER YAxis
 
Gets the y-axis.
 
.PARAMETER YAxisKey
Sets the y-axis key. The default is null.
 
.PARAMETER IsXMonotonic
Sets a value indicating whether the X coordinate of all data point increases monotonically.
 
.PARAMETER WindowStartIndex
Sets the last visible window start position in the data points collection.
 
.PARAMETER Items
Sets the items of the series.
 
.PARAMETER BarAxis
 
Gets the portion of the Y axis associated with bars
 
.PARAMETER VolumeAxis
 
Gets the portion of the Y axis associated with volume
 
.PARAMETER VolumeAxisKey
Sets the volume axis key (defaults to "Volume")
 
.PARAMETER BarAxisKey
Sets the bar axis key (defaults to null, as is the primary axis).
 
.PARAMETER VolumeStyle
Sets the style of volume rendering (defaults to Combined)
 
.PARAMETER StrokeThickness
Sets the thickness of the bar lines
 
.PARAMETER StrokeIntensity
Sets the stroke intensity scale (used to generate stroke color from positive or negative color).
For example, 1.0 = same color and 0.5 is 1/2 of the intensity of the source fill color.
 
.PARAMETER SeparatorStrokeThickness
Sets the thickness of the volume / bar separator
 
.PARAMETER SeparatorLineStyle
Sets the line style for the volume / bar separator
 
.PARAMETER PositiveColor
Sets the color used when the closing value is greater than opening value or
for buying volume.
 
.PARAMETER NegativeColor
Sets the fill color used when the closing value is less than opening value or
for selling volume
 
.PARAMETER SeparatorColor
Sets the color of the separator line
 
.PARAMETER PositiveHollow
Sets a value indicating whether positive bars are shown as filled (false) or hollow (true) candlesticks
 
.PARAMETER NegativeHollow
Sets a value indicating whether negative bars are shown as filled (false) or hollow (true) candlesticks
 
.PARAMETER CandleWidth
Sets the bar width in data units (for example if the X axis is date-time based, then should
use the difference of DateTimeAxis.ToDouble(date) to indicate the width). By default candlestick
series will use 0.80 x the minimum difference in data points.
 
.PARAMETER MinimumVolume
Sets the minimum volume seen in the data series.
 
.PARAMETER MaximumVolume
Sets the maximum volume seen in the data series.
 
.PARAMETER AverageVolume
Sets the average volume seen in the data series.
 
.PARAMETER Font
Sets the font. The default is null (use OxyPlot.PlotModel.DefaultFont.
 
If the value is null, the DefaultFont of the parent PlotModel will be used.
 
.PARAMETER FontSize
Sets the size of the font. The default is double.NaN (use OxyPlot.PlotModel.DefaultFontSize).
 
If the value is NaN, the DefaultFontSize of the parent PlotModel will be used.
 
.PARAMETER FontWeight
Sets the font weight. The default is FontWeights.Normal.
 
.PARAMETER PlotModel
 
Gets the parent OxyPlot.PlotElement.PlotModel.
 
.PARAMETER Tag
Sets an arbitrary object value that can be used to store custom information about this plot element. The default is null.
 
This property is analogous to Tag properties in other Microsoft programming models. Tag is intended to provide a pre-existing property location where you can store some basic custom information about any PlotElement without requiring you to subclass an element.
 
.PARAMETER TextColor
Sets the color of the text. The default is OxyColors.Automatic (use OxyPlot.PlotModel.TextColor).
 
If the value is OxyColors.Automatic, the TextColor of the parent PlotModel will be used.
 
.PARAMETER ToolTip
Sets the tool tip. The default is null.
 
.PARAMETER ActualFont
 
Gets the actual font.
 
.PARAMETER ActualFontSize
 
Gets the actual size of the font.
 
.PARAMETER ActualFontWeight
 
Gets the actual font weight.
 
.PARAMETER ActualTextColor
 
Gets the actual color of the text.
 
.PARAMETER ActualCulture
 
Gets the actual culture.
 
The culture is defined in the parent PlotModel.
 
.PARAMETER Selectable
Sets a value indicating whether this element can be selected. The default is true.
 
.PARAMETER SelectionMode
Sets the selection mode of items in this element. The default is SelectionMode.All.
 
This is only used by the select/unselect functionality, not by the rendering.
 
.PARAMETER ActualSelectedColor
 
Gets the actual selection color.
 
.LINK
http://www.mathworks.com/help/toolbox/finance/highlowfts.html
 
 
.PARAMETER InputObject
Sets the source of the data set.
 
.PARAMETER X
Sets the column X of the data set.
 
.PARAMETER Open
Sets the column Open of the data set.
 
.PARAMETER High
Sets the column High of the data set.
 
.PARAMETER Low
Sets the column Low of the data set.
 
.PARAMETER Close
Sets the column Close of the data set.
 
.PARAMETER BuyVolume
Sets the column BuyVolume of the data set.
 
.PARAMETER SellVolume
Sets the column SellVolume of the data set.
 
.PARAMETER Group
Specifies groups to which each element of the data set belongs.
 
If this parameter is set, the data set will be grouped by these values, and multiple series will be produced for each group.
 
.PARAMETER XName
Specifies a property name of the input objects to be assigned to the column X of the data set.
 
.PARAMETER OpenName
Specifies a property name of the input objects to be assigned to the column Open of the data set.
 
.PARAMETER HighName
Specifies a property name of the input objects to be assigned to the column High of the data set.
 
.PARAMETER LowName
Specifies a property name of the input objects to be assigned to the column Low of the data set.
 
.PARAMETER CloseName
Specifies a property name of the input objects to be assigned to the column Close of the data set.
 
.PARAMETER BuyVolumeName
Specifies a property name of the input objects to be assigned to the column BuyVolume of the data set.
 
.PARAMETER SellVolumeName
Specifies a property name of the input objects to be assigned to the column SellVolume of the data set.
 
.PARAMETER GroupName
Specifies a property name of the input objects to be treated as groups.
 
If this parameter is set, the data set will be grouped by the values of this property, and multiple series will be produced for each group.
 
.PARAMETER GroupingKeys
Specifies effective groups and these order.
 
This option is useful when you will select groups, or specify the order of the groups shown in the legend.
 
.PARAMETER Options
Sets properties of the object.
 
.PARAMETER Style
Sets a style of the object.
 
.PARAMETER AddTo
Specifies a plot model to which the object will be added.
 
.INPUTS
You can send any object to the cmdlet as the source of the data set.
#>

function New-OxyCandleStickAndVolumeSeries {
  [cmdletbinding()]
  [OutputType([OxyPlot.Series.CandleStickAndVolumeSeries[]], [void])]
  param(
    [Parameter(ValueFromPipeline=$true)]
    [object]$InputObject,

    [object[]]$X = @(),
    [object[]]$Open = @(),
    [object[]]$High = @(),
    [object[]]$Low = @(),
    [object[]]$Close = @(),
    [object[]]$BuyVolume = @(),
    [object[]]$SellVolume = @(),
    [string[]]$Group = @(),

    [string]$XName,
    [string]$OpenName,
    [string]$HighName,
    [string]$LowName,
    [string]$CloseName,
    [string]$BuyVolumeName,
    [string]$SellVolumeName,
    [string]$GroupName,
    [string[]]$GroupingKeys = @(),

    [System.Collections.Generic.List`1[[OxyPlot.Series.OhlcvItem, OxyPlot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=638079a8f0bd61e9]]]$Items,
    [OxyPlot.Axes.LinearAxis]$VolumeAxis,
    [System.String]$VolumeAxisKey,
    [System.String]$BarAxisKey,
    [OxyPlot.Series.VolumeStyle]$VolumeStyle,
    [object]$StrokeThickness,
    [object]$StrokeIntensity,
    [object]$SeparatorStrokeThickness,
    [OxyPlot.LineStyle]$SeparatorLineStyle,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$PositiveColor,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$NegativeColor,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$SeparatorColor,
    [System.Boolean]$PositiveHollow,
    [System.Boolean]$NegativeHollow,
    [object]$CandleWidth,
    [object]$MinimumVolume,
    [object]$MaximumVolume,
    [object]$AverageVolume,
    [object]$MaxX,
    [object]$MaxY,
    [object]$MinX,
    [object]$MinY,
    [System.String]$XAxisKey,
    [System.String]$YAxisKey,
    [System.Collections.IEnumerable]$ItemsSource,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$Background,
    [System.Boolean]$IsVisible,
    [System.String]$Title,
    [System.Boolean]$RenderInLegend,
    [System.String]$TrackerFormatString,
    [System.String]$TrackerKey,
    [System.String]$Font,
    [object]$FontSize,
    [object]$FontWeight,
    [System.Object]$Tag,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$TextColor,
    [System.String]$ToolTip,
    [System.Boolean]$Selectable,
    [OxyPlot.SelectionMode]$SelectionMode,
    [OxyPlot.Model]$Parent,

    [hashtable]$Options = @{},

    [string]$Style = "default",
    [OxyPlot.PlotModel]$AddTo
  )

begin {

  if (!(Test-OxyStyleName $Style)) {
    Write-Error "Unknown style: '$Style'"
    return
  }

  $info = [PSCustomObject]@{
    XAxisTitle = "X"
    YAxisTitle = "Close"
    XDataType = $null
    YDataType = $null
    GroupName = $GroupName
    CategoryNames = @()
    CategoryTitle = $null
  }

  if ($PSBoundParameters.ContainsKey("XName")) { $info.XAxisTitle = $XName }
  if ($PSBoundParameters.ContainsKey("CloseName")) { $info.YAxisTitle = $CloseName }


  $XData = New-Object Collections.Generic.List[object]
  $OpenData = New-Object Collections.Generic.List[object]
  $HighData = New-Object Collections.Generic.List[object]
  $LowData = New-Object Collections.Generic.List[object]
  $CloseData = New-Object Collections.Generic.List[object]
  $BuyVolumeData = New-Object Collections.Generic.List[object]
  $SellVolumeData = New-Object Collections.Generic.List[object]
  $GroupData = New-Object Collections.Generic.List[string]

}

process {
  if ($InputObject -ne $null) {
    if ($PSBoundParameters.ContainsKey("XName")) { $XData.Add($InputObject.$XName) }
    if ($PSBoundParameters.ContainsKey("OpenName")) { $OpenData.Add($InputObject.$OpenName) }
    if ($PSBoundParameters.ContainsKey("HighName")) { $HighData.Add($InputObject.$HighName) }
    if ($PSBoundParameters.ContainsKey("LowName")) { $LowData.Add($InputObject.$LowName) }
    if ($PSBoundParameters.ContainsKey("CloseName")) { $CloseData.Add($InputObject.$CloseName) }
    if ($PSBoundParameters.ContainsKey("BuyVolumeName")) { $BuyVolumeData.Add($InputObject.$BuyVolumeName) }
    if ($PSBoundParameters.ContainsKey("SellVolumeName")) { $SellVolumeData.Add($InputObject.$SellVolumeName) }
    if ($PSBoundParameters.ContainsKey("GroupName")) { $GroupData.Add($InputObject.$GroupName) }
  }
}

end {
  if ($XData.Count -gt 0 -and $X.Count -gt 0) { Write-Error "Data set of 'X' is given in two ways"; return }
  if ($OpenData.Count -gt 0 -and $Open.Count -gt 0) { Write-Error "Data set of 'Open' is given in two ways"; return }
  if ($HighData.Count -gt 0 -and $High.Count -gt 0) { Write-Error "Data set of 'High' is given in two ways"; return }
  if ($LowData.Count -gt 0 -and $Low.Count -gt 0) { Write-Error "Data set of 'Low' is given in two ways"; return }
  if ($CloseData.Count -gt 0 -and $Close.Count -gt 0) { Write-Error "Data set of 'Close' is given in two ways"; return }
  if ($BuyVolumeData.Count -gt 0 -and $BuyVolume.Count -gt 0) { Write-Error "Data set of 'BuyVolume' is given in two ways"; return }
  if ($SellVolumeData.Count -gt 0 -and $SellVolume.Count -gt 0) { Write-Error "Data set of 'SellVolume' is given in two ways"; return }
  if ($GroupData.Count -gt 0 -and $Group.Count -gt 0) { Write-Error "Data set of 'Group' is given in two ways"; return }

  $XData.AddRange($X)
  $OpenData.AddRange($Open)
  $HighData.AddRange($High)
  $LowData.AddRange($Low)
  $CloseData.AddRange($Close)
  $BuyVolumeData.AddRange($BuyVolume)
  $SellVolumeData.AddRange($SellVolume)
  $GroupData.AddRange($Group)

  if ($GroupData.Count -gt 0) {
    $groups = @{}
    foreach ($e in $GroupData) {
      $groups[$e] = 1
    }
    if ($GroupingKeys.Count -eq 0) {
      $GroupingKeys = $groups.Keys | Sort
    }
    $grouping = $true
  }
  else {
    $GroupingKeys = @("dummy")
    $grouping = $false
  }

  $dataCount = ($XData.Count, $OpenData.Count, $HighData.Count, $LowData.Count, $CloseData.Count, $BuyVolumeData.Count, $SellVolumeData.Count | Measure -Maximum).Maximum
  foreach ($group in $GroupingKeys) {

    $series = New-Object OxyPlot.Series.CandleStickAndVolumeSeries

    if ($grouping) {
      $series.Title = $group
    }

    for ($i = 0; $i -lt $dataCount; ++$i) {
      if ($grouping -and $GroupData[$i] -ne $group) {
        continue
      }
      if ($i -lt $XData.Count) {
        $XElement = $XData[$i]
      }
      else {
        $XElement = $null
      }
      if ($i -lt $OpenData.Count) {
        $OpenElement = $OpenData[$i]
      }
      else {
        $OpenElement = $null
      }
      if ($i -lt $HighData.Count) {
        $HighElement = $HighData[$i]
      }
      else {
        $HighElement = $null
      }
      if ($i -lt $LowData.Count) {
        $LowElement = $LowData[$i]
      }
      else {
        $LowElement = $null
      }
      if ($i -lt $CloseData.Count) {
        $CloseElement = $CloseData[$i]
      }
      else {
        $CloseElement = $null
      }
      if ($i -lt $BuyVolumeData.Count) {
        $BuyVolumeElement = $BuyVolumeData[$i]
      }
      else {
        $BuyVolumeElement = $null
      }
      if ($i -lt $SellVolumeData.Count) {
        $SellVolumeElement = $SellVolumeData[$i]
      }
      else {
        $SellVolumeElement = $null
      }
      Add-OxyCandleStickAndVolumeSeriesPoint $series $XElement $OpenElement $HighElement $LowElement $CloseElement $BuyVolumeElement $SellVolumeElement
    }

    if ($XData.Count -gt 0) { $info.XDataType = Get-ValueType $XData[0] }
    if ($CloseData.Count -gt 0) { $info.YDataType = Get-ValueType $CloseData[0] }

    $series = $series | Add-Member -PassThru NoteProperty _Info $info

    Apply-OxyStyle $series $Style $MyInvocation

    $props = $PROPERTY_HASH["OxyPlot.Series.CandleStickAndVolumeSeries"]
    Assign-ParametersToProperties $props $PSBoundParameters $Options $series

    if ($AddTo -ne $null) {
      Add-OxyObjectToPlotModel $series $AddTo -NoRefresh
    }
    else {
      $series
    }
  }

  if ($AddTo -ne $null) {
    $AddTo.InvalidatePlot($true)
  }
}
}