# rma is a built-in function for moving average used in RSI in pine script. What is a similar built-in function in Thinkscript?

#### petergluis

##### Active member
rma is a built-in function for moving average used in RSI in pine script. What is a similar built-in function in Thinkscript?

Syntax

rma (source, length) --> series

Returns

Exponential moving average of x with alpha = 1/y.

I would like to know how to create a built-in function of rma by using following code for Thinkscript.

input length =14;
input price = close;
input averageType = AverageType.EXPONENTIAL;
def NetChangeAverage = MovingAverage(averageType , price - price[1], length);
def TotChangeAverage = MovingVerage (averageType, AbsValue(price - price[1]), length);
def rma = if TotChangeAverage !=0 then NetChangeAverge / TotChangeAvg else 0;

I would like to know how to create a built-in function of rma by using following code for Thinkscript.

input length =14;
input price = close;
input averageType = AverageType.EXPONENTIAL;
def NetChangeAverage = MovingAverage(averageType , price - price[1], length);
def TotChangeAverage = MovingVerage (averageType, AbsValue(price - price[1]), length);
def rma = if TotChangeAverage !=0 then NetChangeAverge / TotChangeAvg else 0;

mashume created a sub script for rma() here,

Code:
``````# study("Rob Hoffman - Overlay Set", shorttitle = "RH - MAs", overlay = true)
script rma {
input source = CLOSE;
input length = 14;

def alpha = 1 / length;
def ma = alpha * source + (1 - alpha) * ma[1];
plot rma = ma;
};``````

Last edited:

87k+ Posts
311 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?