Skip to content
← Indicator library
tradingviewtrendstrategypinescript-v6

Dual-Speed EMA + MACD Cycle Strategy

A Pine Script v6 strategy requiring aligned 9/21 EMA and 12/26/9 MACD crossover signals.

Published by AlgoNexa. AlgoNexa builds and documents evidence-first trading tools so you can inspect the logic before using it.About AlgoNexaIndicator library
Published Aug 4, 2026#ema#macd#crossover#atr#strategy#pinescript-v6#tradingview

How it works

Read the logic before you use it.

1

When it signals

A long signal requires the 9 EMA to cross above the 21 EMA and the MACD line to cross above its 9-period signal line on the same bar. A short signal requires both bearish crossunders.

2

What confirms it

The EMA crossover supplies the price-trend component, while the MACD crossover supplies the momentum component. Neither condition alone can enter a position in this code.

3

How risk is framed

After entry, ATR(14) sets a stop 1.5 ATR away and a limit 3 ATR away from the average entry price. The source also applies a 0.1% strategy commission assumption.

Walkthrough

Watch how it reads the chart.

Live market chart

The logic on real candles.

Backtest evidence

What the numbers actually show.

E0 · Reconstructed reference

algonexta-reference · Yahoo Finance · EURUSD · 1h

Net profit

-0.0021

Max drawdown

0.0021

Trades

1

Symbol · TF

EURUSD · 1h

Equity curve

Reference trades (2)
TimeSidePrice
Jun 30, 02:00 PMlong1.14364
Jun 30, 04:00 PMexit1.14157

Executed from the versioned AlgoNexta IR on the same OHLC dataset used by the chart.

This is an independent reference backtest; TradingView Strategy Tester remains the official comparison.

This is an AI-reconstructed approximation of the script’s logic, not an execution of the exact source — verify the real script in TradingView Strategy Tester.

Vision Grade

What was measured, and how confident we are in it.

Vision Grade requires a reference backtest with enough reconstructed entries to measure — not available for this script yet.

Full breakdown

How the script behaves.

About AlgoNexta

Published by AlgoNexta, an evidence-first platform for building, reviewing, and documenting algorithmic trading tools. This page explains the script's actual logic and intended use; it does not promise profitability or replace verification in TradingView.

What it does

This TradingView strategy opens a long or short position only when two crossover events occur on the same bar: a 9 EMA / 21 EMA price-trend crossover and a 12/26/9 MACD crossover. It uses a fixed ATR-based stop and profit target after entry.

Despite the suggested name, the supplied code does not calculate hidden divergence, draw bow/arrow graphics, or apply a separate EMA regime filter. Its implemented logic is EMA and MACD crossover confluence.

Conditions it watches

  • Long: the 9-period EMA crosses above the 21-period EMA, while the MACD line crosses above its 9-period signal line.
  • Short: the 9-period EMA crosses below the 21-period EMA, while the MACD line crosses below its 9-period signal line.
  • Both events must happen on the same bar because they are joined with and.
  • The strategy allows no pyramiding (pyramiding=0), so it does not stack entries in the same direction.

How to read it

  • Apply it to a price chart with overlay=true enabled; TradingView displays the strategy's entry and exit markers on the chart.
  • A Long order is submitted when both bullish crossovers align.
  • A Short order is submitted when both bearish crossovers align.
  • Once in a position, the script calculates ta.atr(14) and places a stop at 1.5 ATR from the average entry price.
  • The profit limit is 3 ATR from entry, which is a 2:1 target-to-stop-distance relationship before fees and fills.
  • The script sets commission to 0.1% in the strategy declaration. This is an assumption in the script, not a statement about your broker's actual costs.

Timeframes and markets

No symbol or timeframe is specified in the code. The calculations can run on any TradingView market and chart interval that has sufficient price history. Because crossover signals and ATR distances vary materially by market and interval, evaluate the Strategy Tester on the specific symbol, timeframe, session, and trading costs you intend to use.

Limitations

  • This is a crossover strategy, so it can enter after a move has already started and may be vulnerable to whipsaws in sideways conditions.
  • The EMA and MACD conditions must cross on the same bar; signals that occur a bar apart do not qualify.
  • The source does not contain divergence detection, volume analysis, support/resistance logic, or a visual dashboard.
  • Orders are processed with process_orders_on_close=false; TradingView's fill model and intrabar assumptions can affect backtest results. Verify behavior in TradingView before use.
  • The script is a strategy that can generate simulated orders in Strategy Tester; it is not a guarantee of future results.

Source

pinescript-v6 · full source

bow-arrow-indicator-with-dualspeed-macd-cycles-hidden-divergence-ema-regime.pine
// ============================================================================
// © algonexta
// This script is for education and research; it does not guarantee results.
// Verify this source in TradingView before use.
// ============================================================================

//@version=6
strategy("Bow  Arrow indicator with dualspeed MACD cycles hidden divergence EMA regime", overlay=true, pyramiding=0, commission_type=strategy.commission.percent, commission_value=0.1, process_orders_on_close=false)

// Generated with AlgoNexta Pine Studio
// https://algonexta.com
// Pine Script v6 — verify in TradingView before use.
// Generated deterministically from approved AlgoNexta strategy IR.
longCondition = ta.crossover(ta.ema(close, 9), ta.ema(close, 21)) and ta.crossover((ta.ema(close, 12) - ta.ema(close, 26)), ta.ema((ta.ema(close, 12) - ta.ema(close, 26)), 9))
shortCondition = ta.crossunder(ta.ema(close, 9), ta.ema(close, 21)) and ta.crossunder((ta.ema(close, 12) - ta.ema(close, 26)), ta.ema((ta.ema(close, 12) - ta.ema(close, 26)), 9))
if longCondition
    strategy.entry("Long", strategy.long)
if shortCondition
    strategy.entry("Short", strategy.short)
atrStop = ta.atr(14)
longStop = strategy.position_avg_price - atrStop * 1.5
shortStop = strategy.position_avg_price + atrStop * 1.5
if strategy.position_size > 0
    strategy.exit("Long Exit", "Long", stop=longStop, limit=strategy.position_avg_price + atrStop * 3)
if strategy.position_size < 0
    strategy.exit("Short Exit", "Short", stop=shortStop, limit=strategy.position_avg_price - atrStop * 3)
// Generation: AlgoNexta compiler-v17 · f2f658c0fca9

FAQ

Common questions.

What triggers a long or short trade?

A long requires a 9 EMA crossover above the 21 EMA and a bullish MACD-line crossover above its 9-period signal line on the same bar. A short requires the corresponding bearish crossunders.

Does this strategy detect hidden divergence or an EMA regime?

No. Those terms appear in the supplied strategy name, but the code only implements 9/21 EMA crossover confluence with a 12/26/9 MACD crossover, plus ATR exits.

How are the stop loss and target calculated?

The strategy uses ATR(14). Long and short stops are 1.5 ATR from the average entry price, while profit limits are 3 ATR from entry.

Does it repaint or place real trades automatically?

The code uses crossover functions on chart bars and does not use higher-timeframe lookahead or pivot-based future-bar confirmation. It submits TradingView strategy orders, but automated live execution requires separate alert and broker-automation setup; no alert conditions are defined in this source.

What markets and timeframes should I use?

The code does not prescribe a market or timeframe, so test it on the instrument and interval you plan to trade. EMA/MACD crossover frequency, ATR sizing, commissions, and fills can differ substantially across markets.

Is this financial advice, and where can I verify results?

No, this is not financial advice. TradingView Strategy Tester, using your selected symbol, timeframe, costs, and execution assumptions, is the source of truth for the strategy's simulated results.

Want a version tuned to your market?

Describe the change in plain English and AlgoNexta rebuilds it as a fresh Pine v6 script — with its own explanation, evidence, and walkthrough.

Build your own version

Educational content only — not financial advice. TradingView is the source of truth for live data, compilation, and Strategy Tester results.