Easy way to Make Money with Moving Average TradingView Script?

Moving average is a technical indicator that smoothens out price action by filtering out the noise and showing only the major trends. It is one of the most popular indicators among traders and is used in many different ways. The most common use of moving average is to identify the trend direction, but it can also be used to generate buy and sell signals, as well as to gauge momentum. moving average TradingView script


What is a moving average?

A moving average is a technical analysis indicator that is used to smooth out price data by filtering out short-term fluctuations and highlighting long-term trends. It is calculated by taking the average of a certain number of past prices, typically closing prices, and plotting the resulting series of averages on a chart.

The length of the moving average, which is the number of past prices used to calculate it, can be adjusted to suit the trader’s needs. A shorter moving average will be more sensitive to short-term price movements, while a longer moving average will filter out short-term fluctuations and focus on longer-term trends.

Moving averages can be used to identify trends, support and resistance levels, and potential buy and sell signals.

What is TradingView?

Created in 2011, TradingView is a web-based charting platform that has become popular among traders in recent years. The platform offers a wide range of features, including social sharing and collaboration tools, as well as advanced charting capabilities.

One of the key reasons for Trading View’s success is its ease of use. The platform is user-friendly and intuitive, making it ideal for beginner and experienced traders alike. Another key advantage is its affordability – TradingView offers a free basic subscription, with paid plans starting at just $9.95 per month.

Whether you’re looking to start your trading journey or take your analysis to the next level, TradingView is definitely worth checking out.

moving average TradingView script

How to set up Moving Average a Script

A moving average is a calculation to smooth out data points by creating a constantly updated average value. This is useful for data that fluctuates frequently, such as security prices. When security prices are plotted, the moving average line can help identify trends.

There are different types of moving averages, but the most common is the simple moving average (SMA), which smooth’s out data by calculating the arithmetic mean of previous periods. To set up a simple moving average script, you will need access to historical data and software that can perform calculations.

The first step is to determine the length of time over which you want to calculate the moving average. This is typically done by looking at past data to see how long it takes for trends to develop.

How to use Moving Average a Script

A moving average is a technique that is used to smooth out data points by creating a constantly updated average line. This line is created by taking the average of a predetermined set of values, typically closing prices. This technique can be used in conjunction with other technical indicators to help make trading decisions.

To use a moving average script, first select the time frame that you want to analyze. For example, you may want to look at a daily chart or an hourly chart. Next, decide which type of moving average you would like to use. There are three common types: simple, exponential, and weighted. Each has its own benefits and drawbacks.

Once you have selected your time frame and moving average type, it’s time to start looking for trading opportunities.

indicator("Hull Butterfly Oscillator [LuxAlgo]", "Hull Butterfly Oscillator [LuxAlgo]")
length = input(14)

mult = input(2., 'Levels Multiplier')

src = input(close)

bull_css_0 = input.color(color.new(#0cb51a, 50), 'Bullish Gradient'
  , inline = 'inline0'
  , group = 'Style')

bull_css_1 = input.color(#0cb51a, ''
  , inline = 'inline0'
  , group = 'Style')

bear_css_0 = input.color(color.new(#ff1100, 50), 'Bearish Gradient'
  , inline = 'inline1'
  , group = 'Style')

bear_css_1 = input.color(#ff1100, ''
  , inline = 'inline1'
  , group = 'Style')

//Normalization variables
var short_len = int(length / 2)
var hull_len = int(math.sqrt(length))

var den1 = short_len * (short_len + 1) / 2
var den2 = length * (length + 1) / 2
var den3 = hull_len * (hull_len + 1) / 2

//Hull coefficients
var lcwa_coeffs = array.new_float(hull_len, 0)
var hull_coeffs = array.new_float(0)

if barstate.isfirst
    //Linearly combined WMA coeffs
    for i = 0 to length-1
        sum1 = math.max(short_len - i, 0)
        sum2 = length - i
        array.unshift(lcwa_coeffs, 2 * (sum1 / den1) - (sum2 / den2))
    //Zero padding of linearly combined WMA coeffs
    for i = 0 to hull_len-2
        array.unshift(lcwa_coeffs, 0)
    //WMA convolution of linearly combined WMA coeffs
    for i = hull_len to array.size(lcwa_coeffs)-1
        sum3 = 0.
        for j = i-hull_len to i-1
            sum3 += array.get(lcwa_coeffs, j) * (i - j)
        array.unshift(hull_coeffs, sum3 / den3)

//Hull squeeze oscillator
var os  = 0
var len = array.size(hull_coeffs)-1
hma     = 0.
inv_hma = 0.

for i = 0 to len
    hma += src[i] * array.get(hull_coeffs, i)
    inv_hma += src[len-i] * array.get(hull_coeffs, i)
hso = hma - inv_hma

cmean = ta.cum(math.abs(hso)) / bar_index * mult

os := ta.cross(hso, cmean) or ta.cross(hso, -cmean) ? 0
  : hso < hso[1] and hso > cmean ? -1
  : hso > hso[1] and hso < -cmean ? 1
  : os

css0 = color.from_gradient(hso, 0, cmean, bull_css_0, bull_css_1)
css1 = color.from_gradient(hso, -cmean, 0, bear_css_1, bear_css_0)
css = hso > 0 ? css0 : css1

//Oscillator line/histogram
plot(hso, 'Hull Butterfly', css
  , style = plot.style_histogram)

plot(hso, 'Hull Butterfly', chart.fg_color)

plot(os > os[1] and os == 1 ? hso : na, 'Bullish Dot'
  , bull_css_1
  , 2
  , plot.style_circles)
plot(os < os[1] and os == -1 ? hso : na, 'Bearish Dot'
  , bear_css_1
  , 2
  , plot.style_circles)

plot(cmean, color = color.gray, editable = false)

plot(cmean / 2, color = color.gray, editable = false)

plot(-cmean / 2, color = color.gray, editable = false)

plot(-cmean, color = color.gray, editable = false)


Pros and cons of using moving average a script

  • -A moving average script can help smooth out data and make it easier to interpret.
  • -It can also help to identify trends.
  • -Moving average scripts are relatively easy to use and understand.
  • -They can be customized to fit the specific needs of the user.
  • -Moving averages can be used with other technical indicators to create a more comprehensive analysis.
  • -A moving average script cannot predict future movements in the market.
  • -It is a lagging indicator, so it may give false signals.
  • -Moving averages may not work well in choppy markets.
  • -They can be subject to interpretation, so two analysts may not come to the same conclusions based on the same data.
  • – Moving averages may not pick up on all changes in the underlying data, especially if there is a lot of noise.


In conclusion, the moving average TradingView script is a great tool for any trader. It is easy to use and can help you make better trading decisions. If you are new to trading, or if you are looking for a new tool to help you trade, the moving average TradingView script is definitely worth a try.

Latest posts by Amrita (see all)