//@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.
// Giriş sinyalleri ve giriş emri oluşturma 09:30-18:15 UTC+3 seansıyla sınırlıdır.
// Çıkışlar ve dolumlar bu seansın dışında gerçekleşebilir.
// Seans içi çalışmayı izleyen ilk uygun seans dışı grafik çalışmasında close_all() çağrılır; dolum ayrıca doğrulanmalıdır.
// ATR tabanlı SL/TP, EMA cross sinyali.
//
// EN: Session-based strategy for VIOP (Turkish futures market).
// Entry signals and entry-order creation are gated to 09:30-18:15 UTC+3.
// Exits and fills can occur outside that session.
// close_all() is called on the first available out-of-session chart execution after an in-session execution; any fill needs separate verification.
// 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() can compile in a strategy but does not create selectable strategy alertcondition events; alert() is used
// - barstate.islast label kaldırıldı → bgcolor ile seans gösterimi
// - calc_on_every_tick kaldırıldı (default false; backtest realism still depends on fills, data, and costs)
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: sesClose, seans içi çalışmayı izleyen ilk uygun seans dışı grafik çalışmasında true olur.
// EN: sesClose is true only on the first available out-of-session chart execution after an in-session execution.
// TR: Grafik çalışması yoksa kapatma isteği de yoktur.
// EN: No chart execution means no close request.
// TR: close_all() kapatma ister; oluşturulan emir varsayılan ayarlarda normalde daha sonra dolar.
// EN: close_all() requests a close; any created order normally fills later under default settings.
// TR: Seans alarmı pozisyon yokken de çalışabilir ve emir dolum onayı değildir.
// EN: The session alert can fire while flat and is not an order-fill confirmation.
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: alertcondition() stratejide derlenebilir ancak seçilebilir olay oluşturmaz; alert() kullanılır
// EN: alertcondition() can compile in a strategy but does not create selectable strategy alertcondition events; alert() is used
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 — close_all() çağrıldı, dolum doğrulanmadı / close_all() called, fill unverified",
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 opens positions when a fast exponential moving average crosses a slow one, but only while chart time falls inside the 09:30 to 18:15 UTC+3 session. Stop loss and take profit distances are multiples of ATR. A long-only switch disables short entries. After an in-session execution, the first later out-of-session chart run calls close all, while exits and fills may still occur outside the session. Quantity is one fixed contract.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Fast EMA
int
9
fastLen
Slow EMA
int
21
slowLen
ATR Length
int
14
atrLen
SL (ATR ×)
float
2.0
slMult
TP (ATR ×)
float
3.0
tpMult
Sadece Long / Long Only
bool
false
longOnly
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.
This strategy executes long and short trades on the price chart by combining multi-timeframe smoothed Heikin-Ashi trends, higher-timeframe Hull Moving Average variations, and an ATR-based trailing stop. Users can adjust timeframes, smoothing lengths, Hull form
This strategy draws two moving averages on the price chart and uses their bias to open long or short trades. It places the stop beyond a swing high or low using an ATR risk multiple, then sets a limit exit from the reward-to-risk ratio. An optional ATR trail c
The IBKR Safe Forex Strategy is a Pine Script v6 strategy that trades forex pairs using crossovers of 10-period and 50-period EMAs, filtered by a 200-period EMA and restricted to London or New York session overlap. It enters long positions on fast EMA above sl
This Pine Script v6 strategy uses multi-timeframe analysis to identify intraday trends and generate trading signals. It requests higher-timeframe data for trend context via EMAs and Supertrend direction. On the local timeframe it plots EMA cross signals for lo
This strategy template provides a modular foundation for building TradingView v6 backtests. It uses a placeholder Exponential Moving Average crossover signal combined with customizable filters for higher-timeframe trend alignment, volatility regime thresholds,
This mean-reversion strategy plots Bollinger Bands and a long-term moving average directly on the price chart. It enters trades when price candles penetrate the outer Bollinger Bands beyond a user-defined body percentage, anticipating a price reversal. Entries