//@version=6 // SEIHAI experiment 001, fixed-window v1.1.0. Compiled on TradingView 2026-11-11. No profitability claim. strategy("AI Lab 01 | SMA 20/60 cost experiment", overlay = true, initial_capital = 10000, currency = currency.USD, default_qty_type = strategy.fixed, default_qty_value = 0.01, pyramiding = 0, commission_type = strategy.commission.percent, commission_value = 0.10, slippage = 2, margin_long = 100, margin_short = 100, calc_on_every_tick = false, calc_on_order_fills = false, process_orders_on_close = false, use_bar_magnifier = false) int startAt = timestamp("01 Jan 2022 00:00 +0000") int endAt = timestamp("01 Jan 2025 00:00 +0000") float units = input.float(0.01, "Fixed BTC quantity (educational)", minval = 0.000001) if barstate.isfirst if startAt >= endAt runtime.error("Start must precede End.") if not timeframe.isdaily or timeframe.multiplier != 1 runtime.error("Use a 1D chart for this experiment.") if not chart.is_standard runtime.error("Use standard candles, not synthetic chart prices.") float fast = ta.sma(close, 20) float slow = ta.sma(close, 60) bool crossedUp = ta.crossover(fast, slow) bool crossedDown = ta.crossunder(fast, slow) bool warmed = bar_index >= 199 and not na(slow[1]) bool entryWindow = time >= startAt and time_close < endAt if barstate.isconfirmed if strategy.position_size > 0 and (crossedDown or time_close >= endAt) strategy.close("Long", comment = time_close >= endAt ? "Window end" : "Cross down") else if warmed and entryWindow and crossedUp and strategy.position_size == 0 strategy.entry("Long", strategy.long, qty = units) plot(fast, "SMA 20", color = color.orange, linewidth = 2) plot(slow, "SMA 60", color = color.blue, linewidth = 2) bgcolor(entryWindow ? color.new(color.blue, 94) : na, title = "Entry window")