Mechanical SMC 38.2% Engine v6 - Fixed

oemabry · study · 39 行 · 点赞 1 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("Mechanical SMC 38.2% Engine v6 - Fixed", overlay=true)
 
// --- 1. Global Pre-Calculations (Fixes CW10002 Warning) ---
// All history-dependent function calls must execute unconditionally on every single bar
macro_high_60 = ta.highest(high, 60)
macro_low_60  = ta.lowest(low, 60)
macro_high_30 = ta.highest(high, 30)
 
cross_high_60 = ta.crossover(close, macro_high_60)
cross_low_60  = ta.crossunder(close, macro_low_60)
cross_high_30 = ta.crossover(close, macro_high_30)
 
// --- 2. Macro Structural Evaluation ---
macro_CHoCH = cross_high_60 or cross_low_60
macro_BOS   = cross_high_30 // 30-day structural continuation
 
// --- 3. Intraday Session Tracker ---
// FIX CE10123: Convert time change integer evaluation into an explicit boolean state
is_new_day = ta.change(time("D")) != 0
bars_since_open = ta.barssince(is_new_day)
 
// Prevent lookback engine compilation stalls on bar zero
valid_lookback = bars_since_open > 0 ? bars_since_open : 1
 
// Extract session metrics globally 
session_high = ta.highest(high, valid_lookback)
session_low  = ta.lowest(low, valid_lookback)
fib_382      = session_high - ((session_high - session_low) * 0.382)
 
// Extract intraday touchpoint crossings globally to prevent runtime memory gaps
cross_under_fib = ta.crossunder(low, fib_382)
 
// --- 4. Zero-Discretion Trigger Engine ---
long_trigger = (macro_BOS or macro_CHoCH) and cross_under_fib and (close > fib_382)
 
// --- 5. Pure Mechanical Chart Visualization ---
plot(fib_382, color=color.yellow, title="Intraday 38.2% Fib Level", style=plot.style_linebr)
plotshape(long_trigger, title="Mechanical Long Entry", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)

← 返回列表