📊 KabuLink バックテスト

戦略一覧 参考成績 ← KabuLink に戻る

MACD 設定ガイド

 ·  SPY  ·  手数料 0.100%

① Pine Script(TradingViewに貼り付け)

TradingViewのパインエディタに以下のコードを貼り付けて戦略を追加してください。
commission_value = 0.100% がバックテストと同じ手数料条件で設定されています。
アラート作成時に Webhook URL に KabuLink の Webhook URL を、 メッセージstrategy.entry / strategy.closealert_message が自動で使用されます。

//@version=5
strategy("MACD Strategy [F12/S26/Sig9]", overlay=false,
     commission_type   = strategy.commission.percent,
     commission_value  = 0.1,
     initial_capital   = 1000000,
     default_qty_type  = strategy.fixed,
     default_qty_value = 1)

fastLen   = input.int(12,   "Fast EMA")
slowLen   = input.int(26,   "Slow EMA")
signalLen = input.int(9, "Signal EMA")

[macdLine, signalLine, histLine] = ta.macd(close, fastLen, slowLen, signalLen)

plot(macdLine,   "MACD",   color.blue)
plot(signalLine, "Signal", color.orange)
plot(histLine,   "Hist",   color.gray, style=plot.style_histogram)

longEntry = ta.crossover(macdLine, signalLine)
longExit  = ta.crossunder(macdLine, signalLine)

buyMsg  = '{"symbol": "{{ticker}}", "side": "buy",  "quantity": 1, "order_type": "market", "signal_time": "{{timenow}}"}'
sellMsg = '{"symbol": "{{ticker}}", "side": "sell", "quantity": 1, "order_type": "market", "signal_time": "{{timenow}}"}'

if longEntry
    strategy.entry("Long", strategy.long, alert_message=buyMsg)
if longExit
    strategy.close("Long", alert_message=sellMsg)

② KabuLinkで自動トレードを始める

KabuLink に登録してブローカーを接続すると、TradingView のアラートが自動的に発注されます。

KabuLinkに登録する →   ← 戦略一覧に戻る