
双線突破金叉死叉トレンド追跡戦略は,サポートレジスタンスラインと移動平均を予選信号として同時に利用したトレンド追跡型の定量化取引戦略である. この戦略は,価格が異なる時間帯でサポートレジスタンスラインと移動平均の金叉死叉信号を総合的に考慮し,価格突破の重要なサポートとレジスタンスポイントをキャプチャする際に,トレンド指数フィルターと組み合わせて多空のチャンスを作る.
この戦略は以下の4つの部分から構成されています.
具体的には,戦略はまず,要求Security関数を使用して30日および30週間の最高価格と最低価格を取得し,それぞれ動的なサポートラインとレジスタンスラインを区切る. そして,10日移動平均の金叉と死叉の信号を組み合わせて,取引の機会を突破するためにフィルターする. 30日間のサポートレベルより高く,10日間の平均線より高く価格が多信号を生成する. 30日間のレジスタンスレベルより低く価格が10日間の平均線より低い場合空信号を生成する.
この戦略は,中短線と長線の両方のサポート抵抗を考慮し,より大きなトレンドの機会を捕捉します.移動平均と組み合わせると,揺れ傾向の誤った信号を効果的にフィルターできます.
この戦略の利点は以下の通りです.
この戦略にはいくつかのリスクがあります.
対応方法:
この戦略はさらに改善できる余地があります.
双線突破金叉死叉トレンド追跡戦略は,中長線のサポートレジスタンスレベルと移動平均指標を取引信号として総合的に考慮し,大きなトレンドの背景で効率的にノイズをフィルタリングして収益性を実現できる,比較的成熟した量化取引戦略である.この戦略の最適化余地はまだ十分であり,止損機構,パラメータ自適応などの面で改善することができる.また,機械学習などの新しい方法を導入して戦略の安定性を向上させることも試すことができる.
/*backtest
start: 2024-01-22 00:00:00
end: 2024-02-21 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © neosaid
//@version=5
strategy("Support and resistant Strategy", overlay=true)
// Function to check for breakout
f_breakoutCondition(closingPrice, highestHigh, lowestLow) =>
closingPrice > highestHigh or closingPrice < lowestLow
// Step 1: 30 Days Trend Line (Lower Lows)
low30Days = request.security(syminfo.tickerid, "D", low)
// Step 2: 30 Weeks Upper Trend Line (Higher Highs)
high30Weeks = request.security(syminfo.tickerid, "W", high)
// Step 3: Trend Line for Lowest Low within the Last Month
var float lowestLowLastMonth = na
for i = 0 to 29
lowestLowLastMonth := na(lowestLowLastMonth) ? low[i] : math.min(lowestLowLastMonth, low[i])
lowestLowLastMonthValue = lowestLowLastMonth[1]
// Breakout Strategy
highestHighLast3Candles = request.security(syminfo.tickerid, "D", ta.highest(close, 3))
lowestLowLast3Candles = request.security(syminfo.tickerid, "D", ta.lowest(close, 3))
// Additional conditions to filter signals
buyCondition = f_breakoutCondition(close, highestHighLast3Candles, lowestLowLast3Candles) and close > low30Days
sellCondition = f_breakoutCondition(close, highestHighLast3Candles, lowestLowLast3Candles) and close < high30Weeks
// Additional filters to reduce the number of orders
buyFilter = ta.crossover(close, ta.sma(close, 10)) // Buy only when price crosses above a 10-period SMA
sellFilter = ta.crossunder(close, ta.sma(close, 10)) // Sell only when price crosses below a 10-period SMA
buyCondition := buyCondition and buyFilter
sellCondition := sellCondition and sellFilter
// Plot Buy and Sell signals on the chart
plotshape(series=buyCondition, title="Buy Signal", color=color.green, style=shape.triangleup, location=location.belowbar)
plotshape(series=sellCondition, title="Sell Signal", color=color.red, style=shape.triangledown, location=location.abovebar)
// Strategy entries
strategy.entry("Buy", strategy.long, when = buyCondition)
strategy.entry("Sell", strategy.short, when = sellCondition)