Learn
Indicators

What is and how to use Moving Averages in Tuned Script

what is a moving average (ma)? in statistics, a moving average is a calculation used to analyse data points by creating a series of averages of different subsets of the full data set in finance/crypto, a moving average (ma) is an indicator that is commonly used in technical analysis the reason for calculating the moving average of a stock/crypto asset is to help smooth out the price data by creating a constantly updated average price by calculating the moving average, the impacts of random, short term fluctuations on the price of an asset over a specified time frame are mitigated key points about moving averages a moving average is often used to smooth out price data moving averages are commonly used to gauge trend direction there are many types of moving averages, each with varying results/calculations what type of moving averages are supported on tuned? tunedscript alma() (arnaud legoux moving average) tunedscript dema() (double exponential moving average) tunedscript ema() (exponential moving average) tunedscript hullma() (hull moving average) tunedscript kama() (kaufman adaptive moving average) tunedscript mama() (mesa adaptive moving average) tunedscript sma() (simple moving average) tunedscript swma() (symmetrically weighted moving average) tunedscript tema() (triple exponential moving average) tunedscript trima() (triangular moving average) tunedscript vwma() (volume weighted moving average) tunedscript wma() (weighted moving average) all of the above moving averages you will be able to find in our docs https //www tuned com/docs/#/ how to add a moving average to my script? below you will find a short example of using 2 different moving averages in your script lets start with writing a small section of code to use the exponential moving average tunedscript //inputs // create an input variable using type integer to use as the ema's length emalen = intinput("ema length", 21) //indicator // define your ema ema = ema(close, emalen) //plot // plot the ema plot(ema, "ema plot", "#004bec", 2) //signal push // never order means that no orders will be placed out(never order) the second example will show how to use the hull moving average tunedscript //inputs // create an input variable for type integer to use as the hullma's length hmalen = intinput("hullma length", 55) //indicator // define your hullma hullma = hullma(close, hmalen) //plot // plot the hullma plot(hullma, "hullma plot", "#004bec", 2) //signal push // never order means that no orders will be placed out(never order) the above image is how the plot should look on the chart the blue line is your moving average in this example how to combine these 2 moving averages? so now you know how to write a simple script to generate a moving average, what's next? combining them together will allow you to generate buy and sell signals based off of the moving averages the most common way to do this would be to use a faster moving average cross over or under a slower moving average here is how to do this tunedscript //inputs // create an input variable for type integer to use as the hullma's length emalen = intinput("ema length fast ma", 13) hmalen = intinput("hullma length slow ma", 100) //indicator // define your moving averages ema = ema(close, emalen) // this is your ema hullma = hullma(close, hmalen) // this is your hullma //entry and exit conditions // define the entry condition of fast crossing over slow buy = crossover(ema, hullma) // define the exit condition of fast crossing under slow sell = crossunder(ema, hullma) //plot // plot the moving averages plot(ema, "ema plot", "#00ff00", 2) // green line is your ema plot(hullma, "hullma plot", "#004bec", 2) // blue line is hullma //signal push // here you will output your entry and exit signals out(signalif(buy, sell)) below is a screenshot of how it should look on your chart so now you have learnt what a moving average is, how to use it and how to put it in a script and generate signals from it have fun scripting!