本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("InvestMode | Structural Trend & Risk Engine v6", overlay=true)
// =============================================================================
// ENGINE 1: TREND IDENTIFICATION (V6 METRICS)
// =============================================================================
int fastLength = input.int(21, title="Fast Trend Length", minval=1)
int slowLength = input.int(50, title="Slow Trend Length", minval=1)
float fastEMA = ta.ema(close, fastLength)
float slowEMA = ta.ema(close, slowLength)
plot(fastEMA, color=color.green, title="Fast Trend (21 EMA)", linewidth=2)
plot(slowEMA, color=color.red, title="Slow Trend (50 EMA)", linewidth=2)
// =============================================================================
// ENGINE 2: MATHEMATICAL RISK BOUNDARIES (V6 ATR CALCULATIONS)
// =============================================================================
int atrPeriod = input.int(14, title="ATR Period")
float atrMultiplier = input.float(2.0, title="Risk Multiplier (Stop Loss)")
float profitMultiplier = input.float(4.0, title="Target Multiplier (Take Profit)")
float atr = ta.atr(atrPeriod)
// =============================================================================
// ENGINE 3: SYSTEM SIGNALS & COMPILER FIXES
// =============================================================================
bool longEntrySignal = ta.crossover(fastEMA, slowEMA)
// Fixed V6 Shape Syntax Variables
plotshape(longEntrySignal,
title="InvestMode Entry",
style=shape.triangleup,
location=location.belowbar,
color=color.green,
size=size.small)
// =============================================================================
// PREMIUM FEATURES: HIGH-END DYNAMIC BRACKET RIBBONS
// =============================================================================
var float v6StopLoss = na
var float v6TakeProfit = na
if longEntrySignal
v6StopLoss := close - (atr * atrMultiplier)
v6TakeProfit := close + (atr * profitMultiplier)
else if close < v6StopLoss or close > v6TakeProfit
v6StopLoss := na
v6TakeProfit := na
// Plot structural target zones dynamically for the trader
plot(v6StopLoss, title="Dynamic OCO Floor (Stop Loss)", color=color.new(color.red, 30), style=plot.style_linebr, linewidth=2)
plot(v6TakeProfit, title="Dynamic OCO Ceiling (Take Profit)", color=color.new(color.blue, 30), style=plot.style_linebr, linewidth=2)
// =============================================================================
// AUTOMATED ALERT STRINGS
// =============================================================================
if longEntrySignal
alert("InvestMode Alert: Trend shift confirmed. Entry: " + str.tostring(close) + " | Stop-Loss: " + str.tostring(v6StopLoss) + " | Take-Profit: " + str.tostring(v6TakeProfit), alert.freq_once_per_bar_close)