Skip to content

Instantly share code, notes, and snippets.

@milktrader
Created February 18, 2014 03:08
Show Gist options
  • Save milktrader/9063995 to your computer and use it in GitHub Desktop.
Save milktrader/9063995 to your computer and use it in GitHub Desktop.
MACD code
function macd{T}(ta::TimeArray{T,1}, fast::Int, slow::Int, signal::Int)
fastma = ema(ta, fast)
slowma = ema(ta, slow)
mcdval = fastma - slowma
sigval = ema(mcdval, signal)
merge(mcdval, sigval, ["macd", "signal"])
end
@milktrader
Copy link
Author

Hmm, probably the most descriptive code to match algorithm would be this

function macd{T}(ta::TimeArray{T,1}, fast::Int, slow::Int, signal::Int) 
  mcdval = ema(ta, fast) -  ema(ta, slow)
  sigval = ema(mcdval, signal)
  merge(mcdval, sigval, ["macd", "signal"])
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment