本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0
// © EduVest_doro - EDUVEST UTBOT 調整値方式(シンプル改良版)
//@version=5
indicator(title='EDUVEST UTBOT 調整値方式', shorttitle='EDUVEST UTBOT ADJ', overlay=true)
// ===== 🎯 視聴者向けアラート設定 =====
group_alert_improved = "🎯 視聴者向けアラート設定"
use_improved_alerts = input.bool(true, "📱 視聴者向けアラート表示", group=group_alert_improved)
use_cooldown = input.bool(true, "⏰ クールダウン機能", group=group_alert_improved)
cooldown_minutes = input.int(15, "クールダウン時間(分)", minval=5, maxval=60, group=group_alert_improved)
// ===== 🔧 ATR動的調整設定 =====
group_atr = "🔧 ATR動的調整設定"
enable_dynamic_atr = input.bool(true, "ATR動的調整を有効", group=group_atr)
atr_period_global = input.int(14, "ATR計算期間", minval=5, maxval=50, group=group_atr)
atr_smoothing = input.int(20, "ATRスムージング期間", minval=5, maxval=50, group=group_atr)
volatility_sensitivity = input.float(0.5, "ボラティリティ感度", minval=0.1, maxval=1.0, step=0.1, group=group_atr)
// ===== 🕐 時間帯別ATR調整設定 =====
group_time = "🕐 時間帯別ATR調整設定"
enable_time_adjustment = input.bool(true, "時間帯別ATR調整を有効", group=group_time)
show_session_info = input.bool(true, "セッション情報表示", group=group_time)
// ===== 📊 銘柄設定(自動+手動対応) =====
group_asset = "📊 銘柄設定(自動+手動対応)"
use_auto_settings = input.bool(true, "🔄 銘柄自動判定設定", group=group_asset, tooltip="ONで自動設定、OFFで手動設定")
MA_Period = input.int(10, title='MA Period', group=group_asset)
atr_period = input.int(14, title='ATR期間', group=group_asset)
// 手動設定用
manual_base_sensitivity = input.float(1.8, title='[手動]基本レンジ感度', step=0.1, group=group_asset)
manual_tokyo_adj = input.float(-0.3, title='[手動]東京調整値', step=0.1, group=group_asset)
manual_london_adj = input.float(0.0, title='[手動]ロンドン調整値', step=0.1, group=group_asset)
manual_ny_adj = input.float(0.2, title='[手動]NY調整値', step=0.1, group=group_asset)
// ===== 🎚️ 配信用臨時調整 =====
group_live = "🎚️ 配信用臨時調整"
enable_live_mode = input.bool(false, "配信モード調整", group=group_live)
live_adjustment = input.float(0.0, title='全体調整値(配信用)', step=0.1, group=group_live, tooltip="スキャル解説時: -0.5, スイング解説時: +0.5, 重要指標時: +1.0")
// ===== 基本設定 =====
h = input.bool(false, title='Signals from Heikin Ashi Candles', group="基本設定")
Price = input.source(defval=close, title='Price Source', group="基本設定")
smoothing = input.string(title="Moving Average Type", defval="EMA", options=["SMA", "EMA", "WMA", "HMA"], group="基本設定")
// ===== 時間フィルター =====
use_time_filter = input.bool(false, "Use Time Filter (JST)", group="時間フィルター")
mute_now = input.bool(false, "Mute Now", group="時間フィルター")
alert_time_ok = use_time_filter ? not mute_now : not mute_now
cooldown_bars = math.round(cooldown_minutes * 60 / (timeframe.in_seconds(timeframe.period)))
// ===== 時間判定関数 =====
get_current_session() =>
current_hour = hour(time, "GMT+9") // 日本時間基準
if current_hour >= 8 and current_hour < 15
"東京"
else if current_hour >= 15 and current_hour < 23
"ロンドン"
else if current_hour >= 23 or current_hour < 8
"NY"
else
"その他"
// ===== 銘柄自動判定関数 =====
get_asset_settings() =>
ticker_upper = str.upper(syminfo.ticker)
// 安定系通貨ペア
if str.contains(ticker_upper, "USDJPY") or str.contains(ticker_upper, "USD/JPY")
[1.8, -0.3, 0.0, 0.2] // [基本感度, 東京, ロンドン, NY]
else if str.contains(ticker_upper, "EURUSD") or str.contains(ticker_upper, "EUR/USD")
[1.5, -0.2, 0.0, 0.1]
else if str.contains(ticker_upper, "USDCHF") or str.contains(ticker_upper, "USD/CHF")
[1.8, -0.3, 0.0, 0.2]
// 中程度系通貨ペア
else if str.contains(ticker_upper, "AUDUSD") or str.contains(ticker_upper, "AUD/USD")
[2.2, -0.4, 0.0, 0.3]
else if str.contains(ticker_upper, "USDCAD") or str.contains(ticker_upper, "USD/CAD")
[2.0, -0.3, 0.0, 0.2]
else if str.contains(ticker_upper, "EURJPY") or str.contains(ticker_upper, "EUR/JPY")
[2.3, -0.4, 0.1, 0.3]
// 激しい系通貨ペア
else if str.contains(ticker_upper, "GBPUSD") or str.contains(ticker_upper, "GBP/USD")
[2.8, -0.5, 0.1, 0.4]
// 貴金属・株価指数
else if str.contains(ticker_upper, "GOLD") or str.contains(ticker_upper, "XAUUSD") or str.contains(ticker_upper, "XAU")
[3.5, -0.6, 0.2, 0.5]
else if str.contains(ticker_upper, "NASDAQ") or str.contains(ticker_upper, "NAS100") or str.contains(ticker_upper, "US100")
[4.0, -0.8, 0.3, 0.7]
// デフォルト
else
[1.8, -0.3, 0.0, 0.2]
// ===== 設定値取得(自動or手動) =====
[auto_base, auto_tokyo, auto_london, auto_ny] = get_asset_settings()
final_base_sensitivity = use_auto_settings ? auto_base : manual_base_sensitivity
final_tokyo_adj = use_auto_settings ? auto_tokyo : manual_tokyo_adj
final_london_adj = use_auto_settings ? auto_london : manual_london_adj
final_ny_adj = use_auto_settings ? auto_ny : manual_ny_adj
// ===== 動的感度計算関数 =====
get_dynamic_sensitivity() =>
if not enable_time_adjustment
final_base_sensitivity
else
session = get_current_session()
adjustment = switch session
"東京" => final_tokyo_adj
"ロンドン" => final_london_adj
"NY" => final_ny_adj
=> 0.0
result = math.max(0.5, final_base_sensitivity + adjustment)
result
// ===== 配信用調整適用 =====
live_adj = enable_live_mode ? live_adjustment : 0.0
// ===== 最終基本感度 =====
effective_base_sensitivity = get_dynamic_sensitivity() + live_adj
// ===== ATR動的調整計算 =====
current_atr = ta.atr(atr_period_global)
atr_sma = ta.sma(current_atr, atr_smoothing)
atr_ratio = current_atr / atr_sma
// ボラティリティ調整係数
volatility_multiplier = enable_dynamic_atr ? (1.0 + volatility_sensitivity * (2.0 - atr_ratio)) : 1.0
// 最終ATR感度
a = effective_base_sensitivity * volatility_multiplier
// ===== UTBOTコアロジック =====
xATR = ta.atr(atr_period)
nLoss = a * xATR
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, Price, lookahead=barmerge.lookahead_off) : Price
var float xATRTrailingStop = na
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2
var int pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
// Moving Average関数
ma_function(_src, _len) =>
if smoothing == "SMA"
ta.sma(_src, _len)
else if smoothing == "EMA"
ta.ema(_src, _len)
else if smoothing == "WMA"
ta.wma(_src, _len)
else
ta.hma(_src, _len)
ema = ma_function(src, MA_Period)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
// 基本シグナル
buy_signal = src > xATRTrailingStop and above
sell_signal = src < xATRTrailingStop and below
// ===== アラートシステム =====
var int last_buy_alert_time = 0
var int last_sell_alert_time = 0
buy_cooldown_ok = not use_cooldown or (bar_index - last_buy_alert_time) >= cooldown_bars
sell_cooldown_ok = not use_cooldown or (bar_index - last_sell_alert_time) >= cooldown_bars
// 銘柄名取得関数
get_short_ticker() =>
ticker_upper = str.upper(syminfo.ticker)
result = ""
if str.contains(ticker_upper, "USDJPY") or str.contains(ticker_upper, "USD/JPY")
result := "USDJPY"
else if str.contains(ticker_upper, "EURUSD") or str.contains(ticker_upper, "EUR/USD")
result := "EURUSD"
else if str.contains(ticker_upper, "GBPUSD") or str.contains(ticker_upper, "GBP/USD")
result := "GBPUSD"
else if str.contains(ticker_upper, "AUDUSD") or str.contains(ticker_upper, "AUD/USD")
result := "AUDUSD"
else if str.contains(ticker_upper, "USDCAD") or str.contains(ticker_upper, "USD/CAD")
result := "USDCAD"
else if str.contains(ticker_upper, "EURJPY") or str.contains(ticker_upper, "EUR/JPY")
result := "EURJPY"
else if str.contains(ticker_upper, "USDCHF") or str.contains(ticker_upper, "USD/CHF")
result := "USDCHF"
else if str.contains(ticker_upper, "GOLD") or str.contains(ticker_upper, "XAUUSD") or str.contains(ticker_upper, "XAU")
result := "GOLD"
else if str.contains(ticker_upper, "NASDAQ") or str.contains(ticker_upper, "NAS100") or str.contains(ticker_upper, "US100")
result := "NASDAQ"
else
result := syminfo.ticker
result
// 価格フォーマット関数
fmt_price() =>
ticker_upper = str.upper(syminfo.ticker)
result = ""
if str.contains(ticker_upper, "NASDAQ") or str.contains(ticker_upper, "NAS100") or str.contains(ticker_upper, "US100")
result := str.tostring(close, "#")
else if str.contains(ticker_upper, "GOLD") or str.contains(ticker_upper, "XAU") or str.contains(ticker_upper, "AUD") or str.contains(ticker_upper, "GBP")
result := str.tostring(close, "#.##")
else if str.contains(ticker_upper, "JPY")
result := str.tostring(close, "#.###")
else if str.contains(ticker_upper, "USD") and not str.contains(ticker_upper, "JPY")
result := str.tostring(close, "#.#####")
else
result := str.tostring(close, "#.##")
result
// シンプルなチャンス判定
get_chance_info() =>
if atr_ratio > 1.2
"チャンス大"
else if atr_ratio > 0.8
"チャンス中"
else
"要注意"
// アラート(シンプル改良版)
if alert_time_ok and use_improved_alerts and barstate.isconfirmed
price_str = fmt_price()
short_ticker = get_short_ticker()
session_name = get_current_session()
chance_info = get_chance_info()
if buy_signal and buy_cooldown_ok
alert("🚀 " + short_ticker + " BUY " + price_str + " | " + session_name + "タイム [" + chance_info + "]", alert.freq_once_per_bar_close)
last_buy_alert_time := bar_index
if sell_signal and sell_cooldown_ok
alert("🔥 " + short_ticker + " SELL " + price_str + " | " + session_name + "タイム [" + chance_info + "]", alert.freq_once_per_bar_close)
last_sell_alert_time := bar_index
// ===== 表示要素の事前計算 =====
current_session = get_current_session()
session_color = switch current_session
"東京" => color.new(#4CAF50, 0) // 緑系
"ロンドン" => color.new(#2196F3, 0) // 青系
"NY" => color.new(#FF9800, 0) // オレンジ系
=> color.gray
// ボラティリティ状態
high_volatility = enable_dynamic_atr and atr_ratio > 1.2
low_volatility = enable_dynamic_atr and atr_ratio < 0.8
// ===== 表示 =====
plot(ema, title="Moving Average", color=color.rgb(29,166,87), linewidth=2)
// 超大型シグナル表示(ネオン効果)
if buy_signal
label.new(x=bar_index, y=low, text="BUY", style=label.style_label_up, color=color.new(color.lime, 0), textcolor=color.black, size=size.huge, tooltip="UTBOTエントリーシグナル")
if sell_signal
label.new(x=bar_index, y=high, text="SELL", style=label.style_label_down, color=color.new(color.fuchsia, 0), textcolor=color.white, size=size.huge, tooltip="UTBOTエントリーシグナル")
// セッション情報表示
if show_session_info
chance_info_display = get_chance_info()
mode_display = use_auto_settings ? "AUTO" : "MANUAL"
var table session_tbl = table.new(position.top_right, 1, 1,
frame_color=color.new(session_color, 10),
border_color=color.new(color.white, 0),
frame_width=3,
border_width=2)
table.cell(session_tbl, 0, 0, current_session + "\n" + chance_info_display + "\n" + mode_display,
text_color=color.white,
text_size=size.normal,
bgcolor=color.new(session_color, 20))
// ATR状態表示
plotchar(high_volatility, title="High Volatility", char="H", location=location.bottom, color=color.orange, size=size.tiny)
plotchar(low_volatility, title="Low Volatility", char="L", location=location.bottom, color=color.blue, size=size.tiny)