//@version=6
//
indicator('Elite Algo v6', shorttitle = 'Elite Algo', overlay = true, precision =
0, explicit_plot_zorder = true, max_labels_count = 500) // 修改了标题和短标题
symInfoCheck = false
symInfo = syminfo.ticker + ' | ' + timeframe.period + (timeframe.isminutes ? 'M' :
na)
date = str.tostring(dayofmonth(time_close)) + '/' + str.tostring(month(time_close))
+ '/' + str.tostring(year(time_close))
textVPosition = 'middle'
textHPosition = 'center'
width = 0
height = 0
c_title = #b2b5be80
s_title = 'large'
a_title = 'center'
c_subtitle = #b2b5be80
s_subtitle = 'normal'
a_subtitle = 'center'
c_bg = color.new(color.blue, 100)
// Close to Close Volatility
f_coc(x, period, sqrtAnnual) =>
mean = ta.sma(x, period)
s = array.new_float(0)
for i = 0 to period - 1 by 1
array.push(s, math.pow(x[i] - mean, 2))
sqrtAnnual * math.sqrt(array.sum(s) / (period - 1))
// Parkinson Volatility
f_park(period, sqrtAnnual) =>
var LOG2 = math.log(2)
powLogHighLow = math.pow(math.log(high / low), 2)
sqrtAnnual * math.sqrt(1.0 / period * math.sum(1.0 / (4.0 * LOG2) *
powLogHighLow, period))
// Garman Klass Volatility
f_gk(period, sqrtAnnual) =>
var LOG2 = math.log(2)
var SQRT_1_PERIOD = math.sqrt(1 / period)
powLogHighLow = math.pow(math.log(high / low), 2)
powLogCloseOpen = math.pow(math.log(close / open), 2)
tmp = 0.5 * powLogHighLow - (2.0 * LOG2 - 1.0) * powLogCloseOpen
sqrtAnnual * math.sqrt(math.sum(tmp, period)) * SQRT_1_PERIOD
// Rogers Satchell Volatility
f_rsv(period, sqrtAnnual) =>
tmp = math.log(high / close) * math.log(high / open) + math.log(low / close) *
math.log(low / open)
sqrtAnnual * math.sqrt(math.sum(tmp, period) / period)
// Garman Klass Yang Zhang Extension Volatility
f_gkyz(period, sqrtAnnual) =>
var LOG2 = math.log(2)
var SQRT_1_PERIOD = math.sqrt(1 / period)
powLogHighLow = math.pow(math.log(high / low), 2)
powLogCloseOpen = math.pow(math.log(close / open), 2)
lastClose = nz(close[1], close)
powLogOpenClose1 = math.pow(math.log(open / lastClose), 2)
tmp = powLogOpenClose1 + 0.5 * powLogHighLow - (2.0 * LOG2 - 1.0) *
powLogCloseOpen
sqrtAnnual * math.sqrt(math.sum(tmp, period)) * SQRT_1_PERIOD
// Yang Zhang Volatility
f_yz(a, period, sqrtAnnual) =>
oaman = math.log(open) - math.log(nz(close[1], close))
u = math.log(high) - math.log(open)
d = math.log(low) - math.log(open)
caman = math.log(close) - math.log(open)
nMinusOne = period - 1
avgo = ta.sma(oaman, period)
avgc = ta.sma(caman, period)
so = array.new_float(0)
sc = array.new_float(0)
for i = 0 to period - 1 by 1
array.push(so, math.pow(oaman[i] - avgo, 2))
array.push(sc, math.pow(caman[i] - avgc, 2))
sumo = array.sum(so)
sumc = array.sum(sc)
Vo = sumo / nMinusOne
Vc = sumc / nMinusOne
Vrs = math.sum(u * (u - caman) + d * (d - caman), period) / period
k = (a - 1.0) / (a + (period + 1.0) / nMinusOne)
sqrtAnnual * math.sqrt(Vo + k * Vc + (1.0 - k) * Vrs)
// Exponentially Weighted Volatility
f_ewma(source, period, sqrtAnnual) =>
var lambda = (period - 1) / (period + 1)
squared = math.pow(source, 2)
float v = na
v := lambda * nz(v[1], squared) + (1.0 - lambda) * squared
sqrtAnnual * math.sqrt(v)
// Mean Absolute Deviation (Adjusted)
f_mad(source, period, sqrtAnnual) =>
var SQRT_HALF_PI = math.sqrt(math.asin(1))
mean = ta.sma(source, period)
S = array.new_float(0)
for i = 0 to period - 1 by 1
array.push(S, math.abs(source[i] - mean))
sumS = array.sum(S)
sqrtAnnual * (sumS / period) * SQRT_HALF_PI
// Median Absolute Deviation
f_mead(source, period, sqrtAnnual) =>
median = ta.percentile_nearest_rank(source, period, 50)
E = 0.0
for i = 0 to period - 1 by 1
E := E + math.abs(source[i] - median)
E
sqrtAnnual * math.sqrt(2) * (E / period)
//Rescale Function
f_rescale(_src, _size) =>
math.max(0, math.min(_size, int(_src / 100 * _size)))
// label Panel Function
_label(T, color_PnL) =>
label PnL_Label = na
label.delete(PnL_Label[1])
PnL_Label := label.new(time, 0, text = T, color = color_PnL, textcolor =
color.white, size = size.normal, style = label.style_label_left, xloc =
xloc.bar_time, textalign = text.align_left)
label.set_x(PnL_Label, label.get_x(PnL_Label) + math.round(ta.change(time) *
3))
// Round Function
Round(src, digits) =>
p = math.pow(10, digits)
math.round(math.abs(src) * p) / p * math.sign(src)
//Options for Inputs - 直接赋值,不再需要广告检查
ON = 'On'
OFF = 'Off'
CTC = 'Close to Close'
PKS = 'Parkinson'
GK = 'Garman Klass'
RS = 'Rogers Satchell'
GKYZ = 'Garman Klass Yang Zhang Extension'
YZ = 'Yang Zhang'
EWMA = 'EWMA'
MAD = 'Mean Absolute Deviation'
MAAD = 'Median Absolute Deviation'
L = 'Line'
SL = 'StepLine'
Ar = 'Area'
CL = 'Columns'
// Settings - 直接赋值,不再需要广告检查
Haman = EWMA
period = 10
Annual = 365
a = 1.34
Plen = 365
Pco = ON
sma = ON
malen = 55
bsg = OFF
stl = CL
lT = 3
i_invert = OFF
bg = OFF
sp = OFF
// bgcolor(bg ? color.new(#000000, 20) : na, title='深色背景', transp=90)
var sqrtAnnual = math.sqrt(Annual) * 100
logr = math.log(close / close[1])
// Historical Volatiity Models
Hv = if Haman == CTC
f_coc(logr, period, sqrtAnnual)
else if Haman == PKS
f_park(period, sqrtAnnual)
else if Haman == RS
f_rsv(period, sqrtAnnual)
else if Haman == GK
f_gk(period, sqrtAnnual)
else if Haman == GKYZ
f_gkyz(period, sqrtAnnual)
else if Haman == EWMA
f_ewma(logr, period, sqrtAnnual)
else if Haman == YZ
f_yz(a, period, sqrtAnnual)
else if Haman == MAD
f_mad(logr, period, sqrtAnnual)
else // H == "Median Absolute Deviation"
f_mead(logr, period, sqrtAnnual)
pstyle = stl == L ? plot.style_linebr : stl == SL ? plot.style_stepline : stl == Ar
? plot.style_area : stl == CL ? plot.style_columns : plot.style_line
textWatermark = table.new(textVPosition + '_' + textHPosition, 1, 3) // 保持水印表格,但其内容
不再包含广告
//Hv Stats
avgHV = ta.sma(Hv, malen)
HVP = ta.percentrank(Hv, Plen)
NearZero = HVP < 1.5 ? 1 : 0
HV50 = ta.percentile_nearest_rank(Hv, Plen, 50)
//Custom MAS - 直接赋值,不再需要广告检查
maa = avgHV / 100 * 140
mab = avgHV / 100 * 180
mac = avgHV / 100 * 240
mad = avgHV / 100 * 60
mae = avgHV / 100 * 20
// Auto Sensivity Volatility Band Settings
float volatility = 0.0
if Hv < maa and Hv > avgHV // ilk band ust
volatility := 6
volatility
else if Hv < mab and Hv > maa // ikinci band ust
volatility := 7
volatility
else if Hv < mac and Hv > mab // ucuncu band ust
volatility := 7.8
volatility
else if Hv > mac // volatilite en ust degerde
volatility := 9
volatility
else if Hv < maa and Hv > mad // altdaki ilk band
volatility := 5
volatility
else if Hv < mad and Hv > mae // altdaki ikinci band
volatility := 4
volatility
else if Hv < mae // volatilite butun bandlarin anltinda
volatility := 3
volatility
// --- 中文翻译的用户输入 ---
// basic settings - 移除广告检查
signalPreset_zh = '无' // 定义翻译后的默认值
signalLogic_zh = '专业剥头皮'
signalStyle_zh = '普通'
signalAgility_zh = '自动'
candleColor_zh = '渐变确认'
signalPreset = input.string(signalPreset_zh, title = '信号预设⠀⠀⠀⠀⠀⠀⠀⠀⠀', options =
['无', '仅趋势'], group = '基础设置')
signalLogic = input.string(signalLogic_zh, title = '信号逻辑⠀⠀⠀⠀⠀⠀⠀⠀⠀', options = ['专
业剥头皮', '普通'], group = '基础设置')
signalStyle = input.string(signalStyle_zh, title = '信号风格⠀⠀⠀⠀⠀⠀⠀⠀⠀', options = ['普
通', '简约'], group = '基础设置')
signalAgility = input.string(signalAgility_zh, title = '灵敏度%⠀⠀⠀⠀⠀⠀⠀⠀⠀', options =
['自动', '手动'], group = '基础设置')
signalMode = signalStyle == '普通' ? 'Simple Entry + Exits' : 'Minimized Entry +
Exits' // Internal logic string, keep English
normalsensitivity = input.float(15, title = '普通灵敏度⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀', minval = 5.1,
maxval = 50.1, step = 0.1, group = '基础设置', tooltip = '调整信号灵敏度和准确性')
sensitivity = input.float(5, title = '专业剥头皮灵敏度⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀', minval = 0.6, maxval
= 15.1, step = 0.1, group = '基础设置', tooltip = '调整信号灵敏度和准确性')
strongSignalOnly = signalPreset == '仅趋势' ? true : false // Compare with translated
option
noRepainting = true
auto_button = signalAgility == '自动' ? true : false // Compare with translated
option
// basic chart features - 移除广告检查
normalsignalsmode = normalsensitivity / 4.4
normalsignalvolatility = volatility - 1.7
if signalLogic == '专业剥头皮' // Compare with translated option
sensitivity
else if signalLogic == '普通' // Compare with translated option
sensitivity := normalsignalsmode
sensitivity
//
if signalLogic == '专业剥头皮' // Compare with translated option
volatility
else if signalLogic == '普通' // Compare with translated option
volatility := normalsignalvolatility
volatility
//
if auto_button == false
sensitivity
else if auto_button == true
sensitivity := volatility
sensitivity
//
ReversalCloud = input(false, title = '反转云⠀⠀⠀', group = '基础图表功能', inline = 'feature
[R, 1]')
LongTrendAverage = input(false, title = '长趋势均线', group = '基础图表功能', inline =
'feature [R, 1]', tooltip = '放置一个反转通道,可预测反转。\n\n 趋势云线 (EMA) 将显示在图表上。')
ReversalBands = input(false, title = '反转带⠀⠀⠀', group = '基础图表功能', inline = 'feature
[R, 2]')
TrendTracer = true // Not an input
frequencyCloud = input(false, title = '频率云⠀⠀', tooltip = '显示短趋势云', group = '基础图表功
能', inline = 'feature [R, 2]')
CandleColor = input.string(candleColor_zh, title = 'K 线着色', options = ['渐变确认', '关
闭'], group = '基础图表功能')
Plot_MAs = input.bool(defval = true, title = '趋势云', group = '基础图表功能')
// leading features (No inputs here)
//=============================================================================
// EK Cloud (保持内部逻辑不变)
//=============================================================================
gr_MA = '📈移动平均线设置📈'
Timeframe = ''
Repaint = false
MA_T1 = 'Ehlers Kaufman' // Keep internal type names
MA_S1_Input = close
MA_L1 = 200
MA_T2 = 'Ehlers Kaufman' // Keep internal type names
MA_S2_Input = close
MA_L2 = 350
MA_S1 = request.security(syminfo.tickerid, Timeframe, MA_S1_Input[Repaint ? 0 :
barstate.isrealtime ? 1 : 0])[Repaint ? 0 : barstate.isrealtime ? 0 : 1]
MA_S2 = request.security(syminfo.tickerid, Timeframe, MA_S2_Input[Repaint ? 0 :
barstate.isrealtime ? 1 : 0])[Repaint ? 0 : barstate.isrealtime ? 0 : 1]
// ---- Moving Averages ---- (计算逻辑保持不变)
MA_1 = switch MA_T1
'Simple' => ta.sma(MA_S1, MA_L1)
'Exponential' => ta.ema(MA_S1, MA_L1)
'Double Exponential' => 2 * ta.ema(MA_S1, MA_L1) - ta.ema(ta.ema(MA_S1, MA_L1),
MA_L1)
'Triple Exponential' => 3 * (ta.ema(MA_S1, MA_L1) - ta.ema(ta.ema(MA_S1,
MA_L1), MA_L1)) + ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1)
'Quadruple Exponential' => 5 * ta.ema(MA_S1, MA_L1) - 10 * ta.ema(ta.ema(MA_S1,
MA_L1), MA_L1) + 10 * ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1) - 5 *
ta.ema(ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1), MA_L1) +
ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1), MA_L1), MA_L1)
'Weighted' => ta.wma(MA_S1, MA_L1)
'Volume-weighted' => ta.vwma(MA_S1, MA_L1)
'Hull' => ta.hma(MA_S1, MA_L1)
'Symmetrical' => ta.swma(MA_S1)
'Arnaud Legoux' => ta.alma(MA_S1, MA_L1, 0.85, 6)
'Least Squares' => ta.linreg(MA_S1, MA_L1, 0)
'Relative Strength' => ta.rma(MA_S1, MA_L1)
'Welles Wilder' =>
Wilder_MA1 = .0
Wilder_MA1 := int(1 / MA_L1) * MA_S1 + (1 - int(1 / MA_L1)) *
nz(Wilder_MA1[1])
Wilder_MA1
'Triangular' => ta.sma(ta.sma(MA_S1, MA_L1), MA_L1)
'Ehlers Kaufman' =>
KA_D1 = .0
for int i = 0 to 80 - 1 by 1
KA_D1 := KA_D1 + math.abs(nz(MA_S1[i]) - nz(MA_S1[i + 1]))
KA_D1
KA_EF1 = KA_D1 != 0 ? math.min(math.abs(MA_S1 - nz(MA_S1[80 - 1])) /
KA_D1, 1) : 0
KAMA1 = .0
KAMA1 := math.pow(0.6667 * KA_EF1 + 0.0645, 2) * MA_S1 + (1 -
math.pow(0.6667 * KA_EF1 + 0.0645, 2)) * nz(KAMA1[1])
KAMA1
MA_2 = switch MA_T2
'Simple' => ta.sma(MA_S2, MA_L2)
'Exponential' => ta.ema(MA_S2, MA_L2)
'Double Exponential' => 2 * ta.ema(MA_S2, MA_L2) - ta.ema(ta.ema(MA_S2, MA_L2),
MA_L2)
'Triple Exponential' => 3 * (ta.ema(MA_S2, MA_L2) - ta.ema(ta.ema(MA_S2,
MA_L2), MA_L2)) + ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2)
'Quadruple Exponential' => 5 * ta.ema(MA_S2, MA_L2) - 10 * ta.ema(ta.ema(MA_S2,
MA_L2), MA_L2) + 10 * ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2) - 5 *
ta.ema(ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2), MA_L2) +
ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2), MA_L2), MA_L2)
'Weighted' => ta.wma(MA_S2, MA_L2)
'Volume-weighted' => ta.vwma(MA_S2, MA_L2)
'Hull' => ta.hma(MA_S2, MA_L2)
'Symmetrical' => ta.swma(MA_S2)
'Arnaud Legoux' => ta.alma(MA_S2, MA_L2, 0.85, 6)
'Least Squares' => ta.linreg(MA_S2, MA_L2, 0)
'Relative Strength' => ta.rma(MA_S2, MA_L2)
'Welles Wilder' =>
Wilder_MA2 = .0
Wilder_MA2 := int(1 / MA_L2) * MA_S2 + (1 - int(1 / MA_L2)) *
nz(Wilder_MA2[1])
Wilder_MA2
'Triangular' => ta.sma(ta.sma(MA_S2, MA_L2), MA_L2)
'Ehlers Kaufman' =>
KA_D2 = .0
for int i = 0 to 135 - 1 by 1
KA_D2 := KA_D2 + math.abs(nz(MA_S2[i]) - nz(MA_S2[i + 1]))
KA_D2
KA_EF2 = KA_D2 != 0 ? math.min(math.abs(MA_S2 - nz(MA_S2[135 - 1])) /
KA_D2, 1) : 0
KAMA2 = .0
KAMA2 := math.pow(0.6667 * KA_EF2 + 0.0645, 2) * MA_S2 + (1 -
math.pow(0.6667 * KA_EF2 + 0.0645, 2)) * nz(KAMA2[1])
KAMA2
MA_Color = Plot_MAs ? MA_1 > MA_2 ? color.new(#04994b, 80) : color.new(#b4060d, 80)
: na
P1 = plot(Plot_MAs ? MA_1 : na, title = '快线 MA', color = MA_Color)
P2 = plot(Plot_MAs ? MA_2 : na, title = '慢线 MA', color = MA_Color)
// --- 买卖信号逻辑(保持不变) ---
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ----------------------------------------------- Buy & Sell
-----------------------------------------------------
src = close
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(close, 100, sensitivity)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
[mi, u, lo] = ta.kc(close, 90, 6.8)
[mid, upp, loww] = ta.kc(close, 90, 5.3)
[midd, ups, lowe] = ta.kc(close, 90, 4)
shorttop = ta.sma(close, 13)
longtop = ta.ema(close, 65)
eq_cloud_is_bullish = shorttop > longtop
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
hband = filt + smrng
lband = filt - smrng
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or src > filt and src <
src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or src < filt and src >
src[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
// --- 蜡烛评分和趋势置信度(保持不变) ---
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// Candle Rating
//=============================================================================
// INDICATOR 11 - Trend Confidence
//============================================================================
// CCI
TM_Long = ta.cci(close, 20) > 50
TM_Short = ta.cci(close, 20) < -50
// ADX
lenadx = 21
lensig = 21
limadx = 34
ADX_up = ta.change(high)
ADX_down = -ta.change(low)
trur = ta.rma(ta.tr, lenadx)
plus = fixnan(100 * ta.rma(ADX_up > ADX_down and ADX_up > 0 ? ADX_up : 0, lenadx) /
trur)
minus = fixnan(100 * ta.rma(ADX_down > ADX_up and ADX_down > 0 ? ADX_down : 0,
lenadx) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
macol = adx > limadx and plus > minus ? color.lime : adx > limadx and plus <
minus ? color.red : color.black
ADX_Long = adx > limadx and plus > minus
ADX_Short = adx > limadx and plus < minus
//Acumulation/Distribution
ACC_Dist = ta.sma(ta.accdist, 21)
ACC_Long = ta.accdist > ACC_Dist
ACC_Short = ta.accdist < ACC_Dist
// MFI
MFI = ta.mfi(close, 14)
MFI_SMA = ta.sma(MFI, 9)
MFI_Long = MFI > MFI_SMA
MFI_Short = MFI < MFI_SMA
// Momentum Linear Regression
mom = ta.mom(close, 21)
lrmom = ta.linreg(mom, 28, 0)
MOML_Long = lrmom > lrmom[1]
MOML_Short = lrmom < lrmom[1]
// 直接启用,不再需要广告检查
entry_long = true
entry_short = true
Long_Signal_Strength = 0
Short_Signal_Strength = 0
if entry_long
if TM_Long
Long_Signal_Strength := Long_Signal_Strength + 1
Long_Signal_Strength
if ADX_Long
Long_Signal_Strength := Long_Signal_Strength + 1
Long_Signal_Strength
if ACC_Long
Long_Signal_Strength := Long_Signal_Strength + 1
Long_Signal_Strength
if MFI_Long
Long_Signal_Strength := Long_Signal_Strength + 1
Long_Signal_Strength
if MOML_Long
Long_Signal_Strength := Long_Signal_Strength + 1
Long_Signal_Strength
if entry_short
if TM_Short
Short_Signal_Strength := Short_Signal_Strength + 1
Short_Signal_Strength
if ADX_Short
Short_Signal_Strength := Short_Signal_Strength + 1
Short_Signal_Strength
if ACC_Short
Short_Signal_Strength := Short_Signal_Strength + 1
Short_Signal_Strength
if MFI_Short
Short_Signal_Strength := Short_Signal_Strength + 1
Short_Signal_Strength
if MOML_Short
Short_Signal_Strength := Short_Signal_Strength + 1
Short_Signal_Strength
// --- 趋势检测(保持不变,移除广告检查) ---
// Trend Detecting
//------------------------------------------------------------------------------
//Settings - Directly assign values, no ad check needed
//-----------------------------------------------------------------------------{
length = 20
incr = 100
resetOn = 'CHoCH' // Internal logic string
showMS = false
//Style - Directly assign values, no ad check needed
bullCss = color.teal
bearCss = color.red
retCss = #ff5d00
areaTransp = 100
//------------------------------------------------------------------------------
//Global variables
//-----------------------------------------------------------------------------{
var float ph_y = na
var int ph_x = na
var float pl_y = na
var int pl_x = na
var float topaman = na
var float btmaman = na
var ph_cross = false
var pl_cross = false
var float maxaman = na
var float minaman = na
var float ts = na
var os = 0
ms = 0
//------------------------------------------------------------------------------
//Detect pivots and get coordinates
//-----------------------------------------------------------------------------{
// Directly assign values, no ad check needed
n = bar_index
ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)
if bool(ph)
ph_y := ph
ph_x := n - length
ph_cross := false
ph_cross
if bool(pl)
pl_y := pl
pl_x := n - length
pl_cross := false
pl_cross
//-----------------------------------------------------------------------------
}
//Bullish structures
//-----------------------------------------------------------------------------
{
if close > ph_y and not ph_cross
if resetOn == 'CHoCH' // Keep internal check string
ms := os == -1 ? 1 : 0
ms
else
ms := 1
ms
ph_cross := true
if showMS
line.new(ph_x, ph_y, n, ph_y, color = bullCss, style = os == -1 ?
line.style_dashed : line.style_dotted)
os := 1
btmaman := low
for i = 0 to n - ph_x - 1 by 1
btmaman := math.min(low[i], btmaman)
btmaman
//-------------------------------------------------------------------------
----}
//Bearish structures
//-------------------------------------------------------------------------
----{
if close < pl_y and not pl_cross
if resetOn == 'CHoCH' // Keep internal check string
ms := os == 1 ? -1 : 0
ms
else
ms := -1
ms
pl_cross := true
if showMS
line.new(pl_x, pl_y, n, pl_y, color = bearCss, style = os == 1 ?
line.style_dashed : line.style_dotted)
os := -1
topaman := high
for i = 0 to n - pl_x - 1 by 1
topaman := math.max(high[i], topaman)
topaman
//-------------------------------------------------------------------------
----}
//Trailing stop
//-------------------------------------------------------------------------
----{
if ms == 1
maxaman := close
maxaman
else if ms == -1
minaman := close
minaman
else
maxaman := math.max(close, maxaman)
minaman := math.min(close, minaman)
minaman
ts := ms == 1 ? btmaman : ms == -1 ? topaman : os == 1 ? ts + (maxaman -
maxaman[1]) * incr / 100 : ts + (minaman - minaman[1]) * incr / 100
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
cssaman = bool(ms) ? na : os == 1 ? bullCss : bearCss
// plot_price = plot(close, editable = false, display = display.none)
// plot_ts = plot(ts, '追踪止损', color = cssaman)
// css_area = (close - ts) * os < 0 ? retCss : cssaman
// fill(plot_price, plot_ts, color.new(css_area, areaTransp))
//-----------------------------------------------------------------------------}
//Plot Buy/Sell Signals on chart
// Directly define conditions, no ad check needed
buyCond = longCond and CondIni[1] == -1 and cssaman == bearCss
strongBuyCond1 = longCond and CondIni[1] == -1 and cssaman == bullCss
sellCond = shortCond and CondIni[1] == 1 and cssaman == bullCss
strongSellCond1 = shortCond and CondIni[1] == 1 and cssaman == bearCss
// Directly assign values, no ad check needed
enter_pluslong = str.tostring(Long_Signal_Strength)
enter_plussell = str.tostring(Short_Signal_Strength)
enter_longtrt = str.tostring(Long_Signal_Strength)
enter_selltrtt = str.tostring(Short_Signal_Strength)
// --- 中文信号标签文本 ---
// Directly assign values, no ad check needed
smartbuysigtex = '强力\n' + str.tostring(Long_Signal_Strength) + '★'
smartbuyminimal = '▲+\n' + str.tostring(Long_Signal_Strength) + '★'
smartselsigtex = str.tostring(Short_Signal_Strength) + '★\n' + '强力'
smartselminimal = str.tostring(Short_Signal_Strength) + '★\n' + '▼+'
buysigtex = '买入\n' + str.tostring(Long_Signal_Strength) + '★'
buyminimal = '▲\n' + str.tostring(Long_Signal_Strength) + '★'
selsigtex = str.tostring(Short_Signal_Strength) + '★\n' + '卖出'
selsminimal = str.tostring(Short_Signal_Strength) + '★\n' + '▼'
// Repainting check
if noRepainting
buyCond := buyCond and barstate.isconfirmed
strongBuyCond1 := strongBuyCond1 and barstate.isconfirmed
sellCond := sellCond and barstate.isconfirmed
strongSellCond1 := strongSellCond1 and barstate.isconfirmed
strongSellCond1
// Buy Signals - Directly create labels based on conditions, no ad check needed
BuySignal = signalMode == 'Simple Entry + Exits' and buyCond and not
strongSignalOnly ? label.new(bar_index, low, buysigtex, xloc.bar_index,
yloc.belowbar, #00cf4b8c, label.style_label_up, color.white, size.normal) : na
MinimalBuy = signalMode == 'Minimized Entry + Exits' and buyCond and not
strongSignalOnly ? label.new(bar_index, low, buyminimal, xloc.bar_index,
yloc.belowbar, #00cf4b8c, label.style_label_up, color.white, size.normal) : na
StrongBuy = signalMode == 'Simple Entry + Exits' and strongBuyCond1 ?
label.new(bar_index, low, smartbuysigtex, xloc.bar_index, yloc.belowbar, #00cf4b8c,
label.style_label_up, color.white, size.normal) : na
MinimalStrongBuy = signalMode == 'Minimized Entry + Exits' and strongBuyCond1 ?
label.new(bar_index, low, smartbuyminimal, xloc.bar_index, yloc.belowbar,
#00cf4b8c, label.style_label_up, color.white, size.normal) : na
//Sell Signals - Directly create labels based on conditions, no ad check needed
SellSignal = signalMode == 'Simple Entry + Exits' and sellCond and not
strongSignalOnly ? label.new(bar_index, high, selsigtex, xloc.bar_index,
yloc.abovebar, #ff00008c, label.style_label_down, color.white, size.normal) : na
MinimalSell = signalMode == 'Minimized Entry + Exits' and sellCond and not
strongSignalOnly ? label.new(bar_index, high, selsminimal, xloc.bar_index,
yloc.abovebar, #ff00008c, label.style_label_down, color.white, size.normal) : na
StrongSell = signalMode == 'Simple Entry + Exits' and strongSellCond1 ?
label.new(bar_index, high, smartselsigtex, xloc.bar_index, yloc.abovebar,
#ff00008c, label.style_label_down, color.white, size.normal) : na
MinimalStrongSell = signalMode == 'Minimized Entry + Exits' and strongSellCond1 ?
label.new(bar_index, high, smartselminimal, xloc.bar_index, yloc.abovebar,
#ff00008c, label.style_label_down, color.white, size.normal) : na
// --- K 线着色(逻辑不变,移除广告检查) ---
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Candle Color
----------------------------------------------------
barcolor = src > filt and src > src[1] and upward > 0 ? color.new(#00db0a, 5) : src
> filt and src < src[1] and upward > 0 ? color.new(#00db05, 5) : src < filt and src
< src[1] and downward > 0 ? color.new(#c90505, 5) : src < filt and src > src[1] and
downward > 0 ? color.new(#ff0000, 5) : color.new(#3ebe48, 5) // 442886
barcolor(CandleColor == '渐变确认' ? barcolor : na, title = 'K 线颜色') // Compare with
translated option, removed ad check
// --- 反转云和带(逻辑不变,移除广告检查) ---
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Reversal Cloud
--------------------------------------------------
// Directly plot based on input, no ad check needed
u1 = plot(ReversalCloud ? ta.sma(u, 1) : na, editable = false)
u2 = plot(ReversalCloud ? ta.sma(upp, 5) : na, editable = false)
u3 = plot(ReversalCloud ? ta.sma(ups, 10) : na, editable = false)
l1 = plot(ReversalCloud ? ta.sma(lo, 1) : na, editable = false)
l2 = plot(ReversalCloud ? ta.sma(loww, 5) : na, editable = false)
l3 = plot(ReversalCloud ? ta.sma(lowe, 10) : na, editable = false)
plot(ReversalBands ? ta.sma(u, 1) : na, editable = false, offset = 2, color =
color.new(#f23645, 60))
plot(ReversalBands ? ta.sma(upp, 5) : na, editable = false, offset = 3, color =
color.new(#f23645, 70))
plot(ReversalBands ? ta.sma(ups, 10) : na, editable = false, offset = 3, color =
color.new(#f23645, 65))
plot(ReversalBands ? ta.sma(lowe, 10) : na, editable = false, offset = 3, color =
color.new(#089981, 65))
plot(ReversalBands ? ta.sma(loww, 5) : na, editable = false, offset = 3, color =
color.new(#089981, 70))
plot(ReversalBands ? ta.sma(lo, 1) : na, editable = false, offset = 2, color =
color.new(#089981, 60))
fill(u1, u2, color = color.new(#f23645, 65), title = '反转区 [R3, R2]')
fill(u2, u3, color = color.new(#f23645, 75), title = '反转区 [R2, R1]')
fill(l2, l3, color = color.new(#089981, 75), title = '反转区 [S2, S1]')
fill(l1, l2, color = color.new(#089981, 65), title = '反转区 [S3, S2]')
// --- 趋势追踪器(逻辑不变,移除广告检查) ---
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------- Trend Catcher
--------------------------------------------------
filtcolor = upward > 0 ? color.rgb(0, 255, 85) : downward > 0 ? color.new(#ff0000,
0) : color.new(#56328f, 0)
// Directly plot based on TrendTracer (which is true), no ad check needed
plot(TrendTracer ? filt : na, color = filtcolor, linewidth = 3, title = '趋势追踪器')
// --- 频率云(逻辑不变,移除广告检查) ---
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Frquency Cloud
--------------------------------------------------
// Directly plot based on input, no ad check needed
plot_eq_closing_price = plot(frequencyCloud ? shorttop : na, editable = false)
plot_eq_external_value = plot(frequencyCloud ? longtop : na, editable = false)
// table.cell(textWatermark, 0, 1, subtitle, width, height, c_subtitle, a_subtitle,
text_size=s_subtitle, bgcolor=c_bg) // Re-added subtitle display if needed
eqCloudColor = ta.sma(close, 26) < ta.sma(close, 48) ? color.new(#9f0700, 80) :
shorttop < longtop ? color.new(#ff1100, 80) : ta.sma(close, 26) > ta.sma(close, 48)
? color.new(#10253b, 80) : shorttop > longtop ? color.new(#0d67c2, 80) :
ta.sma(close, 34) > ta.sma(close, 56) ? color.new(#549de6, 80) : na
fill(plot_eq_closing_price, plot_eq_external_value, color = eqCloudColor, title =
'频率云填充')
// --- 订单块(中文翻译输入选项,移除广告检查) ---
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ---------------------------------------------- Order Blocks
------------------------------------------------
const color colup = #089981
const color coldn = #f23645
// --- 中文提示信息 ---
const string tm_zh = '[长度] 使用长度调整订单块的坐标\n[完整] 使用整个蜡烛实体'
const string tn_zh = '触发订单块时的缓解方法'
const string tj_zh = '订单块指标文本大小'
const string ta_zh = '显示内部买卖活动'
const string tsorder_zh = '显示最后几个订单块'
const string gv_zh = '成交量订单块' // Group name translation
// Directly define inputs, no ad check needed
obshow = input.bool(true, title = '显示最后', tooltip = tsorder_zh, inline = '1', group
= gv_zh)
oblast = input.int(3, title = '', minval = 0, maxval = 50, step = 1, inline = '1',
group = gv_zh)
obupcs = input.color(color.new(colup, 90), title = '', inline = '1', group = gv_zh)
obdncs = input.color(color.new(coldn, 90), title = '', inline = '1', group = gv_zh)
obshowactivity = input.bool(true, title = '显示买/卖活动 ', tooltip = ta_zh,
inline = '2', group = gv_zh)
obactup = input.color(color.new(colup, 50), title = '', inline = '2', group =
gv_zh)
obactdn = input.color(color.new(coldn, 50), title = '', inline = '2', group =
gv_zh)
obmode_zh = '长度' // Translated default
obmode = input.string(obmode_zh, title = '构建方式 ', options = ['长度', '完整'], tooltip =
tm_zh, inline = '3', group = gv_zh)
len = input.int(5, title = '', minval = 1, maxval = 20, step = 1, inline = '3',
group = gv_zh) // Note: 'len' is also used in Trend Detection section, ensure scope
or rename if conflict
obmiti_zh = '收盘价' // Translated default
obmiti = input.string(obmiti_zh, title = '缓解方法', options = ['收盘价', '影线', '平均价'],
tooltip = tn_zh, group = gv_zh)
obtxt_zh = '普通' // Translated default
obtxt = input.string(obtxt_zh, title = '指标大小', options = ['微小', '小', '普通', '大', '巨
大'], tooltip = tj_zh, group = gv_zh)
showmetric = input.bool(true, title = '显示指标', group = gv_zh)
showline = input.bool(true, title = '显示中线', group = gv_zh)
overlap = input.bool(true, title = '隐藏重叠', tooltip = '最新的订单块将被保留', group = gv_zh)
alert_group_zh = '任何警报' // Group name translation
// Directly define inputs, no ad check needed
blcreated = input.bool(false, title = '看涨 OB 形成 ', inline = '形成', group =
alert_group_zh)
brcreated = input.bool(false, title = '看跌 OB 形成', inline = '形成', group =
alert_group_zh)
blmitigated = input.bool(false, title = '看涨 OB 缓解 ', inline = '缓解', group =
alert_group_zh)
brmitigated = input.bool(false, title = '看跌 OB 缓解', inline = '缓解', group =
alert_group_zh)
blinside = input.bool(false, title = '价格进入看涨 OB', inline = '进入', group =
alert_group_zh)
brinside = input.bool(false, title = '价格进入看跌 OB', inline = '进入', group =
alert_group_zh)
// --- 订单块内部逻辑和类型定义(保持不变) ---
type bar
float o = open
float h = high
float l = low
float c = close
float v = volume
int i = bar_index
int t = time
type ob
float top
float btm
float avg
int loc
color css
float vol
int dir
int move
int blPOS
int brPOS
int xlocbl
int xlocbr
type alert
bool created = false
bool inside = false
bool mitigated = false
type cross
bool reset = false
bar b = bar.new()
alert blal = alert.new()
alert bral = alert.new()
var cross blIS = cross.new()
var cross brIS = cross.new()
// 方法和函数(保持不变,除了文本大小转换)
method txSz(string s) =>
out = switch s
'微小' => size.tiny
'小' => size.small
'普通' => size.normal
'大' => size.large
'巨大' => size.huge
out
method display(ob id, array<ob> full, int i) =>
box.new(top = id.top, bottom = id.btm, left = id.loc, right = b.t, border_color
= na, bgcolor = id.css, xloc = xloc.bar_time)
box.new(top = id.top, bottom = id.btm, left = b.t, right = b.t + 1,
border_color = na, bgcolor = id.css, xloc = xloc.bar_time, extend = extend.right)
if obshowactivity
box.new(top = id.top, bottom = id.avg, left = id.loc, right = id.xlocbl,
border_color = na, bgcolor = obactup, xloc = xloc.bar_time)
box.new(top = id.avg, bottom = id.btm, left = id.loc, right = id.xlocbr,
border_color = na, bgcolor = obactdn, xloc = xloc.bar_time)
if showline
line.new(x1 = id.loc, x2 = b.t, y1 = id.avg, y2 = id.avg, color =
color.new(id.css, 0), xloc = xloc.bar_time, style = line.style_dashed)
if showmetric
if i == math.min(oblast - 1, full.size() - 1)
float tV = 0
array<float> dV = array.new<float>()
seq = math.min(oblast - 1, full.size() - 1)
for j = 0 to seq by 1
cV = full.get(j)
tV := tV + cV.vol
if j == seq
for y = 0 to seq by 1
dV.push(math.floor(full.get(y).vol / tV * 100))
id = full.get(y)
label.new(b.i + 1, id.avg, textcolor = color.new(id.css,
0), style = label.style_label_left, size = obtxt.txSz(), color = #ffffff00, text =
str.tostring(math.round(full.get(y).vol, 3), format = format.volume) + ' (' +
str.tostring(dV.get(y)) + '%)') // 使用转换后的大小 , color = #ffffff00 , text =
str.tostring(math.round(full.get(y).vol, 3), format = format.volume) + " (" +
str.tostring(dV.get(y)) + "%)" )
method overlap(array<ob> id) =>
if id.size() > 1
for i = id.size() - 1 to 1 by 1
stuff = id.get(i)
current = id.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top => id.remove(i)
stuff.top < current.top and stuff.btm > current.btm => id.remove(i)
stuff.top > current.top and stuff.btm < current.btm => id.remove(i)
stuff.top < current.top and stuff.top > current.btm => id.remove(i)
method umt(ob metric) =>
switch metric.dir
1 =>
switch metric.move
1 =>
metric.blPOS := metric.blPOS + 1
metric.move := 2
metric.move
2 =>
metric.blPOS := metric.blPOS + 1
metric.move := 3
metric.move
3 =>
metric.brPOS := metric.brPOS + 1
metric.move := 1
metric.move
-1 =>
switch metric.move
1 =>
metric.brPOS := metric.brPOS + 1
metric.move := 2
metric.move
2 =>
metric.brPOS := metric.brPOS + 1
metric.move := 3
metric.move
3 =>
metric.blPOS := metric.blPOS + 1
metric.move := 1
metric.move
field_0 = b.t // Added check for positive time difference to avoid division by
zero or issues on data gaps
field_1 = b.t
field_2 = b.t
field_3 = b.t
if b.t - field_0[1] == field_1[1] - field_2[2] and b.t - field_3[1] > 0
field_4 = b.t
metric.xlocbl := metric.loc + (b.t - field_4[1]) * metric.blPOS
field_5 = b.t
metric.xlocbr := metric.loc + (b.t - field_5[1]) * metric.brPOS
metric.xlocbr
fnOB() =>
var array<ob> blob = array.new<ob>()
var array<ob> brob = array.new<ob>()
var int dir = 0
// Use 'len_ob' for OB length to avoid conflict with 'len' from Trend Detection
section
len_ob = len // Assign the input value 'len' to a specific variable for OBs
up = ta.highest(len_ob)
dn = ta.lowest(len_ob)
pv = ta.pivothigh(b.v, len_ob, len_ob)
field_6 = b.h
field_7 = b.l
dir := field_6[len_ob] > up ? -1 : field_7[len_ob] < dn ? 1 : dir[1]
atr = ta.atr(len_ob)
field_8 = b.h // Compare with translated option
field_9 = b.l
field_10 = b.l
field_11 = b.h
field_12 = b.l
btmP = obmode == '长度' ? field_8[len_ob] - 1 * atr[len_ob] < field_9[len_ob] ?
field_10[len_ob] : field_11[len_ob] - 1 * atr[len_ob] : field_12[len_ob]
field_13 = b.l // Compare with translated option
field_14 = b.h
field_15 = b.h
field_16 = b.l
field_17 = b.h
topP = obmode == '长度' ? field_13[len_ob] + 1 * atr[len_ob] > field_14[len_ob] ?
field_15[len_ob] : field_16[len_ob] + 1 * atr[len_ob] : field_17[len_ob]
if bool(pv) and dir == 1
field_18 = b.l
field_19 = b.l
field_20 = b.t
field_21 = b.v
field_22 = b.c
field_23 = b.o
field_24 = b.t
blob.unshift(ob.new(topP, field_18[len_ob], math.avg(topP,
field_19[len_ob]), field_20[len_ob], obupcs, field_21[len_ob], field_22[len_ob] >
field_23[len_ob] ? 1 : -1, 1, 0, 0, field_24[len_ob]))
blal.created := true
blIS.reset := false
blIS.reset
if bool(pv) and dir == -1
field_25 = b.h
field_26 = b.h
field_27 = b.t
field_28 = b.v
field_29 = b.c
field_30 = b.o
field_31 = b.t
brob.unshift(ob.new(field_25[len_ob], btmP, math.avg(btmP,
field_26[len_ob]), field_27[len_ob], obdncs, field_28[len_ob], field_29[len_ob] >
field_30[len_ob] ? 1 : -1, 1, 0, 0, field_31[len_ob]))
bral.created := true
brIS.reset := false
brIS.reset
if blob.size() > 0 and barstate.isconfirmed
for [i, ob_item] in blob // Renamed loop variable to avoid conflict with
type 'ob'
for j = 0 to len_ob - 1 by 1
// Compare with translated options
field_32 = b.c
field_33 = b.o
if obmiti == '收盘价' ? math.min(field_32[j], field_33[j]) <
ob_item.btm : obmiti == '影线' ? b.l < ob_item.btm : obmiti == '平均价' ? b.l <
ob_item.avg : false
blob.remove(i)
blal.mitigated := true
break
if brob.size() > 0 and barstate.isconfirmed
for [i, ob_item] in brob // Renamed loop variable
for j = 0 to len_ob - 1 by 1
// Compare with translated options
field_34 = b.c
field_35 = b.o
if obmiti == '收盘价' ? math.max(field_34[j], field_35[j]) >
ob_item.top : obmiti == '影线' ? b.h > ob_item.top : obmiti == '平均价' ? b.h >
ob_item.avg : false
brob.remove(i)
bral.mitigated := true
break
if blob.size() > 0
for [i, metric] in blob
metric.umt()
if brob.size() > 0
for [i, metric] in brob
metric.umt()
if overlap
blob.overlap()
brob.overlap()
if barstate.isconfirmed
if blob.size() > 0
ob_first = blob.get(0) // Renamed variable
if low < ob_first.top and blIS.reset == false
blal.inside := true
blIS.reset := true
blIS.reset
if brob.size() > 0
ob_first = brob.get(0) // Renamed variable
if high > ob_first.btm and brIS.reset == false
bral.inside := true
brIS.reset := true
brIS.reset
if barstate.islast
for bx in box.all
bx.delete()
for ln in line.all
ln.delete()
// for lb in label.all // Razzere Fixed! - Keep original comment
// lb.delete() // Razzere Fixed! - Keep original comment
if blob.size() > 0
for i = 0 to math.min(oblast - 1, blob.size() - 1) by 1
blob.get(i).display(blob, i)
if brob.size() > 0
for i = 0 to math.min(oblast - 1, brob.size() - 1) by 1
brob.get(i).display(brob, i)
// 执行订单块功能(如果启用)
if obshow
fnOB()
// --- 警报(中文翻译输入选项,警报文本保持英文或根据需要翻译) ---
alert_group2_zh = '警报' // Group name translation
// Directly define inputs, no ad check needed
buyalert = input.bool(false, title = '买入警报', group = alert_group2_zh)
sellalert = input.bool(false, title = '卖出警报', group = alert_group2_zh)
// OB 警报触发
if blinside and blal.inside
alert('Price Inside Bullish OB', alert.freq_once_per_bar_close) // Keep alert
messages English or translate as needed
if blcreated and blal.created
alert('Bullish OB Formed', alert.freq_once_per_bar_close)
if blmitigated and blal.mitigated
alert('Bullish OB Mitigated', alert.freq_once_per_bar_close)
if brinside and bral.inside
alert('Price Inside Bearish OB', alert.freq_once_per_bar_close)
if brcreated and bral.created
alert('Bearish OB Formed', alert.freq_once_per_bar_close)
if brmitigated and bral.mitigated
alert('Bearish OB Mitigated', alert.freq_once_per_bar_close)
// 买卖信号警报
if buyalert and (buyCond or strongBuyCond1)
alert('Buy', alert.freq_once_per_bar_close) // Keep standard alert messages
if sellalert and (sellCond or strongSellCond1)
alert('Sell', alert.freq_once_per_bar_close) // Keep standard alert messages