Combine SMA & EMA in TradingView: Create a Custom Indicator with ChatGPT (No Coding Needed!)


Introduction:

If you want to combine SMA and EMA in TradingView, especially while using the free version, you’re in the right place.

In this blog, I’ll show you exactly how I created a custom TradingView indicator that combines 4 SMAs and 4 EMAs — all in one script.

I’ll also explain what SMA and EMA are, how they work, and how you can use them together for better trend analysis. And guess what? I didn’t write a single line of code myself — ChatGPT did it for me.

Let’s dive in.


Why Combine SMA and EMA in TradingView?

If you’ve used TradingView for any serious analysis, you already know the free plan only lets you use two indicators.

But when you’re trading with moving averages, you may want:

  • Multiple Simple Moving Averages (SMA)
  • Multiple Exponential Moving Averages (EMA)
    …at the same time.

That’s when I thought:
Can I combine SMA and EMA in TradingView using one custom script?

Yes — and I’ll show you how.


What Is SMA and EMA in TradingView?

Before we dive into the code, let’s understand the tools we’re combining.

🔷 What is SMA?

SMA stands for Simple Moving Average. It’s the average of closing prices over a period of time. For example:

  • A 50 SMA = average of the last 50 candles.

It’s smooth, steady, and helps identify long-term market direction.

🔶 What is EMA?

EMA, or Exponential Moving Average, gives more weight to recent candles, making it more responsive to price changes.

This makes it great for:

  • Short-term momentum
  • Quick trend shifts

🔄 SMA vs EMA

FeatureSMAEMA
SpeedSlowerFaster
Best ForLong trendsShort moves
ReactionsDelayedResponsive

When you combine SMA and EMA INDICATOR in TradingView, you get a more complete market view.


My Problem: I Needed More Indicators

I was using the free version of TradingView. I wanted:

  • 4 SMAs for different timeframes (25, 50, 100, 200)(customize option)
  • 4 EMAs for the same periods

But I could only add 2 indicators on my chart. That wasn’t enough for me to analyze the market the way I wanted.


My Solution: ChatGPT + Pine Script

I don’t know how to code in Pine Script.
But I knew what I wanted.

So I asked ChatGPT to create a TradingView indicator that could:

  • Plot 4 Simple Moving Averages
  • Plot 4 Exponential Moving Averages
  • Allow me to customize inputs
  • Display all 8 lines in one clean indicator

In less than a minute, ChatGPT wrote the full Pine Script code.

Here’s how you can use it too.


🛠️ Pine Script Code to Combine SMA and EMA in TradingView

you can do the same as i did. play around with the ai or modern technology. That’s how we learn and adapt with new technology.

for instance if you want short cut, here is the code I use. Copy-paste this into your Pine Script editor in TradingView.

//@version=5
indicator("Multiple SMA & EMA", overlay=true)

// Input fields for SMA and EMA periods
period1 = input.int(25, minval=1, title="Period 1")
period2 = input.int(50, minval=1, title="Period 2")
period3 = input.int(100, minval=1, title="Period 3")
period4 = input.int(200, minval=1, title="Period 4")

// Define SMAs
sma1 = ta.sma(close, period1)
sma2 = ta.sma(close, period2)
sma3 = ta.sma(close, period3)
sma4 = ta.sma(close, period4)

// Define EMAs
ema1 = ta.ema(close, period1)
ema2 = ta.ema(close, period2)
ema3 = ta.ema(close, period3)
ema4 = ta.ema(close, period4)

// Plot SMAs
plot(sma1, color=color.blue, linewidth=2, title="SMA 1")
plot(sma2, color=color.orange, linewidth=2, title="SMA 2")
plot(sma3, color=color.green, linewidth=2, title="SMA 3")
plot(sma4, color=color.purple, linewidth=2, title="SMA 4")

// Plot EMAs
plot(ema1, color=color.red, linewidth=2, title="EMA 1")
plot(ema2, color=color.yellow, linewidth=2, title="EMA 2")
plot(ema3, color=color.aqua, linewidth=2, title="EMA 3")
plot(ema4, color=color.fuchsia, linewidth=2, title="EMA 4")

How to Use This Custom Indicator in TradingView

  1. Open TradingView and go to any chart
  2. Click on “Pine Editor” at the bottom
  3. Paste the code above
  4. Click Add to Chart
  5. Save the script under a name you’ll remember

That’s it. You just added 8 moving averages in one go.

You’ve now officially combined SMA and EMA in TradingView with a single script.


Customize Inputs and Style

With this script, now indicator is flexible. You can:

  • Change SMA/EMA periods
  • Pick your own colors
  • Adjust line thickness
  • Hide/show individual lines

You can also make this indicator private or public. I did not publish in tradingview.



Final Thoughts: Combine SMA and EMA in TradingView Like a Pro

With this guide, you now know how to:

  • Understand the difference between SMA and EMA
  • Combine them both into one TradingView indicator
  • Customize and use it without any coding

All you need is:

  • A free TradingView account
  • And a little help from ChatGPT or other AI.

Zingyo .T
Zingyo .T