Strategy · Pine Script v5 · On the chart

EMA + MACD Line Segment Break Strategy

by Druidss

This strategy plots EMAs 21, 52, and 144 alongside the MACD indicator on the BTC price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code245
Settings13inputs
LicenceNone stated
Last update7 weeks ago7 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

EMA + MACD Line Segment Break Strategy identifies bullish or bearish line segments using MACD crossovers above and below zero, with delay confirmations and below-zero-axis breakout filters. Entries occur when EMA 52 crosses below EMA 21 with rising MACD histogram and multi-timeframe (4H) MACD conditions met. The strategy supports position sizing in cash and includes partial take-profit at 50% of position when breaking recent highs, with remaining position closed on EMA 52 breach or other conditions. Main settings adjust EMA lengths, MACD periods, segment confirmation bars, and threshold values. It draws signals directly on the price chart without a separate pane. No stop loss is applied by default.

Details

Published by

Druidss on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Moving averages, Oscillators & momentum, Breakout, Trend

Markets

Crypto

Timeframes

M15-H1, H4 and above

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
EMA21int21ema21_length
EMA52int52ema52_length
EMA144int144ema144_length
MACD 快线周期int12macd_fast
MACD 慢线周期int26macd_slow
MACD 信号线周期int9macd_signal
下跌线段确认K线数int25delay_bars
上涨线段确认最短K线数int2min_downtrend_bars
4小时MACD快线上限float1500.0max_4h_dif
4小时DEA下限float-1500.0min_4h_dea
启用零轴下突破booltrueenable_below_zero
DEA阈值float-60.0dea_threshold
Show all 13 settings
SettingTypeDefaultVariable
突破超时K线数int8below_zero_timeout
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

ADA4H Optuna Strategy

by skywalker0803r
42 stars

This strategy trades longs and shorts on the price chart. Long entries require a close above the prior Donchian high, a close above a long-term SMA, and RSI above a threshold, with size set as a percentage of equity. Long exits use a stop at the prior Donchian

Strategy v5 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of ADA4H Optuna Strategy

Edge 59

by subos2008
6 stars

Edge 59 is a price-chart strategy that combines an ADX directional filter, a weighted moving average, and a trend-follower channel. The channel uses an exponential moving average of close, optionally smoothed by linear regression, and a percentage of a fixed 2

Strategy v5 TrendOscillators & momentum Repaints
Updated 2 years ago · Custom licence GitHub repository of Edge 59

AG Momentum Breakout

by eltonaguiar
4 stars

AG Momentum Breakout is a strategy that identifies continuation signals after pullbacks in trending markets. It filters for uptrends using EMAs and detects recent pullbacks via RSI conditions before entering on RSI crossovers above 50 with ADX confirmation. Th

Strategy v6 TrendOscillators & momentum
Updated today · None stated GitHub repository of AG Momentum Breakout
4 stars

Christian Qullamaggie Strategy is a trend-following and breakout strategy overlay designed to identify high-momentum trading opportunities directly on the price chart. It evaluates market conditions using fast, mid, and slow EMAs, average true range (ATR), and

Strategy v6 BreakoutTrend
Updated 7 months ago · None stated GitHub repository of Christian Qullamaggie Strategy

RSI-7 Breakout

by aofwittawat
4 stars

This strategy identifies breakout trades using a 7-period RSI combined with price extreme lookbacks. A long entry triggers when the RSI rises above 70 and price reaches a new lookback high, provided price remains above an optional EMA trend filter and passes a

Strategy v5 Oscillators & momentumBreakout
Updated 4 years ago · None stated GitHub repository of RSI-7 Breakout

RSI EMA Breakout

by latentwill
4 stars

This strategy trades momentum breakouts by combining an Exponential Moving Average with the Relative Strength Index. It enters a long position when the closing price is above the EMA and the RSI crosses above the breakout threshold. It enters a short position

Strategy v5 TrendOscillators & momentum
Updated 6 days ago · None stated GitHub repository of RSI EMA Breakout

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers