Strategy · Pine Script v6 · On the chart

PineForge Gatekeeper Risk Cap

by pineforge-4pass· code credited to PineForge

This Pine Script v6 strategy gates long trades to a user-defined session window (default 0900-1700 Asia/Taipei) and enforces a maximum daily filled orders limit.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code38
Settings7inputs
LicenceApache-2.0
Last update7 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

38 lines of Pine Script v6 from validation/cap-gatekeeper-intraday-risk-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: Gatekeeper Risk Cap
// A session gate and runtime filled-order cap bound daily execution.
strategy("PineForge — Gatekeeper Risk Cap", overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.fixed, default_qty_value=2,
     pyramiding=0, commission_type=strategy.commission.percent,
     commission_value=0.05, slippage=1,
     margin_long=100, margin_short=100,
     process_orders_on_close=true, calc_on_order_fills=false)

tradeSession = input.session("0900-1700", "Trade Session", group="Session")
sessionTimezone = input.string("Asia/Taipei", "Session Timezone", group="Session")
maxDailyFills = input.int(4, "Maximum Daily Filled Orders", minval=1, maxval=20, group="Risk")
fastLength = input.int(10, "Fast EMA", minval=2, group="Signal")
slowLength = input.int(31, "Slow EMA", minval=3, group="Signal")
atrLength = input.int(14, "ATR Length", minval=2, group="Risk")
stopAtr = input.float(1.8, "Stop ATR", minval=0.5, step=0.1, group="Risk")

strategy.risk.max_intraday_filled_orders(maxDailyFills)
newDay = timeframe.change("1D")
inSession = not na(time(timeframe.period, tradeSession, sessionTimezone))
fastEma = ta.ema(close, fastLength)
slowEma = ta.ema(close, slowLength)
atrValue = ta.atr(atrLength)

if inSession and ta.crossover(fastEma, slowEma)
    strategy.entry("Gatekeeper Long", strategy.long)
if strategy.position_size > 0 and (not inSession or newDay)
    strategy.close("Gatekeeper Long", comment="Session boundary")
if strategy.position_size > 0
    strategy.exit("Gatekeeper Guard", from_entry="Gatekeeper Long",
         stop=strategy.position_avg_price - atrValue * stopAtr)

plot(fastEma, "Fast EMA", color=color.green)
plot(slowEma, "Slow EMA", color=color.red)

Overview

PineForge Gatekeeper Risk Cap generates entries solely on fast EMA crossover above the slow EMA while inside the session. Positions automatically close at session boundary or new day. A trailing-style stop loss uses ATR multiplier on average entry price. EMAs are plotted on the main price chart. Inputs customize session timezone, EMA lengths, ATR period, stop distance, and maximum daily fills. No pyramiding or short entries supported.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge, as written in the script's header

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.

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 Sessionsession0900-1700tradeSession
Session TimezonestringAsia/TaipeisessionTimezone
Maximum Daily Filled Ordersint4maxDailyFills
Fast EMAint10fastLength
Slow EMAint31slowLength
ATR Lengthint14atrLength
Stop ATRfloat1.8stopAtr
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 2 days ago · None stated GitHub repository of Boilerplate Configurable Strategy [Yosiet]
4 stars

This strategy trades directional momentum breakouts for crude oil on the price chart. It enters long or short positions when a fast exponential moving average crosses a slow exponential moving average, provided that current Average True Range exceeds its movin

Strategy v6 TrendMoving averages
Updated 2 months ago · MIT GitHub repository of CL Crude Oil Momentum [trugurpala]
3 stars

This strategy plots Bollinger bands and a simple moving average on the price chart. It opens a short when price crosses above the upper band while below the average, and a long when price crosses below the lower band while above the average. Entries are allowe

Strategy v5 Volatility & bandsMoving averages
Updated 2 years ago · None stated GitHub repository of 周末布林带策略

Session Wicks

by g-moe
3 stars

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

Strategy v5 TrendMoving averages Repaints
Updated 5 months ago · None stated GitHub repository of Session Wicks

3Commas Bot

by regalouisei
2 stars

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

Strategy v5 TrendMoving averages
Updated 8 months ago · None stated GitHub repository of 3Commas Bot
2 stars

Gold Multi-TF NYSE Scalper v2 is an intraday trading strategy for XAUUSD that seeks momentum entries by aligning RSI and EMA bias across multiple timeframes. It filters trades using an optional NYSE session clock and an ATR volatility spike check. Entries exit

Strategy v6 Oscillators & momentumVolatility & bands
Updated 9 days ago · None stated GitHub repository of Gold Multi-TF NYSE Scalper v2

More Sessions & time 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