[pshaiCmd] Relative Moving Average (RMA)

stable
By pshai in Trend Published April 2021 👁 1,553 views 💬 0 comments

Description

Custom command for Relative Moving Average indicator. Details: https://www.hybrid-solutions.com/plugins/client-vtl-plugins/free/rma.html Example:

local rma = CC_RMA(ClosePrices(), 20)
local sma = SMA(ClosePrices(), 20)

Plot(0, 'rma', rma, White)
Plot(0, 'sma', sma, Yellow)
HaasScript
-- Author: [email protected]

DefineCommand('RMA', 'Relative Moving Average')

local c = DefineParameter(ListNumberType, 'c', 'Close prices', true, ClosePrices(), 'ClosePrices')
local len = DefineParameter(NumberType, 'length', 'RMA Length', true, 14, 'Input, Number')
local type = DefineParameter(EnumType, 'type', 'MA Type to base calculations on', false, SmaType, 'InputMaTypes, Enumerations Moving Averages')

local ma1 = MA(c, len * 3, type)
local ma2 = MA(c, len * 2, type)
local ma3 = MA(c, len, type)

local ret = ma1 - ma2 + ma3

DefineOutput(ListNumberType, ret, 'RMA Output', 'Plot')

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!