// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF TA-isolate probe 12 — matrix.transpose round-trip (mask → mT → mTT)
// Purpose: parity test for `matrix.transpose()` (mask 24×7 → mT 7×24 → mTT
// 24×7 round-trip) followed by `matrix.get(mTT, h, d)` sampling — no
// hot-count loop, so the only matrix surface under test is transpose.
//
//@version=6
strategy("PF TA isolate 12 - sample only no hotCount", shorttitle="TAI_12_SAMPLE", 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)
var matrix<bool> mask = matrix.new<bool>(24, 7, false)
rsiVal = ta.rsi(close, 14)
int h = hour(time)
int d = dayofweek(time) - 1
if not na(rsiVal) and rsiVal > 60.0 and h >= 0 and h < 24 and d >= 0 and d < 7
matrix.set(mask, h, d, true)
var matrix<bool> mT = matrix.new<bool>(7, 24, false)
var matrix<bool> mTT = matrix.new<bool>(24, 7, false)
mT := matrix.transpose(mask)
mTT := matrix.transpose(mT)
bool sample = matrix.get(mTT, h < 24 ? h : 0, d >= 0 and d < 7 ? d : 0)
bool entryCond = sample and rsiVal > 55.0
bool exitCond = not na(rsiVal) and rsiVal < 45.0
if entryCond and strategy.position_size == 0
strategy.entry("L", strategy.long, qty=1, comment="entry long")
if exitCond and strategy.position_size > 0
strategy.close("L", comment="exit long")