implement GetUpperShadowHeight and GetLowerShadowHeight

This commit is contained in:
c9s 2020-06-16 13:44:50 +08:00
parent c089e9a1b5
commit fded619772

View File

@ -82,10 +82,32 @@ func (k KLine) GetMaxChange() float64 {
return k.GetHigh() - k.GetLow()
}
// GetThickness returns the thickness of the kline. 1 => thick, 0.1 => thin
func (k KLine) GetThickness() float64 {
return math.Abs(k.GetChange()) / math.Abs(k.GetMaxChange())
}
func (k KLine) GetUpperShadowHeight() float64 {
high := k.GetHigh()
if k.GetOpen() > k.GetClose() {
return high - k.GetOpen()
}
return high - k.GetClose()
}
func (k KLine) GetLowerShadowHeight() float64 {
low := k.GetLow()
if k.GetOpen() < k.GetClose() {
return k.GetOpen() - low
}
return k.GetClose() - low
}
// GetBody returns the height of the candle real body
func (k KLine) GetBody() float64 {
return k.GetChange()
}
func (k KLine) GetChange() float64 {
return k.GetClose() - k.GetOpen()
}