CRV Precision Ichimoku + Intermarket Columns

EvaldasPaulikas · study · 178 行 · 点赞 2 · TradingView 原页

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

Pine Script

//@version=6
// CRV Precision Ichimoku + Post-Cross Confirmation + Intermarket Ratio Columns
// Strategic Upgrade: Normalized CRV/ETH and CRV/XRP performance lines embedded in the Risk Regime columns
 
indicator("CRV Precision Ichimoku + Intermarket Columns", shorttitle="CRV ICH PRO+", overlay=true, max_labels_count=500)
 
// ==========================================
// 1. INPUTS
// ==========================================
group_ichi = "Ichimoku Settings"
TKlength = input.int(9, "Tenkan-sen Length", minval=1, group=group_ichi)
KJlength = input.int(26, "Kijun-sen Length", minval=1, group=group_ichi)
CSHSlength = input.int(26, "Chikou Span Shift", minval=1, group=group_ichi)
SBlength = input.int(52, "Senkou Span B Length", minval=1, group=group_ichi)
 
group_filters = "Confirmation & Risk Regime Filters"
confirm_bars = input.int(2, "Bars to Confirm After Cross (1-5)", minval=1, maxval=5, group=group_filters)
use_rs_filter = input.bool(true, "Require CRV Outperforming BTC", group=group_filters)
use_mfi_filter = input.bool(true, "Require Positive Money Flow (MFI > 50)", group=group_filters)
use_chikou_filter = input.bool(true, "Require Chikou Span Clear of Cloud/Price", group=group_filters)
 
group_visuals = "Intermarket Visuals (Bottom Columns)"
show_eth = input.bool(true, "Show CRV/ETH Performance Line (Yellow)", group=group_visuals)
show_xrp = input.bool(true, "Show CRV/XRP Performance Line (Aqua)", group=group_visuals)
norm_lookback = input.int(100, "Normalization Lookback for Ratios", minval=10, tooltip="How many bars to scale the min/max of the ratio lines to fit the column area.", group=group_visuals)
 
// ==========================================
// 2. ICHIMOKU CALCULATIONS
// ==========================================
donchian(len) => (ta.highest(len) + ta.lowest(len)) / 2
 
TK = donchian(TKlength)
KJ = donchian(KJlength)
CS = close
SB = donchian(SBlength)
SA = (TK + KJ) / 2
 
cloud_top = math.max(SA, SB)
cloud_bottom = math.min(SA, SB)
inside_cloud = close <= cloud_top and close >= cloud_bottom
 
// ==========================================
// 3. MACRO & INTERMARKET PROXIES
// ==========================================
// A. Relative Strength: CRV vs BTC
btc_close = request.security("BINANCE:BTCUSDT", timeframe.period, close, gaps=barmerge.gaps_off)
crv_btc_ratio = close / btc_close
rs_ma = ta.sma(crv_btc_ratio, 20)
rs_bull = crv_btc_ratio > rs_ma
rs_bear = crv_btc_ratio < rs_ma
 
// B. Money Flow Index
mfi = ta.mfi(hlc3, 14)
mfi_bull = mfi > 50
mfi_bear = mfi < 50
 
// C. Intermarket Ratios: CRV vs ETH & XRP
eth_close = request.security("BINANCE:ETHUSDT", timeframe.period, close, gaps=barmerge.gaps_off)
xrp_close = request.security("BINANCE:XRPUSDT", timeframe.period, close, gaps=barmerge.gaps_off)
 
crv_eth_ratio = close / eth_close
crv_xrp_ratio = close / xrp_close
 
// ==========================================
// 4. POST-CROSS CONFIRMATION LOGIC
// ==========================================
bull_cross = ta.crossover(TK, KJ)
bear_cross = ta.crossunder(TK, KJ)
 
bars_since_bull = nz(ta.barssince(bull_cross), 999)
bars_since_bear = nz(ta.barssince(bear_cross), 999)
 
long_confirmed_setup = (bars_since_bull <= confirm_bars) and (close > KJ) and (close > cloud_top)
short_confirmed_setup = (bars_since_bear <= confirm_bars) and (close < KJ) and (close < cloud_bottom)
 
chikou_price_clear = close > ta.highest(high, CSHSlength)[CSHSlength]
chikou_cloud_clear = close > math.max(SA[CSHSlength], SB[CSHSlength])
chikou_clear_long = chikou_price_clear and chikou_cloud_clear
 
chikou_price_clear_short = close < ta.lowest(low, CSHSlength)[CSHSlength]
chikou_cloud_clear_short = close < math.min(SA[CSHSlength], SB[CSHSlength])
chikou_clear_short = chikou_price_clear_short and chikou_cloud_clear_short
 
// ==========================================
// 5. STRICT RISK ON / RISK OFF REGIMES
// ==========================================
is_risk_on = long_confirmed_setup and 
             (use_rs_filter ? rs_bull : true) and 
             (use_mfi_filter ? mfi_bull : true) and 
             (use_chikou_filter ? chikou_clear_long : true) and 
             not inside_cloud
 
is_risk_off = short_confirmed_setup and 
              (use_rs_filter ? rs_bear : true) and 
              (use_mfi_filter ? mfi_bear : true) and 
              (use_chikou_filter ? chikou_clear_short : true) and 
              not inside_cloud
 
is_neutral = not is_risk_on and not is_risk_off
 
// ==========================================
// 6. VISUAL PLOTTING: ICHIMOKU
// ==========================================
plot(TK, color=color.blue, linewidth=2, title="Tenkan-sen")
plot(KJ, color=color.red, linewidth=2, title="Kijun-sen")
plot(CS, offset=-CSHSlength, color=color.new(color.purple, 0), linewidth=2, title="Chikou Span")
 
senkouA_plot = plot(SA, offset=CSHSlength, color=color.green, linewidth=1, title="Senkou Span A")
senkouB_plot = plot(SB, offset=CSHSlength, color=color.new(color.purple, 0), linewidth=1, title="Senkou Span B")
fill(senkouA_plot, senkouB_plot, color=SA > SB ? color.new(color.green, 85) : color.new(color.red, 85), title="Kumo Cloud")
 
// ==========================================
// 7. VISUAL PLOTTING: RISK COLUMNS & INTERMARKET LINES
// ==========================================
// Define the column area boundaries
col_height = close * 0.03 
 
// 1. Risk Regime Columns (Background)
plot(is_risk_on ? col_height : na, style=plot.style_columns, color=color.new(color.green, 40), linewidth=8, title="Risk On Column")
plot(is_risk_off ? -col_height : na, style=plot.style_columns, color=color.new(color.red, 40), linewidth=8, title="Risk Off Column")
plot(is_neutral ? col_height * 0.1 : na, style=plot.style_columns, color=color.new(color.gray, 70), linewidth=2, title="Neutral Baseline")
 
// 2. Intermarket Ratio Normalization (Maps ratios to fit exactly inside the column area)
eth_min = ta.lowest(crv_eth_ratio, norm_lookback)
eth_max = ta.highest(crv_eth_ratio, norm_lookback)
crv_eth_norm = eth_max == eth_min ? 0 : -col_height + (crv_eth_ratio - eth_min) / (eth_max - eth_min) * (col_height * 2)
 
xrp_min = ta.lowest(crv_xrp_ratio, norm_lookback)
xrp_max = ta.highest(crv_xrp_ratio, norm_lookback)
crv_xrp_norm = xrp_max == xrp_min ? 0 : -col_height + (crv_xrp_ratio - xrp_min) / (xrp_max - xrp_min) * (col_height * 2)
 
// Plot Normalized Lines (Yellow for ETH, Aqua for XRP)
plot(show_eth ? crv_eth_norm : na, color=color.new(color.yellow, 0), linewidth=2, title="CRV/ETH Normalized")
plot(show_xrp ? crv_xrp_norm : na, color=color.new(color.aqua, 0), linewidth=2, title="CRV/XRP Normalized")
 
// Zero line for the column area (Middle baseline)
plot(0, color=color.new(color.white, 60), linewidth=1, style=plot.style_circles, title="Column Zero Line")
 
// ==========================================
// 8. CONFIRMED SIGNAL LABELS
// ==========================================
plotshape(is_risk_on and not is_risk_on[1], title="Confirmed Long", style=shape.labelup, location=location.belowbar, color=color.green, text="CONFIRMED\nLONG", textcolor=color.white, size=size.small)
plotshape(is_risk_off and not is_risk_off[1], title="Confirmed Short", style=shape.labeldown, location=location.abovebar, color=color.red, text="CONFIRMED\nSHORT", textcolor=color.white, size=size.small)
 
// ==========================================
// 9. REAL-TIME DASHBOARD
// ==========================================
var table dash = table.new(position.top_right, 2, 8, bgcolor=color.new(color.black, 80), border_width=1, frame_color=color.gray, frame_width=1)
if barstate.islast
    table.cell(dash, 0, 0, "System Status", text_color=color.white, bgcolor=color.new(color.blue, 50))
    table.cell(dash, 1, 0, "Reading", text_color=color.white, bgcolor=color.new(color.blue, 50))
    
    table.cell(dash, 0, 1, "Market Regime", text_color=color.white)
    table.cell(dash, 1, 1, is_risk_on ? "RISK ON" : is_risk_off ? "RISK OFF" : "NEUTRAL", text_color=is_risk_on ? color.green : is_risk_off ? color.red : color.yellow)
    
    table.cell(dash, 0, 2, "Cross Confirmation", text_color=color.white)
    table.cell(dash, 1, 2, long_confirmed_setup ? "Bullish Held" : short_confirmed_setup ? "Bearish Held" : "Waiting / Failed", text_color=long_confirmed_setup ? color.green : short_confirmed_setup ? color.red : color.gray)
    
    table.cell(dash, 0, 3, "CRV vs BTC (RS)", text_color=color.white)
    table.cell(dash, 1, 3, rs_bull ? "Outperforming" : "Underperforming", text_color=rs_bull ? color.green : color.red)
    
    table.cell(dash, 0, 4, "Money Flow (MFI)", text_color=color.white)
    table.cell(dash, 1, 4, str.tostring(mfi, "#.#"), text_color=mfi > 50 ? color.green : color.red)
    
    table.cell(dash, 0, 5, "Chikou Span", text_color=color.white)
    table.cell(dash, 1, 5, chikou_clear_long ? "Clear (Long)" : chikou_clear_short ? "Clear (Short)" : "Obstructed", text_color=chikou_clear_long ? color.green : chikou_clear_short ? color.red : color.gray)
 
    table.cell(dash, 0, 6, "CRV vs ETH (Yellow)", text_color=color.white)
    table.cell(dash, 1, 6, crv_eth_ratio > ta.sma(crv_eth_ratio, 20) ? "Outperforming" : "Underperforming", text_color=crv_eth_ratio > ta.sma(crv_eth_ratio, 20) ? color.green : color.red)
 
    table.cell(dash, 0, 7, "CRV vs XRP (Aqua)", text_color=color.white)
    table.cell(dash, 1, 7, crv_xrp_ratio > ta.sma(crv_xrp_ratio, 20) ? "Outperforming" : "Underperforming", text_color=crv_xrp_ratio > ta.sma(crv_xrp_ratio, 20) ? color.green : color.red)
 
// ==========================================
// 10. ALERTS
// ==========================================
alertcondition(is_risk_on and not is_risk_on[1], title="Confirmed LONG Signal", message="CRV CONFIRMED LONG: Post-cross validation + Macro + Intermarket aligned.")
alertcondition(is_risk_off and not is_risk_off[1], title="Confirmed SHORT Signal", message="CRV CONFIRMED SHORT: Post-cross validation + Macro + Intermarket aligned.")

← 返回列表