Strategy · Pine Script v6 · On the chart

VİOP Session Strategy

by kierbica

This strategy trades BIST30 futures on the price chart using a fast 9-period and slow 21-period EMA crossover signal.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code111
Settings6inputs
LicenceMIT
Last update6 months ago23 Apr 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

111 lines of Pine Script v6 from examples/strategies/11_viop_session_strategy.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

11_viop_session_strategy.pine
//@version=6
// VİOP Session Strategy — BIST30 Futures Seans Bazlı
// Author: Ugur Pala · github.com/trugurpala/pinescriptv6
// TradingView: https://tr.tradingview.com/u/trugurpala/
//
// TR: VİOP (Türkiye vadeli işlem piyasası) için seans bazlı strateji.
//     09:30-18:15 UTC+3 seans saatleri içinde işlem yapar.
//     Seans kapanışında tüm pozisyonlar otomatik kapatılır.
//     ATR tabanlı SL/TP, EMA cross sinyali.
//
// EN: Session-based strategy for VIOP (Turkish futures market).
//     Only trades within market hours: 09:30-18:15 UTC+3.
//     All positions auto-closed at session end.
//     ATR-based SL/TP, EMA cross signal.
//
// Sembol / Symbol: BIST:XU030D1! veya F_XU030 (VİOP)
// Önerilen TF / Recommended TF: 5M, 15M, 1H
//
// LESSONS_LEARNED uygulanan düzeltmeler:
//   - alertcondition() → alert() (strategy içinde çalışmaz)
//   - barstate.islast label kaldırıldı → bgcolor ile seans gösterimi
//   - calc_on_every_tick kaldırıldı (default false — backtest güvenilir)

strategy("VİOP Session Strategy [trugurpala]",
    overlay              = true,
    initial_capital      = 100000,
    default_qty_type     = strategy.fixed,
    default_qty_value    = 1,
    commission_type      = strategy.commission.cash_per_contract,
    commission_value     = 2.0,
    slippage             = 2)

// ── Inputs ───────────────────────────────────────────────────────────────────
int   fastLen  = input.int(9,    "Fast EMA",        minval=1,   group="Sinyal / Signal")
int   slowLen  = input.int(21,   "Slow EMA",        minval=1,   group="Sinyal / Signal")
int   atrLen   = input.int(14,   "ATR Length",      minval=1,   group="Risk")
float slMult   = input.float(2.0, "SL (ATR ×)",     step=0.1,   group="Risk",
    tooltip="TR: ATR çarpanı — stop loss mesafesi\nEN: ATR multiplier — stop loss distance")
float tpMult   = input.float(3.0, "TP (ATR ×)",     step=0.1,   group="Risk",
    tooltip="TR: ATR çarpanı — take profit mesafesi\nEN: ATR multiplier — take profit distance")
bool  longOnly = input.bool(false, "Sadece Long / Long Only", group="Sinyal / Signal",
    tooltip="TR: Sadece long pozisyon aç\nEN: Only open long positions")

// ── VİOP Seans Filtresi — 09:30-18:15 UTC+3 ──────────────────────────────────
// TR: Seans saatleri dışında sinyal üretilmez
// EN: No signals generated outside session hours
bool inSession = not na(time(timeframe.period, "0930-1815", "UTC+3"))

// TR: Seans kapanışında tüm pozisyonları kapat
// EN: Close all positions at session end
bool sesClose = not inSession and inSession[1]
if sesClose
    strategy.close_all(comment="Seans sonu / Session end")

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

// TR: Sinyal — seans içinde EMA kesişimi
// EN: Signal — EMA crossover within session
bool bullCross = ta.crossover(fastEma,  slowEma) and inSession
bool bearCross = ta.crossunder(fastEma, slowEma) and inSession

// ── Girişler / Entries ────────────────────────────────────────────────────────
if bullCross
    strategy.entry("Long", strategy.long, comment="EMA ↑")
    strategy.exit("Long SL/TP", "Long",
        stop  = close - slMult * atrVal,
        limit = close + tpMult * atrVal,
        comment_loss="SL", comment_profit="TP")

if bearCross and not longOnly
    strategy.entry("Short", strategy.short, comment="EMA ↓")
    strategy.exit("Short SL/TP", "Short",
        stop  = close + slMult * atrVal,
        limit = close - tpMult * atrVal,
        comment_loss="SL", comment_profit="TP")

// ── Alertler / Alerts ─────────────────────────────────────────────────────────
// TR: alert() strategy içinde çalışır, alertcondition() çalışmaz
// EN: alert() works inside strategies, alertcondition() does not
if bullCross
    alert("VİOP Long — " + syminfo.ticker + " @ " + str.tostring(close, "#.##"),
        alert.freq_once_per_bar)
if bearCross
    alert("VİOP Short — " + syminfo.ticker + " @ " + str.tostring(close, "#.##"),
        alert.freq_once_per_bar)
if sesClose
    alert("VİOP Seans Sonu — pozisyonlar kapatıldı / session closed",
        alert.freq_once_per_bar)

// ── Görseller / Visuals ───────────────────────────────────────────────────────
// TR: Seans içi mavi arka plan, dışı gri
// EN: Blue background inside session, gray outside
bgcolor(inSession ? color.new(color.blue, 96) : color.new(color.gray, 97),
    title="Seans / Session BG")

plot(fastEma, "Fast EMA", bullish ? color.green : color.red,    linewidth=2)
plot(slowEma, "Slow EMA", bullish ? color.lime  : color.orange, linewidth=2)

plotshape(bullCross, "Long Signal",  shape.triangleup,
    location.belowbar, color.new(color.green, 0), size=size.normal)
plotshape(bearCross, "Short Signal", shape.triangledown,
    location.abovebar, color.new(color.red,   0), size=size.normal)

// TR: Seans durumu — plot ile göster (label yerine, uyarısız)
// EN: Session status — shown via plot (no warning, unlike label)
plotchar(inSession, "Seans / Session", "●",
    location.top, color.new(color.blue, 40), size=size.tiny)

Overview

VİOP Session Strategy generates buy signals only during Turkish market session hours of 09:30-18:15 UTC+3 and closes all positions automatically at session end. ATR-based stop loss and take profit levels are calculated with user-adjustable multipliers of 2 and 3 respectively. Long positions only mode is available as an input option. The strategy uses standard strategy settings with fixed position sizing.

Details

Published by

kierbica on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

M15-H1

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.

Settings

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

SettingTypeDefaultVariable
Fast EMAint9fastLen
Slow EMAint21slowLen
ATR Lengthint14atrLen
SL (ATR ×)float2.0slMult
TP (ATR ×)float3.0tpMult
Sadece Long / Long OnlyboolfalselongOnly
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

106 stars

This trading strategy combines three Exponential Moving Averages (8, 14, and 50 periods by default) with Stochastic RSI and Average True Range (ATR). It enters a long position when EMA 1 is above EMA 2, EMA 2 is above EMA 3, and the Stochastic RSI %K line cros

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 3 x EMA + Stochastic RSI + ATR

Momentum Rider DAILY FINAL

by greenpeas007
58 stars

This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute

Strategy v6 TrendOscillators & momentum Repaints
Updated 4 months ago · Custom licence GitHub repository of Momentum Rider DAILY FINAL
57 stars

This strategy identifies trend reversals through market structure changes (CHoCH) filtered by MACD momentum. It initiates long positions on bullish structure breaks when MACD is positive and above its signal line, and short positions on bearish breaks when MAC

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints
Updated 1 year ago · Apache-2.0 GitHub repository of Market Structure MACD 4H + Trailing

CombinedBinHAndClucV6

by viktors1982
36 stars

CombinedBinHAndClucV6 is a trading strategy based on the popular BinHV45 and ClucMay72018 algorithms. It calculates dual Bollinger Bands, Exponential Moving Averages, Relative Strength Index, Average True Range, and volume metrics across primary and one-hour h

Strategy v4 Volatility & bandsOscillators & momentum Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV6
27 stars

LuxAlgo Hybrid Gold Scalper is a price-chart strategy aimed at gold. It stacks a fast, slow, trend and 200-period bias EMA to mark trend direction, then filters strength with RSI, ADX and an intraday VWAP. Swing highs and lows are marked from pivot length. Set

Strategy v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of LuxAlgo Hybrid Gold Scalper

More Trend scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers