All problems
Signal Line
Problem
Compute the MACD signal line: build the MACD series from the short and long EMAs, then apply an EMA with span signal_span to that series and return its final value. Each EMA uses smoothing factor 2 / (span + 1) and starts at the first value of its input.
Return 0.0 for an empty series.
Hint
Signal-line crossings are the classic MACD trigger events.
Test cases
case 1
in: [[1,2,3,4,5],2,3,2]
expected: 0.4099794238683124
case 2
in: [[5,5,5],12,26,9]
expected: 0
case 3
in: [[10],3,5,2]
expected: 0
case 4
in: [[10,9,8,7,6],2,4,3]
expected: -0.6606271604938272
Starter codePython
def signal_line(prices, short_span, long_span, signal_span):
# Your code here
pass4 test cases · run your code against them in the editor