Strategy · Pine Script v6 · On the chart

EUR/USD Forex Strategy [trugurpala]

by trugurpala

This strategy trades on the price chart using a fast and slow exponential moving average crossover.

View on GitHub

Repaints

GitHub stars4on the repository
Pine versionv6current
Lines of code61
Settings5inputs
LicenceMIT
Last update2 months ago3 Aug 2026

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 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

61 lines of Pine Script v6 from global-markets/05_eurusd_forex.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

05_eurusd_forex.pine
//@version=6
// EUR/USD Forex Strategy — London + NY Session
// github.com/trugurpala/pinescriptv6 — Author: Ugur Pala
//
// TR: Sembol: FX:EURUSD / OANDA:EURUSD / FXCM:EURUSD
// EN: Symbol: FX:EURUSD / OANDA:EURUSD / FXCM:EURUSD
//
// En Aktif Seanslar / Most Active Sessions:
// London: 08:00–16:00 GMT
// New York: 13:00–21:00 GMT
// Overlap (en iyi): 13:00–16:00 GMT
strategy("EUR/USD Forex Strategy [trugurpala]",
    overlay           = true,
    initial_capital   = 10000,
    default_qty_type  = strategy.percent_of_equity,
    default_qty_value = 2,
    commission_type   = strategy.commission.percent,
    commission_value  = 0.005,  // ~0.5 pip spread
    slippage          = 1)

// ── Inputs ───────────────────────────────────────────────────────────────────
int   fastLen   = input.int(9,    "Fast EMA",  minval=1)
int   slowLen   = input.int(21,   "Slow EMA",  minval=1)
int   atrLen    = input.int(14,   "ATR",       minval=1)
float slMult    = input.float(1.5, "SL Mult",  step=0.1)
float tpMult    = input.float(2.0, "TP Mult",  step=0.1)

// ── London + NY Seans Filtresi ────────────────────────────────────────────────
bool london = not na(time(timeframe.period, "0800-1600", "GMT"))
bool newYork = not na(time(timeframe.period, "1300-2100", "GMT"))
bool inSession = london or newYork

// ── Hesaplamalar ──────────────────────────────────────────────────────────────
float fastEma  = ta.ema(close, fastLen)
float slowEma  = ta.ema(close, slowLen)
float atrVal   = ta.atr(atrLen)

bool bullCross = ta.crossover(fastEma,  slowEma) and inSession
bool bearCross = ta.crossunder(fastEma, slowEma) and inSession

// ── Entries ──────────────────────────────────────────────────────────────────
if bullCross
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", "Long",
        stop  = close - slMult * atrVal,
        limit = close + tpMult * atrVal)

if bearCross
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", "Short",
        stop  = close + slMult * atrVal,
        limit = close - tpMult * atrVal)

// ── Visuals ──────────────────────────────────────────────────────────────────
bgcolor(london and newYork ? color.new(color.green, 96) : // Overlap — en aktif
        inSession           ? color.new(color.blue, 96)  :
                              color.new(color.gray, 97))
plot(fastEma, "Fast", fastEma > slowEma ? color.green : color.red,    linewidth=2)
plot(slowEma, "Slow", fastEma > slowEma ? color.lime  : color.orange, linewidth=2)
plotshape(bullCross, "Long",  shape.triangleup,   location.belowbar, color.green)
plotshape(bearCross, "Short", shape.triangledown, location.abovebar, color.red)

Overview

EUR/USD Forex Strategy [trugurpala] enters long when the fast EMA crosses above the slow EMA and short when it crosses below, but only during the London or New York session in GMT. Each entry sets an ATR-based stop and a larger ATR-based limit target. The inputs change EMA lengths, ATR length, and the stop and target multiples. It plots both EMAs, entry markers, and a session background. Signals can change before the live bar closes.

Details

Published by

trugurpala on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Trend, Moving averages, Sessions & time

Markets

Forex

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Topics

aialgorithmic-tradingclaude-codecodexcoding-agentsgithub-copilotopen-sourcepine-scriptpine-script-v6technical-analysis

Settings

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

SettingTypeDefaultVariable
Fast EMAint9fastLen
Slow EMAint21slowLen
ATRint14atrLen
SL Multfloat1.5slMult
TP Multfloat2.0tpMult
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

257 stars

Donald - Test Logic Futures is an overlay strategy designed for intraday futures trading. It combines kernel regression functions with exponential moving averages to evaluate price retracements and entry timing. Trades are filtered by session execution windows

Strategy v5 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald - Test Logic Futures

Andean Scalping

by hasnocool
106 stars

Andean Scalping is a Pine Script v5 strategy template designed for backtesting trading signals. It features session and date-range filtering, directional trade toggles for long and short entries, and optional trend filtering tools including higher-timeframe EM

Strategy v5 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of Andean Scalping

This strategy plots a 90-period simple moving average from the daily and four-hour charts plus a daily session VWAP on the price chart. It enters long when VWAP is above the daily average and the four-hour VWAP crosses above its average, and short in the oppos

Strategy v5 TrendMoving averages Repaints
Updated 3 years ago · MIT GitHub repository of 1D Bullish Buy 4H Bearish Sell Session
4 stars

This strategy executes trades on 5-minute index futures using Exponential Moving Averages, RSI, ADX, and volume filters across multiple timeframes. It supports trend pullback and VWAP reversion regimes with entry confirmation on breakout of prior high or low p

Strategy v6 TrendMean reversion
Updated yesterday · None stated GitHub repository of Lucid 100K Prop Bot (MES 5m)

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