Skip to content

MACD Signal line (EMA) seems to be broken/not working... #39

@amlwwalker

Description

@amlwwalker

Based on a series of data, to plot the MACD and signal lines, I am doing:

	macD := analytics.MACD(closePriceIndicator, 12, 26)
	macDSignal := analytics.MACDSignalLine(macD, 9)

Where the above two functions are defined as:

func MACD(indicator techan.Indicator, shortWindow, longWindow int) techan.Indicator {
	return techan.NewMACDIndicator(indicator, shortWindow, longWindow)
}
func MACDSignalLine(indicator techan.Indicator, window int) techan.Indicator {
	return techan.NewEMAIndicator(indicator, window)
}

However when I plot this, I get two very different lines

image

To check I wasn't going completely mad, I changed the signal line to use an SMA instead, so my MACDSignalLine function becomes

func MACDSignalLine(indicator techan.Indicator, window int) techan.Indicator {
	return techan.NewSimpleMovingAverage(indicator, window) // Create an exponential moving average with a window of 10
}

which plots like

image

Which suggests that the EMA isn't working correctly for some reason here. Any suggestions as to where Im going wrong would be great, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions