OPEN-SOURCE SCRIPT

Decimal EMA

103
Imagine you want a moving average line, but you want its "length" or "period" to be super precise, like 2.7 days instead of just 2 days or 3 days.

This script lets you do that. Here's the simple idea:

You Pick a Decimal Number: In the settings, you can type in a period with a decimal, say, 2.7.
The Script Does a Smart Blend:

It first calculates two regular EMAs: one for the whole number below your choice (EMA for 2 days) and one for the whole number above (EMA for 3 days).

Then, it cleverly mixes these two EMA lines. Since 2.7 is closer to 3 than to 2, it takes more from the "3-day EMA" and a bit less from the "2-day EMA." (Specifically, it takes 70% from the 3-day EMA and 30% from the 2-day EMA).

You Get a Decimal EMA Line: The result is a new EMA line that acts as if its period was exactly 2.7. This line is drawn on your chart.

Why do this?

It allows for very fine-tuned adjustments to how responsive your moving average is, giving a smoother change if you're testing slightly different period lengths.

In Short:

This script calculates an EMA for a period like "2.7" by intelligently blending the results of an EMA for "2" and an EMA for "3".

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。