Пример #1
0
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *AdlWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {

	moneyFlowMultiplier := ((tickData.C() - tickData.L()) - (tickData.H() - tickData.C())) / (tickData.H() - tickData.L())
	moneyFlowVolume := moneyFlowMultiplier * tickData.V()
	result := ind.previousAdl + moneyFlowVolume

	ind.UpdateIndicatorWithNewValue(result, streamBarIndex)

	ind.previousAdl = result
}
Пример #2
0
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *StochOscWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
	ind.periodCounter += 1
	ind.hhv.ReceiveTick(tickData.H(), streamBarIndex)
	ind.llv.ReceiveTick(tickData.L(), streamBarIndex)

	if ind.periodCounter >= 0 {
		ind.currentFastK = 100.0 * ((tickData.C() - ind.currentPeriodLow) / (ind.currentPeriodHigh - ind.currentPeriodLow))
		ind.slowKMA.ReceiveTick(ind.currentFastK, streamBarIndex)
	}
}
Пример #3
0
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *TrueRangeWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
	ind.periodCounter += 1

	if ind.periodCounter > 0 {

		high := math.Max(tickData.H(), ind.previousClose)
		low := math.Min(tickData.L(), ind.previousClose)
		result := high - low

		ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
	}

	ind.previousClose = tickData.C()
}
Пример #4
0
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *Cci) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
	ind.periodCounter += 1

	// calculate the typical price
	typicalPrice := (tickData.H() + tickData.L() + tickData.C()) / 3.0
	ind.currentTypicalPrice = typicalPrice

	// push it to the history
	ind.typicalPriceHistory.PushBack(typicalPrice)

	// trim the history
	if ind.typicalPriceHistory.Len() > ind.timePeriod {
		var first = ind.typicalPriceHistory.Front()
		ind.typicalPriceHistory.Remove(first)
	}

	// add it to the average
	ind.typicalPriceAvg.ReceiveTick(typicalPrice, streamBarIndex)
}
Пример #5
0
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *ObvWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
	ind.periodCounter += 1

	if ind.periodCounter <= 0 {
		ind.previousObv = tickData.V()
		ind.previousClose = tickData.C()

		result := ind.previousObv

		ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
	}

	if ind.periodCounter > 0 {
		closePrice := tickData.C()
		if closePrice > ind.previousClose {
			ind.previousObv += tickData.V()
		} else if closePrice < ind.previousClose {
			ind.previousObv -= tickData.V()
		}

		result := ind.previousObv

		ind.UpdateIndicatorWithNewValue(result, streamBarIndex)

		ind.previousClose = tickData.C()
	}
}
Пример #6
0
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *AvgPriceWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {

	result := (tickData.O() + tickData.H() + tickData.L() + tickData.C()) / float64(4.0)

	ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
Пример #7
0
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *StochRsiWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {

	ind.rsi.ReceiveTick(tickData.C(), streamBarIndex)
}