OPEN-SOURCE SCRIPT

BTMM EMA's

This script is written in Pine Script version 5 for TradingView and is designed to display multiple Exponential Moving Averages (EMAs) on a price chart. Here's a breakdown of its components:

1. Indicator Declaration
indicator(title="Moving Averages", shorttitle="BFX BTMM EMA", overlay=true):
Declares an indicator named "Moving Averages" with a short title "BFX BTMM EMA".
overlay=true means the indicator will be plotted directly on the price chart, not in a separate window.
2. EMA Calculation
The script calculates EMAs for the lengths of 5, 13, 50, 200, and 800 using the ta.ema() function, which applies the exponential moving average to the closing price (close).
pinescript
Copy code
ema5 = ta.ema(close, 5)
ema13 = ta.ema(close, 13)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
ema800 = ta.ema(close, 800)
3. Plotting EMAs
Each EMA is plotted on the chart using the plot() function with specific colors for visual distinction:
EMA5: Yellow (color.rgb(255, 213, 0))
EMA13: Red (color.rgb(255, 0, 0))
EMA50: Light Blue (color.rgb(111, 183, 242))
EMA200: White (color.rgb(255, 255, 255))
EMA800: Purple (color.rgb(60, 0, 255))
4. Custom Smoothing Function
ma(source, length, type) is a custom function that allows users to select different types of moving averages, such as SMA, EMA, SMMA (RMA), WMA, and VWMA.
pinescript
Copy code
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
5. User Inputs
typeMA and smoothingLength are user inputs for selecting the smoothing method and the length of the moving average. These inputs allow customization of the indicator:
typeMA provides options for the smoothing method.
smoothingLength sets the length of the smoothing.
pinescript
Copy code
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing")
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing")
Summary:
This script calculates and plots five EMAs on the price chart, providing a visual representation of different time-frame trends. Additionally, it includes a custom function to allow the user to apply other smoothing techniques to the data, offering flexibility in analysis.
Exponential Moving Average (EMA)exponentialmovingavarage

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明