Indicator · Pine Script v5 · On the chart

BMNR Power Law

by 0xDkd

BMNR Power Law is a crypto-focused valuation channel indicator that plots dynamic power law bands on the main chart.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code124
Settings13inputs
LicenceMIT
Last update9 months ago17 Jan 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

124 lines of Pine Script v5 from main.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

main.pine
//@version=5
indicator("BMNR Power Law", overlay=true, shorttitle="BMNR Adv Signal")

// ==========================================
// --- 1. 数据源与基础模型参数 ---
// ==========================================
grp_data = "数据源设置"
eth_ticker = input.symbol("COINBASE:ETHUSD", "ETH 交易对代码", group=grp_data)

grp_model = "基础幂律参数 (Power Law)"
mid_scale = input.float(0.00057, "中轨 Scale (A)", group=grp_model)
mid_exp   = input.float(1.3625, "中轨 Exponent (B)", group=grp_model)

top_scale = input.float(0.00097, "上轨 Scale (A)", group=grp_model)
top_exp   = input.float(1.3144, "上轨 Exponent (B)", group=grp_model)

bot_scale = input.float(0.00148, "下轨 Scale (A)", group=grp_model)
bot_exp   = input.float(1.2291, "下轨 Exponent (B)", group=grp_model)

// ==========================================
// --- 2. 进阶波动率修正 (ATR) ---
// ==========================================
grp_adv = "波动率动态修正 (过滤假突破)"
use_atr_adj = input.bool(true, "开启 ATR 弹性轨道?", group=grp_adv)
atr_period  = input.int(14, "ATR 周期", minval=1, group=grp_adv)
atr_mult    = input.float(1.0, "ATR 修正系数", step=0.1, group=grp_adv)

// ==========================================
// --- 3. 显示设置 ---
// ==========================================
grp_disp = "显示设置"
use_filter = input.bool(true, "仅在特定时间内显示信号?", group=grp_disp)
start_time = input.time(timestamp("2024-01-01 00:00:00"), "显示开始时间", group=grp_disp)
end_time   = input.time(timestamp("2026-12-31 23:59:59"), "显示结束时间", group=grp_disp)

show_signal = not use_filter or (time >= start_time and time <= end_time)

// ==========================================
// --- 4. 核心计算逻辑 ---
// ==========================================
// 获取 ETH 日线关闭价格
eth_price_d = request.security(eth_ticker, "D", close, gaps=barmerge.gaps_off)

// 计算基础幂律轨道
base_top = top_scale * math.pow(eth_price_d, top_exp)
base_mid = mid_scale * math.pow(eth_price_d, mid_exp)
base_bot = bot_scale * math.pow(eth_price_d, bot_exp)

// 计算 ATR 修正值
atr_val = ta.atr(atr_period)
adj_val = use_atr_adj ? atr_val * atr_mult : 0

// 最终动态轨道
val_top = base_top + adj_val
val_mid = base_mid
val_bot = base_bot - adj_val

// ==========================================
// --- 5. 绘图与视觉反馈 ---
// ==========================================
plot_top = plot(val_top, "动态压力位 (红)", color=color.new(color.red, 0), linewidth=2)
plot_mid = plot(val_mid, "价值中枢 (蓝)", color=color.new(color.blue, 50), linewidth=1, style=plot.style_linebr)
plot_bot = plot(val_bot, "动态支撑位 (绿)", color=color.new(color.green, 0), linewidth=2)

// 填充区间
fill(plot_top, plot_bot, color=color.new(color.gray, 95), title="估值合理区")

// 信号判定
is_buy  = ta.crossunder(close, val_bot) and show_signal
is_sell = ta.crossover(close, val_top) and show_signal

// 绘制图标
plotshape(is_buy,  title="抄底", style=shape.arrowup,   location=location.belowbar, color=color.green, size=size.normal, text="BUY")
plotshape(is_sell, title="逃顶", style=shape.arrowdown, location=location.abovebar, color=color.red,   size=size.normal, text="SELL")

// 极端行情背景高亮
bgcolor(show_signal and close <= val_bot ? color.new(color.green, 90) : na)
bgcolor(show_signal and close >= val_top ? color.new(color.red, 90) : na)

// ==========================================
// --- 6. 实时状态面板 (Dashboard) ---
// ==========================================
var table panel = table.new(position.top_right, 2, 4, border_width=1, border_color=color.gray)
if barstate.islast
    premium = (close - val_mid) / val_mid * 100
    status_color = close >= val_top ? color.red : (close <= val_bot ? color.green : color.gray)
    
    table.cell(panel, 0, 0, "基准 ETH", bgcolor=color.gray, text_color=color.white)
    table.cell(panel, 1, 0, str.tostring(eth_price_d, "#.##"), bgcolor=color.black, text_color=color.white)
    
    table.cell(panel, 0, 1, "偏离度", bgcolor=color.gray, text_color=color.white)
    table.cell(panel, 1, 1, str.tostring(premium, "#.1") + "%", bgcolor=status_color, text_color=color.white)

    table.cell(panel, 0, 2, "轨道宽度 (ATR)", bgcolor=color.gray, text_color=color.white)
    table.cell(panel, 1, 2, str.tostring(adj_val, "#.##"), bgcolor=color.black, text_color=color.white)

    table.cell(panel, 0, 3, "当前价格", bgcolor=color.gray, text_color=color.white)
    table.cell(panel, 1, 3, str.tostring(close, "#.##"), bgcolor=color.black, text_color=color.white)

// ==========================================
// --- 7. 预设警报逻辑 (用于 Telegram 推送) ---
// ==========================================

// 构造推送文本
string buy_msg = "🟢 **BMNR 抄底预警**\n" + 
                 "------------------\n" +
                 "当前价格: " + str.tostring(close, "#.####") + "\n" +
                 "支撑位(下轨): " + str.tostring(val_bot, "#.####") + "\n" +
                 "ETH参考价: " + str.tostring(eth_price_d, "#.##") + "\n" +
                 "偏离度: " + str.tostring((close - val_mid) / val_mid * 100, "#.1") + "%"

string sell_msg = "🔴 **BMNR 逃顶预警**\n" + 
                  "------------------\n" +
                  "当前价格: " + str.tostring(close, "#.####") + "\n" +
                  "压力位(上轨): " + str.tostring(val_top, "#.####") + "\n" +
                  "ETH参考价: " + str.tostring(eth_price_d, "#.##") + "\n" +
                  "偏离度: " + str.tostring((close - val_mid) / val_mid * 100, "#.1") + "%"

// 触发逻辑
if is_buy
    alert(buy_msg, alert.freq_once_per_bar_close) // 每次收盘确认破位才发,减少误报

if is_sell
    alert(sell_msg, alert.freq_once_per_bar_close)

Overview

BMNR Power Law calculates top, middle, and bottom valuation lines using exponential model parameters applied to daily prices. An optional Average True Range adjustment dynamically expands or contracts the outer bands during volatile market conditions to help filter out false breakouts. The script plots visual buy and sell arrow shapes and highlights chart backgrounds during extreme valuation zones.

Details

Published by

0xDkd on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Support & resistance, Volatility & bands, Trend

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
ETH 交易对代码symbolCOINBASE:ETHUSDeth_ticker
中轨 Scale (A)float0.00057mid_scale
中轨 Exponent (B)float1.3625mid_exp
上轨 Scale (A)float0.00097top_scale
上轨 Exponent (B)float1.3144top_exp
下轨 Scale (A)float0.00148bot_scale
下轨 Exponent (B)float1.2291bot_exp
开启 ATR 弹性轨道?booltrueuse_atr_adj
ATR 周期int14atr_period
ATR 修正系数float1.0atr_mult
仅在特定时间内显示信号?booltrueuse_filter
显示开始时间timetimestamp("2024-01-01 00:00:00")start_time
Show all 13 settings
SettingTypeDefaultVariable
显示结束时间timetimestamp("2026-12-31 23:59:59")end_time
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

Dynamic Linear Regression

by TradersPost
218 stars

Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin

Indicator v6 TrendSupport & resistance
Updated 3 months ago · None stated GitHub repository of Dynamic Linear Regression

ATR Trailing Stop

by mihakralj
99 stars

Calculates an ATR-based trailing stop overlaid on the price chart to assist with trend identification and stop placement. Using a specified ATR period and multiplier, it projects upper and lower bounds around the closing price. The stop line ratchets up during

Indicator v5 TrendVolatility & bands
Updated 4 weeks ago · Apache-2.0 GitHub repository of ATR Trailing Stop

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev Lunar Sniper

SuperTrend & Pivots

by dcaoyuan
55 stars

This overlay indicator plots a SuperTrend line on the price chart using a fixed ATR length of 10 and a factor of 3. When the trend direction is up it draws a green line and a light green fill toward the candle midpoint; when down it draws a red line and a ligh

Indicator v6 TrendVolatility & bands
Updated 6 months ago · Apache-2.0 GitHub repository of SuperTrend & Pivots

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers