Strategy · Pine Script v6 · On the chart

PineForge Compass Session Market

by pineforge-4pass· code credited to PineForge

A long-only session strategy that trades inside a configurable time window, 08:00 to 16:00 UTC by default.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code39
Settings6inputs
LicenceApache-2.0
Last update6 days ago23 Oct 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

39 lines of Pine Script v6 from validation/session-compass-utc-market-window-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
//@version=6
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 PineForge
// PineForge Corporate Strategy: Compass Session Market
strategy("PineForge — Compass Session Market", overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity, default_qty_value=7,
     pyramiding=0, commission_type=strategy.commission.percent,
     commission_value=0.05, slippage=1,
     margin_long=100, margin_short=100,
     process_orders_on_close=false, calc_on_order_fills=false)

tradeSession = input.session("0800-1600", "Trade Session", group="Session")
tradeTimezone = input.string("Etc/UTC", "Session Timezone", group="Session")
fastLength = input.int(16, "Fast EMA", minval=2, group="Signal")
slowLength = input.int(44, "Slow EMA", minval=3, group="Signal")
atrLength = input.int(14, "ATR Length", minval=2, group="Risk")
stopAtr = input.float(2.0, "Stop ATR", minval=0.5, step=0.1, group="Risk")

insideSession = not na(time(timeframe.period, tradeSession, tradeTimezone))
wasInside = insideSession[1]
sessionOpened = insideSession and not wasInside
sessionClosed = not insideSession and wasInside

fastEma = ta.ema(close, fastLength)
slowEma = ta.ema(close, slowLength)
atrValue = ta.atr(atrLength)

if insideSession and (sessionOpened or ta.crossover(fastEma, slowEma))
    strategy.entry("Compass Long", strategy.long)

if sessionClosed
    strategy.close("Compass Long", comment="Session flatten")

if strategy.position_size > 0
    strategy.exit("Compass Guard", from_entry="Compass Long",
         stop=strategy.position_avg_price - atrValue * stopAtr)

bgcolor(insideSession ? color.new(color.blue, 90) : na)

Overview

PineForge Compass Session Market enters long at the start of the window or when a 16-period EMA crosses above a 44-period EMA inside it, and closes the position when the window ends. Each trade has an ATR-based protective stop. Inputs set the session, time zone, EMA lengths, ATR length and stop multiple. The session is shaded on the price chart background, and size is a percentage of equity.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Sessions & time, Moving averages

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.

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

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

SettingTypeDefaultVariable
Trade Sessionsession0800-1600tradeSession
Session TimezonestringEtc/UTCtradeTimezone
Fast EMAint16fastLength
Slow EMAint44slowLength
ATR Lengthint14atrLength
Stop ATRfloat2.0stopAtr
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

This overlay strategy offers two selectable entry modes: a Bollinger squeeze on typical price and a simple moving-average cross. It filters trades by weekday, session, date range, and an optional news window, and can restrict direction or invert the side. Risk

Strategy v5 Volatility & bandsMoving averages
Updated yesterday · None stated GitHub repository of Boilerplate Configurable Strategy [Yosiet]
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
39 stars

This intraday strategy implements Mark Fisher's Opening Range Breakout (ORB) methodology tailored for index futures like ES and NQ. It calculates session opening ranges, volume z-scores, and VWAP bands to plot support, resistance, and confirmation levels on th

Strategy v6 BreakoutSessions & time Repaints
Updated 5 days ago · MIT GitHub repository of Futures Intraday Pro (ES/NQ) Strategy

P404 Smoke

by Musyimi97
16 stars

P404 Smoke is a price-chart strategy that sequences an optional higher-timeframe EMA bias, a liquidity range from recent pivots, a sweep of buy-side or sell-side liquidity, and a market structure shift within a set bar window. Comments state it then looks for

Strategy v5 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · MIT GitHub repository of P404 Smoke

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