Indicator · Pine Script v6 · On the chart

EMA Fibonacci Trend

by ktg0413· code credited to kimteagyun0413

The EMA Fibonacci Trend indicator calculates and plots dynamic Fibonacci retracement and extension levels based on a 200-period Exponential Moving Average (EMA).

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code61
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago12 Oct 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

61 lines of Pine Script v6 from EMA Fibonacci Trend/EMA Fibonacci Trend.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

EMA Fibonacci Trend.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kimteagyun0413

//@version=6
indicator("EMA Fibonacci Trend", overlay = true)

// Calculate logarithmic close price / 로그 종가 계산
log_close = math.log10(close)

// Calculate 200-period Exponential Moving Average / 200일 지수이동평균 계산
ema200 = ta.ema(close, 200)

// Calculate volatility factor using ATR / ATR을 사용한 변동성 팩터 계산
v_factor = ta.atr(14) / close  

// Define range for extension (upward) / 확장 범위 정의 (상승)
range_up = ema200 * v_factor * 2

// Define range for retracement (downward) - Enhanced retracement range / 되돌림 범위 정의 (하락) - 되돌림폭 강화
range_down = ema200 * v_factor * 8

// Function to calculate Fibonacci retracement levels / 피보나치 되돌림 레벨 계산 함수
fibo_retrace(level) =>
    ema200 - (range_down * level)

// Function to calculate Fibonacci extension levels / 피보나치 확장 레벨 계산 함수
fibo_extension(level) =>
    ema200 + (range_up * level)

// Fibonacci retracement levels (below EMA200) / 피보나치 되돌림 레벨 (EMA200 아래)
level_0 = fibo_retrace(1)      // 0% - Full retracement / 0% - 전체 되돌림
level_236 = fibo_retrace(0.236)  // 23.6%
level_382 = fibo_retrace(0.382)  // 38.2%
level_50 = fibo_retrace(0.5)     // 50%
level_618 = fibo_retrace(0.618)  // 61.8%
level_786 = fibo_retrace(0.786)  // 78.6%

// Fibonacci extension levels (above EMA200) / 피보나치 확장 레벨 (EMA200 위)
level_1272 = fibo_extension(1.272)  // 127.2%
level_1618 = fibo_extension(1.618)  // 161.8%
level_2618 = fibo_extension(2.618)  // 261.8%
level_3618 = fibo_extension(3.618)  // 361.8%
level_4236 = fibo_extension(4.236)  // 423.6%

// Plot extension levels (above EMA200) / 확장 레벨 표시 (EMA200 위)
plot(level_4236, color = color.red, linewidth = 1)
plot(level_3618, color = color.orange, linewidth = 1)
plot(level_2618, color = color.yellow, linewidth = 1)
plot(level_1618, color = color.green, linewidth = 1)
plot(level_1272, color = color.aqua, linewidth = 1)

// Plot EMA200 baseline / EMA200 기준선 표시
plot(ema200, color = color.white, linewidth = 1)

// Plot retracement levels (below EMA200) / 되돌림 레벨 표시 (EMA200 아래)
plot(level_786, color = color.aqua, linewidth = 1)
plot(level_618, color = color.blue, linewidth = 1)
plot(level_50, color = color.green, linewidth = 1)
plot(level_382, color = color.yellow, linewidth = 1)
plot(level_236, color = color.orange, linewidth = 1)
plot(level_0, color = color.red, linewidth = 1)

Overview

EMA Fibonacci Trend measures volatility using a 14-period Average True Range (ATR) relative to price, establishing dynamic expansion and retracement ranges above and below the baseline EMA. The script draws dynamic Fibonacci extension levels above the EMA and retracement levels below it directly on the price chart to serve as adaptive support and resistance zones.

Details

Published by

ktg0413 on GitHub

Code credit

kimteagyun0413, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance, Moving averages, Volatility & bands, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

MA Envelope (MAE)

by mihakralj
99 stars

The MA Envelope indicator calculates upper and lower channel bands shifted by a user-defined percentage around a baseline moving average. It supports Simple Moving Average, Exponential Moving Average, and Weighted Moving Average calculation types. The script p

Indicator v6 Moving averagesSupport & resistance
Updated 4 weeks ago · Apache-2.0 GitHub repository of MA Envelope (MAE)

Trend Compass 4H

by chris-c-thomas
14 stars

Trend Compass 4H plots a multi-EMA ribbon (10/21/50) along with higher-timeframe reference levels on the price chart. It classifies trend phase into six states and calculates a composite weighted trend score. The script detects RSI and MACD divergences, analyz

Indicator v6 TrendMoving averages
Updated 6 months ago · MIT GitHub repository of Trend Compass 4H
10 stars

My Macro Cycle Indicator plots daily and weekly simple and exponential moving averages on the price chart, plus Pi Cycle and Mayer Multiple levels derived from the 200-day average. Optional toggles add support-band fills, a Keltner channel, CME futures gaps, a

Indicator v4 Moving averagesVolatility & bands
Updated 5 years ago · None stated GitHub repository of My Macro Cycle Indicator

This indicator plots a double-smoothed Supertrend baseline on the price chart, combining a Supertrend midline with WMA and EMA smoothing to show trend direction. Direction uses an ATR-scaled baseline slope with hysteresis, while percentile-ranked slope magnitu

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of Smooth Trend Radar [WavesUnchained]

SRI Indicator ft. MSB

by kingmalitha
7 stars

This indicator overlays an all-in-one technical analysis toolkit on the price chart. It plots multiple moving averages, including standard EMAs, SMAs, and a Trend Regularity Adaptive Moving Average, alongside Bollinger Bands, Supertrend, Nadaraya-Watson envelo

Indicator v5 Moving averagesTrend Repaints
Updated 3 years ago · None stated GitHub repository of SRI Indicator ft. MSB

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers