// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// MTF probe 03 — ta.sma(close,20) computed *inside* 60m context via request.security
// Purpose: parity test for `ta.sma(close, 20)` evaluated INSIDE
// `request.security(..., "60", ...)` so SMA state runs on the HTF series, not
// resampled from LTF.
//
//@version=6
strategy("PF MTF probe 03 — 60m SMA(20)", shorttitle="MTF_p03", 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)
float htfSma = request.security(syminfo.tickerid, "60", ta.sma(close, 20), lookahead=barmerge.lookahead_off)
float htfCl = request.security(syminfo.tickerid, "60", close, lookahead=barmerge.lookahead_off)
bool longCond = htfCl > htfSma and htfCl[1] <= htfSma[1]
if longCond
strategy.entry("L", strategy.long, qty=1)
bool exitCond = htfCl < htfSma and strategy.position_size > 0
if exitCond
strategy.close("L")