· SPY · 手数料 0.100%
TradingViewのパインエディタに以下のコードを貼り付けて戦略を追加してください。
commission_value = 0.100% がバックテストと同じ手数料条件で設定されています。
アラート作成時に Webhook URL に KabuLink の Webhook URL を、
メッセージ は strategy.entry / strategy.close の alert_message が自動で使用されます。
//@version=5
strategy("RSI Strategy [P14 OB70 OS30]", overlay=false,
commission_type = strategy.commission.percent,
commission_value = 0.1,
initial_capital = 1000000,
default_qty_type = strategy.fixed,
default_qty_value = 1)
rsiPeriod = input.int(14, "RSI Period")
overbought = input.int(70, "Overbought")
oversold = input.int(30, "Oversold")
rsiVal = ta.rsi(close, rsiPeriod)
plot(rsiVal, "RSI", color.purple)
hline(overbought, "OB", color.red)
hline(oversold, "OS", color.green)
longEntry = ta.crossover(rsiVal, oversold)
longExit = ta.crossover(rsiVal, overbought)
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 に登録してブローカーを接続すると、TradingView のアラートが自動的に発注されます。
KabuLinkに登録する → ← 戦略一覧に戻る