
双均線金叉死叉止損策は,トレンド追跡策である. ストキャスティック指標の2つの移動平均KとDの金叉と死叉を使用して,買入と売却のタイミングを判断する. 同時に,リスクを管理するために止損を使用する.
この戦略の核心指標は,ストキャスティックの快線Kと慢線Dである.快線Kはストキャスティックの原値の3日単行移動平均である.慢線Dは快線Kの3日単行移動平均である.快線上を通過すると,金叉信号が生じ,多頭トレンドが来ていることを示す,買えます.快線下を通過すると,死叉信号が生じ,空頭トレンドが来ていることを示す,売ることができます.
さらに,この戦略は,ストキャスティックの値が超冷帯 (<20) または超熱帯 (<80) にある場合にのみ取引信号を生成することを条件として設定しています.これは,いくつかの偽信号をフィルターすることができます.
市場に出回った後,ストップ・ストップ・ロスを使ってリスクを制御する. ストップ・ストップのエントリー価格は120ティックで,ストップ・ストップのエントリー価格は60ティックである. 価格がストップまたはストップ・ロスのレベルに達すると,現在のポジションを退出する.
リスク対策:
双均線金叉死叉ストップ・ロスト戦略は,シンプルで実用的なトレンド追跡戦略である. Stochasticの双均線システムを活用して,入札のタイミングを判断し,ストップ・ロストを活用してリスクを制御する. この戦略は,効果が顕著で,実行が容易で,量化取引に適している. 更に最適化すれば,安定した収益性のアルゴリズム取引戦略になる可能性がある.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Strategy alerts workaround", overlay=true)
// disclaimer: this content is purely educational, especially please don't pay attention to backtest results on any timeframe/ticker
// Entries logic: based on Stochastic crossover
k = ta.sma(ta.stoch(close, high, low, 14), 3)
d = ta.sma(k, 3)
crossover = ta.crossover(k,d)
crossunder = ta.crossunder(k,d)
if (crossover and k < 20)
strategy.entry("Buy", strategy.long, alert_message="buy")
if (crossunder and k > 80)
strategy.entry("Sell", strategy.short, alert_message="sell")
// StopLoss / TakeProfit exits:
SL = input.int(60, title="StopLoss Distance from entry price (in Ticks)")
TP = input.int(120, title="TakeProfit Distance from entry price (in Ticks)")
strategy.exit("xl", from_entry="Buy", loss=SL, profit=TP, alert_message="closebuy")
strategy.exit("xs", from_entry="Sell", loss=SL, profit=TP, alert_message="closesell")
// logical conditions exits:
if (crossunder and k <= 80)
strategy.close("Buy", alert_message="closebuy")
if (crossover and k >= 20)
strategy.close("Sell", alert_message="closesell")