OPEN-SOURCE SCRIPT
premium

//version=5
indicator("Custom Binance Premium Index + Alerts", overlay=false)
// === 1. 数据源(可修改) ===
// 永续合约价格(默认 BTCUSDT 永续)
futures = request.security("BINANCE:BTCUSDT_PERP", timeframe.period, close)
// 现货价格(默认 BTCUSDT 现货)
spot = request.security("BINANCE:BTCUSDT", timeframe.period, close)
// === 2. 计算自定义溢价指数 ===
premium = ((futures / spot) - 1) * 100
// === 3. 用户设定阈值(你给的值) ===
upper = 1.5 // 溢价 ≥ 1.5 触发告警
lower = -2.0 // 溢价 ≤ -2.0 触发告警
// === 4. 绘图 ===
plot(premium, title="Premium Index (%)", color=color.new(color.blue, 0))
hline(upper, "Upper Threshold (1.5%)", color=color.new(color.red, 0))
hline(lower, "Lower Threshold (-2.0%)", color=color.new(color.green, 0))
// === 5. 告警条件 ===
alertcondition(premium >= upper,
title="溢价 ≥ 1.5%",
message="Premium Index ≥ 1.5%(永续合约偏高,多头较强)"
)
alertcondition(premium <= lower,
title="溢价 ≤ -2.0%",
message="Premium Index ≤ -2.0%(永续合约偏低,空头压力大)"
)
// === 6. 信息显示 ===
label.new(bar_index, premium, "Premium: " + str.tostring(premium, "#.##") + "%",
style=label.style_label_left, color=color.new(color.blue, 85))
indicator("Custom Binance Premium Index + Alerts", overlay=false)
// === 1. 数据源(可修改) ===
// 永续合约价格(默认 BTCUSDT 永续)
futures = request.security("BINANCE:BTCUSDT_PERP", timeframe.period, close)
// 现货价格(默认 BTCUSDT 现货)
spot = request.security("BINANCE:BTCUSDT", timeframe.period, close)
// === 2. 计算自定义溢价指数 ===
premium = ((futures / spot) - 1) * 100
// === 3. 用户设定阈值(你给的值) ===
upper = 1.5 // 溢价 ≥ 1.5 触发告警
lower = -2.0 // 溢价 ≤ -2.0 触发告警
// === 4. 绘图 ===
plot(premium, title="Premium Index (%)", color=color.new(color.blue, 0))
hline(upper, "Upper Threshold (1.5%)", color=color.new(color.red, 0))
hline(lower, "Lower Threshold (-2.0%)", color=color.new(color.green, 0))
// === 5. 告警条件 ===
alertcondition(premium >= upper,
title="溢价 ≥ 1.5%",
message="Premium Index ≥ 1.5%(永续合约偏高,多头较强)"
)
alertcondition(premium <= lower,
title="溢价 ≤ -2.0%",
message="Premium Index ≤ -2.0%(永续合约偏低,空头压力大)"
)
// === 6. 信息显示 ===
label.new(bar_index, premium, "Premium: " + str.tostring(premium, "#.##") + "%",
style=label.style_label_left, color=color.new(color.blue, 85))
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.