// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// Process-orders probe 02 — process_orders_on_close=true (corpus default)
//
// Purpose: companion to probe 01 with identical signal logic but
// process_orders_on_close=true. Market entry submitted on the
// signal bar fills at the SAME bar's close. Cross-compare to
// probe-01 reveals next-bar-open shift between TV-default and
// current corpus default.
//
// Trade shape: identical to probe 01 — long-only EMA crossover
// gated by RSI<70, exit on EMA cross-under. ≥10 cycles over 36k
// bars.
//
// TV setup: 15m chart, ETH-USDT-USDT, same window as
// data/ohlcv_ETH-USDT-USDT_15m.csv. TradingView strategy report for this window.
//@version=6
strategy("PF process-orders 02 - on_close=true", shorttitle="POC_p02_TRUE", 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=true)
rsiVal = ta.rsi(close, 14)
emaFast = ta.ema(close, 9)
emaSlow = ta.ema(close, 21)
bool entryCond = ta.crossover(emaFast, emaSlow) and rsiVal < 70
bool exitCond = ta.crossunder(emaFast, emaSlow)
if entryCond and strategy.position_size == 0
strategy.entry("L", strategy.long, qty=1, comment="entry")
if exitCond and strategy.position_size > 0
strategy.close("L", comment="exit")