// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe scalping-probe-02-fast-ma-trigger — short-period EMA cross flip-on-cross
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolates the short-period EMA cross trigger surface that drives
// most scalp strategies' direction signal. Two EMAs (5 and 13) generate
// flat-flip entries on `ta.crossover` / `ta.crossunder` with no bracket,
// no filters — pure cross-on-cross. The engine surface under test is the
// EMA recursion warmup precision and the `ta.crossover`/`ta.crossunder`
// strict-inequality semantics: TV uses `now > prev_other and prev <=
// prev_other` so the engine's edge detector must follow exactly the same
// rule, especially around equal-EMA touches.
//
// Validation goal: bit-exact trade list against TradingView's broker emulator
// on the reference 15-minute ETH-USDT-USDT feed.
//
// TV setup: 15m chart, ETH-USDT-USDT (Binance USDT-M Perpetual). Full window
// matching corpus/data/ohlcv_ETH-USDT-USDT_15m.csv. Strategy properties:
// leave defaults from script header. Export "List of trades" → tv_trades.csv.
//@version=6
strategy("PF probe scalping-probe-02-fast-ma-trigger", shorttitle="PF_SC02_MA",
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)
// ---- inputs --------------------------------------------------------
int i_fast = input.int(5, "Fast EMA", minval=2, maxval=50)
int i_slow = input.int(13, "Slow EMA", minval=3, maxval=100)
// ---- EMA pair + cross ---------------------------------------------
float ema_fast = ta.ema(close, i_fast)
float ema_slow = ta.ema(close, i_slow)
bool long_signal = ta.crossover(ema_fast, ema_slow)
bool short_signal = ta.crossunder(ema_fast, ema_slow)
// ---- flip-on-cross entries ----------------------------------------
if long_signal
strategy.entry("L", strategy.long, qty=1, comment="ma flip long")
if short_signal
strategy.entry("S", strategy.short, qty=1, comment="ma flip short")