// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF TV golden 42 - close immediately vs next-bar market close
//
// Purpose: compare strategy.close(..., immediately=true) with ordinary strategy.close().
// 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 TV golden 42 - close immediate", shorttitle="PF_G42_CLOSE", 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 == 2 and minute == 15 and strategy.position_size == 0
strategy.entry("NEXT", strategy.long, qty=1, comment="normal close case")
if hour == 3 and minute == 15 and strategy.position_size > 0
strategy.close("NEXT", comment="normal close")
if hour == 10 and minute == 15 and strategy.position_size == 0
strategy.entry("IMM", strategy.long, qty=1, comment="immediate close case")
if hour == 11 and minute == 15 and strategy.position_size > 0
strategy.close("IMM", comment="immediate close", immediately=true)