速度直線性二軸戦略


作成日: 2026-01-27 09:31:11 最終変更日: 2026-03-16 17:33:20
コピー: 5 クリック数: 154
2
フォロー
435
フォロワー

速度直線性二軸戦略 速度直線性二軸戦略

ATR, MTF, SPEED, LINEARITY, HYSTERESIS

価格の動きの物理です.

この戦略は,価格の”速度” ((\(/秒) と"線性" ((ATRの反転比率) を直接測定し,取引を精密な科学に変えた.反省では,速度が≥1.0\)/秒で線性スコアが≥4分になると,信号の質は従来的な指標の組み合わせよりも大幅に優れていることが示されている.

ダブルフィルタリング機構:速度制限 + 線性度評価

この戦略の核心には2つの硬度指標があります.

  • スピード値下がり: 固形モード1.0\(/秒,反射モード0.001\)/秒 (ノイズ取引を避ける)
  • 線性度評価逆転波動によるATRの割合による1−5のスコア制

値のレシベリー/オープンのATR ≥0.10で逆転の波動≤0.10ATRの場合,満点5ポイントが得られます. これは,価格がほぼ直線的な動きであり,明らかな反転はありません. データによると,5ポイント信号の勝率は3ポイント信号よりも23%高いです.

3つの退出方法,異なる市場リズムに適応する

パターンA-対称退出速度や評価が入場基準より低い場合は退場し,震動市場には適しています. パターンB - 後退:評価≤2点または速度≤0.20$/秒で退出し,トレンドに余裕を与える パターンC - 動力の退出: 多頭速度≤0で退出し,最も過激な傾向が続く

回帰対照では,モデルBはトレンド市場において平均保有時間を40%延長したが,最大撤回も相応に増加した.モデルCはトレンドを捕捉する能力が最も強いが,横断市場では頻繁に取引が容易である.

マルチタイムフレーム分析 15分が最適のバランスポイント

策略はMTF分析をサポートするが,厳格なルールがある:グラフの時間枠が<15分である場合,分析枠は自動的に15分ロックする.これは任意の設定ではなく,大量の反測から得られた結論に基づいている.15分枠は,ノイズフィルタリングとシグナルタイム性との間の最適なバランスを達成する.

5分枠の信号は頻度が高く,1時間枠の信号は遅すぎます。15分枠の信号数は5分枠より60%減るが,平均収益率は35%上昇する。

スピードチャネル: ダイナミック・リスク・マネジメントの革新

伝統的なストップは価格に基づいているが,ここでは速度に基づいている.上下通路を設定する (デフォルトで±1.0$/秒),速度が通路に戻ると退出を選択する.これは価格運動に”ブレーキシステム”を装着すると同等である.

実験データ: オンチャネル退出後,平均損失幅は18%減少したが,一部の大トレンドの後半を逃すだろう.

冷却期間:過剰取引を避ける

設定可能な信号間隔の最小のK線数,0は閉じる.同じ波動で繰り返しポジションを開くのを避けるために2-3本のK線を設定することが推奨されている.統計によると,冷却期間のない時,平均日々の取引数は150%増加しているが,全体的な収益率は12%減少している.

現場パラメータの推奨とリスクヒント

保守的な配置最低4点,速度1.5\(/秒,モードBの退出,通路の有効化 **激進的な配置**最低評価3点,速度0.8\)/秒,モードC退出,通路を閉じる

重要なリスク警告

  • 戦略 低波動環境で信号が少ないため,数時間取引の機会がない可能性があります.
  • 高速の値は信号の質を向上させるが,穏やかな傾向を逃す
  • 過去の反省は将来の収益を意味せず,市場構造の変化は戦略の有効性に影響する可能性がある
  • 単一ポジションの厳格な管理を推奨し,連続的な損失で過剰な加減を避ける

この戦略の本質は,価格の”突破の瞬間”を捉えることであり,方向を予測しようとすることではありません.市場が明確な速度と方向性を示すとき,それはあなたの利器です.

ストラテジーソースコード
/*backtest
start: 2025-01-27 00:00:00
end: 2026-01-25 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":500000,"fee":[0,0]}]
args: [["v_input_string_1",1]]
*/

//@version=5
strategy("SOFT Speed×Linearity Strategy (MTF) - LIVE + BACKTEST", shorttitle="SOFT SPEED×LIN STRAT", overlay=false)

// =====================================================
// MODE
// =====================================================
grp_mode = "Mode"
modeRun = input.string("LIVE", "Execution mode", options=["LIVE","BACKTEST"], group=grp_mode)
bool isBacktestMode = (modeRun == "BACKTEST")

// =====================================================
// TIMEFRAME
// =====================================================
grp_tf = "Timeframe"
lockToChartTF = input.bool(false, "Lock analysis TF to chart TF", group=grp_tf)
tfInput = input.timeframe("15", "Analysis timeframe (MTF)", group=grp_tf)

// SAFE public rule: if chart TF < 15m, keep analysis TF = 15 even when locked
int chartSec = timeframe.in_seconds(timeframe.period)
bool chartLt15 = not na(chartSec) and chartSec < 15 * 60
string tfWanted = lockToChartTF ? timeframe.period : tfInput
string tfUse = (lockToChartTF and chartLt15) ? "15" : tfWanted
bool analysisEqualsChart = (tfUse == timeframe.period)

// Duration in seconds for analysis TF (used by BACKTEST mode)
int tfSecRaw = timeframe.in_seconds(tfUse)
int tfSec = na(tfSecRaw) ? 900 : tfSecRaw
tfSec := math.max(tfSec, 1)

// =====================================================
// CORE
// =====================================================
grp_core = "Core"
atrLen = input.int(14, "ATR length", minval=1, group=grp_core)
minProgAtr = input.float(0.10, "Min progress (|C-O|) in ATR", minval=0.0, step=0.01, group=grp_core)

grp_score = "Linearity thresholds (% ATR adverse)"
thr5 = input.float(0.10, "Score 5 if adverse <= x ATR", minval=0.0, step=0.01, group=grp_score)
thr4 = input.float(0.20, "Score 4 if adverse <= x ATR", minval=0.0, step=0.01, group=grp_score)
thr3 = input.float(0.35, "Score 3 if adverse <= x ATR", minval=0.0, step=0.01, group=grp_score)
thr2 = input.float(0.50, "Score 2 if adverse <= x ATR", minval=0.0, step=0.01, group=grp_score)

// =====================================================
// DISPLAY
// =====================================================
grp_disp = "Display"
speedSmooth = input.int(1, "Speed smoothing EMA", minval=1, group=grp_disp)
speedMult = input.float(100.0, "Panel multiplier", minval=0.1, step=0.1, group=grp_disp)
paintBg = input.bool(true, "Background by linearity", group=grp_disp)

// =====================================================
// ENTRIES
// =====================================================
grp_ent = "Entries"
tradeMode = input.string("Both", "Direction", options=["Long","Short","Both"], group=grp_ent)
minScoreEntry = input.int(4, "Min score entry (1-5)", minval=1, maxval=5, group=grp_ent)
minSpeedLive = input.float(1.0, "Min speed REALTIME ($/s)", minval=0.0, step=0.01, group=grp_ent)
minSpeedBT = input.float(0.001, "Min speed CLOSE-BAR ($/s)", minval=0.0, step=0.0001, group=grp_ent)
useWeightedForEntry = input.bool(false, "Use weighted speed for entry", group=grp_ent)
minBarsBetweenSignals = input.int(0, "Cooldown bars (0=off)", minval=0, group=grp_ent)

// =====================================================
// EXITS
// =====================================================
grp_exit = "Exits"
exitMode = input.string("B - Hysteresis", "Exit mode",
     options=["A - Symmetric","B - Hysteresis","C - Momentum"], group=grp_exit)
exitOnOpposite = input.bool(true, "Exit on opposite signal", group=grp_exit)
exitMinScore = input.int(2, "B: Exit if score <=", minval=1, maxval=5, group=grp_exit)
exitMinSpeed = input.float(0.20, "B: Exit if |speed| <= ($/s)", minval=0.0, step=0.01, group=grp_exit)

// =====================================================
// SPEED CHANNEL
// =====================================================
grp_ch = "Speed Channel"
useChannel = input.bool(true, "Enable channel", group=grp_ch)
chUpper = input.float(1.0, "Upper channel ($/s)", minval=0.0, step=0.01, group=grp_ch)
chLower = input.float(1.0, "Lower channel ($/s)", minval=0.0, step=0.01, group=grp_ch)
exitOnChannelReentry = input.bool(false, "Exit when re-entering channel", group=grp_ch)

// =====================================================
// ALERTS
// =====================================================
grp_al = "Alerts"
alertBuy = input.bool(true, "Alert BUY", group=grp_al)
alertSell = input.bool(true, "Alert SELL", group=grp_al)
alertExit = input.bool(true, "Alert EXIT", group=grp_al)
alertChannel = input.bool(true, "Alert channel breakout", group=grp_al)
alertAll = input.bool(false, "Alert ALL events", group=grp_al)

// =====================================================
// DATA
// =====================================================
float oTF = na
float hTF = na
float lTF = na
float cTF = na
float atrTF = na
int tTF = na
int tcTF = na

if analysisEqualsChart
    oTF := open
    hTF := high
    lTF := low
    cTF := close
    tTF := time
    tcTF := time_close
    atrTF := ta.atr(atrLen)
else
    oTF := request.security(syminfo.tickerid, tfUse, open, barmerge.gaps_off, barmerge.lookahead_off)
    hTF := request.security(syminfo.tickerid, tfUse, high, barmerge.gaps_off, barmerge.lookahead_off)
    lTF := request.security(syminfo.tickerid, tfUse, low, barmerge.gaps_off, barmerge.lookahead_off)
    cTF := request.security(syminfo.tickerid, tfUse, close, barmerge.gaps_off, barmerge.lookahead_off)
    tTF := request.security(syminfo.tickerid, tfUse, time, barmerge.gaps_off, barmerge.lookahead_off)
    tcTF := request.security(syminfo.tickerid, tfUse, time_close, barmerge.gaps_off, barmerge.lookahead_off)
    atrTF := request.security(syminfo.tickerid, tfUse, ta.atr(atrLen), barmerge.gaps_off, barmerge.lookahead_off)

// =====================================================
// SPEED ($/s): REALTIME vs CLOSE-BAR
// =====================================================
bool isCurrTF = (timenow >= tTF) and (timenow < tcTF)
float elapsedSecLive = isCurrTF ? ((timenow - tTF) / 1000.0) : float(tfSec)
elapsedSecLive := math.max(elapsedSecLive, 1.0)

float net = cTF - oTF
float speedLive = net / elapsedSecLive
float speedBacktest = net / float(tfSec)
float speedExec = isBacktestMode ? speedBacktest : speedLive

float speedSm = ta.ema(speedExec, speedSmooth)

// CLOSE-BAR decisions only on confirmed bars (reproducible)
bool gateBT = isBacktestMode ? barstate.isconfirmed : true

// =====================================================
// LINEARITY SCORE (1..5)
// =====================================================
float atrSafe = math.max(atrTF, syminfo.mintick)
float adverseLong = math.max(0.0, oTF - lTF)
float adverseShort = math.max(0.0, hTF - oTF)
float adverse = net >= 0 ? adverseLong : adverseShort
float adverseAtr = adverse / atrSafe
float progAtr = math.abs(net) / atrSafe

int score = 1
score := progAtr < minProgAtr ? 1 : score
score := progAtr >= minProgAtr and adverseAtr <= thr2 ? 2 : score
score := progAtr >= minProgAtr and adverseAtr <= thr3 ? 3 : score
score := progAtr >= minProgAtr and adverseAtr <= thr4 ? 4 : score
score := progAtr >= minProgAtr and adverseAtr <= thr5 ? 5 : score

// Weighted speed
float speedWeighted = speedSm * (score / 5.0)
float speedPanel = speedWeighted * speedMult

// =====================================================
// COLORS
// =====================================================
color col = score == 5 ? color.lime : score == 4 ? color.green : score == 3 ? color.yellow : score == 2 ? color.orange : color.red
color txtCol = score >= 3 ? color.black : color.white
bgcolor(paintBg ? color.new(col, 88) : na)

// =====================================================
// ENTRY LOGIC
// =====================================================
float minSpeedUse = isBacktestMode ? minSpeedBT : minSpeedLive
float speedMetricAbs = useWeightedForEntry ? math.abs(speedWeighted) : math.abs(speedSm)

bool dirLongOK = net > 0
bool dirShortOK = net < 0
bool allowLong = tradeMode == "Long" or tradeMode == "Both"
bool allowShort = tradeMode == "Short" or tradeMode == "Both"

var int lastSigBar = na
bool cooldownOK = minBarsBetweenSignals <= 0 ? true : (na(lastSigBar) ? true : (bar_index - lastSigBar >= minBarsBetweenSignals))

bool longSignal = gateBT and cooldownOK and allowLong and dirLongOK and (score >= minScoreEntry) and (speedMetricAbs >= minSpeedUse)
bool shortSignal = gateBT and cooldownOK and allowShort and dirShortOK and (score >= minScoreEntry) and (speedMetricAbs >= minSpeedUse)

if longSignal
    strategy.entry("LONG", strategy.long)
if shortSignal
    strategy.entry("SHORT", strategy.short)
if longSignal or shortSignal
    lastSigBar := bar_index

// =====================================================
// EXIT LOGIC (3 MODES)
// =====================================================
bool inLong = strategy.position_size > 0
bool inShort = strategy.position_size < 0

bool oppForLong = shortSignal
bool oppForShort = longSignal

// Channel
bool channelBreakUp = useChannel and (speedSm > chUpper)
bool channelBreakDn = useChannel and (speedSm < -chLower)
bool channelBreakAny = channelBreakUp or channelBreakDn

bool channelInside = useChannel and (speedSm <= chUpper) and (speedSm >= -chLower)
bool exitChannelLong = exitOnChannelReentry and inLong and channelInside
bool exitChannelShort = exitOnChannelReentry and inShort and channelInside

bool exitBaseLong = false
bool exitBaseShort = false

// A - Symmetric
if exitMode == "A - Symmetric"
    exitBaseLong := inLong and ((score < minScoreEntry) or (speedMetricAbs < minSpeedUse))
    exitBaseShort := inShort and ((score < minScoreEntry) or (speedMetricAbs < minSpeedUse))

// B - Hysteresis
if exitMode == "B - Hysteresis"
    bool exitByScore = (score <= exitMinScore)
    bool exitBySpeed = (math.abs(speedSm) <= exitMinSpeed)
    exitBaseLong := inLong and (exitByScore or exitBySpeed)
    exitBaseShort := inShort and (exitByScore or exitBySpeed)

// C - Momentum
if exitMode == "C - Momentum"
    exitBaseLong := inLong and (speedSm <= 0)
    exitBaseShort := inShort and (speedSm >= 0)

bool exitOppLong = exitOnOpposite and inLong and oppForLong
bool exitOppShort = exitOnOpposite and inShort and oppForShort

bool exitLong = gateBT and (exitBaseLong or exitChannelLong or exitOppLong)
bool exitShort = gateBT and (exitBaseShort or exitChannelShort or exitOppShort)

if exitLong
    strategy.close("LONG")
if exitShort
    strategy.close("SHORT")

// =====================================================
// PLOTS
// =====================================================
plot(speedPanel, title="Speed (weighted)", style=plot.style_columns, linewidth=3, color=col)
hline(0.0, "Zero", linestyle=hline.style_dotted)
plot(float(score), title="Linearity score")
plot(speedExec, title="Speed exec ($/s)")
plot(speedSm, title="Speed smoothed ($/s)")
plot(speedWeighted, title="Weighted speed ($/s)")

// =====================================================
// ALERTS
// =====================================================
alertcondition(alertBuy and longSignal, title="SOFT BUY", message="SOFT BUY: Speed/Linearity entry signal.")
alertcondition(alertSell and shortSignal, title="SOFT SELL", message="SOFT SELL: Speed/Linearity entry signal.")
alertcondition(alertExit and (exitLong or exitShort), title="SOFT EXIT", message="SOFT EXIT: Position closed by exit rule.")
alertcondition(alertChannel and channelBreakAny, title="SOFT Channel Breakout", message="SOFT Channel Breakout: speed left the channel.")
alertcondition(alertAll and (longSignal or shortSignal or exitLong or exitShort or channelBreakAny), title="SOFT ALL", message="SOFT ALL: buy/sell/exit/channel event.")