Strategy · Pine Script v6 · On the chart

PF probe 72 - opposite entry close

by pineforge-4pass· code credited to PineForge contributors 2026

This strategy runs on the price chart and enters long positions at the top of each hour when the position is flat.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code33
Settings0inputs
LicenceApache-2.0
Last update5 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

33 lines of Pine Script v6 from validation/order-opposite-entry-close-same-pass-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe 72 - opposite entry and close same pass
//
// Purpose: isolate source-order behavior when an opposite strategy.entry and
// strategy.close target the current position in the same pass.
// TV setup: 15m chart, same symbol/window as data/ohlcv_ETH-USDT-USDT_15m.csv.
// Export TradingView "List of trades" to trades.csv in this folder.
//@version=6
strategy("PF probe 72 - opposite entry close", shorttitle="PF_P72_OPPCLOSE", overlay=true,
     initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0, slippage=0,
     default_qty_type=strategy.fixed, default_qty_value=1, pyramiding=1,
     process_orders_on_close=false)

if hour == 0 and minute == 15 and strategy.position_size == 0
    strategy.entry("L", strategy.long, qty=1, comment="open long")

if hour == 0 and minute == 45 and strategy.position_size > 0
    strategy.entry("S", strategy.short, qty=1, stop=low - syminfo.mintick, comment="opposite stop first")
    strategy.close("L", comment="close long second")

if hour == 6 and minute == 15 and strategy.position_size == 0
    strategy.entry("L2", strategy.long, qty=1, comment="open long2")

if hour == 6 and minute == 45 and strategy.position_size > 0
    strategy.close("L2", comment="close long first")
    strategy.entry("S2", strategy.short, qty=1, stop=low - syminfo.mintick, comment="opposite stop second")

if hour == 12 and minute == 15 and strategy.position_size < 0
    strategy.close_all(comment="cleanup short")

Overview

PF probe 72 - opposite entry close then closes those longs at the end of the hour while simultaneously entering a short position with a stop loss just below the low. Later in the hour it closes the new short and enters a fresh long. At midday it exits any remaining shorts. The probe verifies that strategy.entry and strategy.close calls targeting the current position in the same bar pass execute in the exact order written in the script. No user-adjustable inputs exist and the default quantity is one unit. The script draws directly on the main price pane.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Sessions & time, Mean reversion

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

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

3C QFL Mean Reversal

by hasnocool
106 stars

3C QFL Mean Reversal is a strategy based on the Quickfinger Luc (QFL) trading methodology. It identifies breakdown buying opportunities below established price base levels and enters mean-reversion trades. The strategy includes multi-safety order DCA scaling,

Strategy v5 Mean reversionSupport & resistance Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 3C QFL Mean Reversal
13 stars

This strategy overlays the price chart to trade DAX futures during European market hours. It calculates exponential and simple moving averages, RSI, MACD, Bollinger Bands, ATR, and realized volatility to simulate VIX levels. Trades execute when session time fi

Strategy v5 Sessions & timeOscillators & momentum
Updated 8 months ago · Custom licence GitHub repository of ClaudeHedge - DAX Session Strategy
5 stars

This strategy enters one long trade when the bar low comes within a set point tolerance of the prior day's low and the close finishes above that level. Entries are allowed only inside a UTC session and are blocked after a Friday cutoff hour. It stays flat unti

Strategy v5 Support & resistanceMean reversion Repaints
Updated 4 months ago · MIT GitHub repository of PDL — Prior Day Level Retest (Bull)
4 stars

This strategy trades opening gap fades on the DAX index during the European Xetra session. At the 09:00 CET market open, it measures the opening price against the previous close relative to an ATR threshold. If a gap exceeds the threshold, it fades the move by

Strategy v6 Mean reversionSessions & time
Updated 2 months ago · MIT GitHub repository of DAX Gap Fade [trugurpala]
4 stars

Lucid 100K is an automated evaluation strategy tailored for micro futures contracts such as MES, MGC, and MNQ on lower timeframes. It operates a two-phase state machine that moves from an initial risk-averse lock-in phase to an expanded payout phase once targe

Strategy v6 TrendMean reversion
Updated yesterday · None stated GitHub repository of Lucid 100K (MES/MGC/MNQ)
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 周末布林带策略

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