[pshaiCmd] Hull Moving Average (SE)
stableDescription
Custom command for Hull Moving Average, made in SE and supports all built-in MAs.
Example:
local c = ClosePrices()
local ma1 = CC_HMA(c, 20, SmaType)
local ma2 = CC_HMA(c, 20, DemaType)
local ma3 = CC_HMA(c, 20) -- default is WMA
local ma4 = CC_HMA(c, 20, KamaType)
Plot(0, 'ma1', ma1, White)
Plot(0, 'ma2', ma2, Yellow)
Plot(0, 'ma3', ma3, Orange)
Plot(0, 'ma4', ma4, Red)
HaasScript
DefineCommand('HMA', 'Hull Moving Average by pshai')
local src = DefineParameter(ListNumberType, 'source', 'Source data', true, ClosePrices(), 'ClosePrices')
local period = DefineParameter(NumberType, 'period', 'Period Length', true, 20, 'Input, Number, SessionGet')
local maType = DefineParameter(EnumType, 'maType', 'Type of Moving Average', false, WmaType, 'InputMaTypes')
local hma = MA(2*MA(src, Round(period/2, 0), maType) - MA(src, period, maType), Round(Sqrt(period), 0), maType)
DefineOutput(ListNumberType, hma, 'Hull Moving Average values array')
0 Comments
Sign in to leave a comment.
No comments yet. Be the first!