Created
February 18, 2014 03:08
-
-
Save milktrader/9063995 to your computer and use it in GitHub Desktop.
MACD code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Author
Let's not make it a one-liner though! Which by the way is not all that big of a jump.
Author
macd{T}(ta::TimeArray{T,1}, fast::Int, slow::Int, signal::Int) = merge((ema(ta, fast) - ema(ta, slow)), ema((ema(ta, fast) - ema(ta, slow)), signal), ["macd", "signal"])
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
Of course, you can always refactor ...