
この策略は,均線完全配列とトレンドマジック指標を組み合わせて市場動向を捉えます.この策略は,3つの移動平均 (EMA45,SMA90,SMA180) とCCIとATRをベースにしたトレンドマジック指標を使用します.この策略の核心は,均線完全配列の状況を識別し,トレンドマジック指標の色の変化と組み合わせてトレンドの逆転を確認し,取引信号を生成します.この方法は,偽信号を減らすために作られており,強力なトレンドが形成されたときにのみ取引されます.
戦略の基本は以下の要素に基づいています.
平均線の完璧な並び:EMA45,SMA90,SMA180の3つの平均線を使用し,特定の順序で並べられたとき ((多頭:EMA45 > SMA90 > SMA180;空頭:EMA45 < SMA90 < SMA180),トレンドを確立する強力な信号とみなされます.
トレンドマジック指標:CCI (商品通路指数) とATR (リアル波幅) に基づくカスタム指標である.色の変化によって潜在的トレンドの逆転を示している.
入場条件:平均線が完璧な配列とトレンドマジック指標の色変化が同時に満たされた場合にのみ取引シグナルが生成されます. これは,強いトレンドが形成されたときにのみ取引することを保証します.
リスク管理:戦略は,リスクと報酬の比率に基づく止損と利益の目標を使用します. 止損は,入場時のSMA90レベルに設定され,利益の目標は,リスクの1.5倍に設定されます.
トレンド追跡:複数の指標を組み合わせることで,戦略は中長期のトレンドを効果的に捉え,偽信号を減らすことができます.
リスク管理: 固定ストップとリスクによるリターンに基づく利益目標を含む,内蔵されたリスク管理メカニズムにより,取引ごとにリスクを制御できます.
柔軟性: 戦略は,ユーザが異なる市場条件と個人の好みに合わせて,CCI周期,ATR倍数,移動平均周期などのパラメータを調整することを可能にします.
視覚化: 戦略は,トレンドマジック指標と移動平均をグラフに描画し,トレーダーが市場動向を直観的に分析できるようにする.
落後性:移動平均と他の落後指標を使用しているため,戦略はトレンドの初期にいくつかのチャンスを逃す可能性があります.
振動市場:横盤または振動市場では,戦略は頻繁に偽信号を生じ,過剰取引を引き起こす可能性があります.
固定ストップ:固定SMA90をストップとして使用すると,場合によっては過度に緩やかになり,潜在的損失が増加する.
パラメータ感性: 戦略の性能はパラメータ設定に敏感であり,慎重に最適化および反測する必要があります.
ダイナミックストップ: トラッキングストップを実現することを検討し,価格の動きに合わせてストップレベルを調整し,利益をよりよく保護する.
市場状態フィルター:変動性またはトレンド強度フィルターを導入して,異なる市場条件で戦略行動を調整する.
タイムフレーム分析:信号の信頼性を高め,偽信号を減らすために,複数のタイムフレーム分析を統合する.
定量指標:トレンド確認と逆転認識を強化するために,取引量分析または他の定量指標を追加する.
機械学習の最適化:機械学習アルゴリズムのパラメータを動的に調整して,変化する市場条件に適応する.
この均線の完璧な配列とトレンドマジック指標を組み合わせた自動取引戦略は,潜在的なトレンド追跡方法を示している.この戦略は,複数の技術指標を総合的に利用することで,強力な市場トレンドを捉え,同時に,内蔵されたリスク管理メカニズムでリスクを制御することを目的としている.遅滞性やパラメータへの敏感性などの固有の制限があるにもかかわらず,この戦略は,継続的な最適化と適応的調整によって,効果的な取引ツールになる見込みがある.
/*backtest
start: 2024-08-26 00:00:00
end: 2024-09-24 08:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PakunFX
//@version=5
strategy("Trend Magic with EMA, SMA, and Auto-Trading", shorttitle="TM_Trading", overlay=true, format=format.price, precision=2)
// Inputs
period = input.int(21, "CCI period")
coeff = input.float(1.0, "ATR Multiplier")
AP = input.int(7, "ATR Period")
riskRewardRatio = input.float(1.5, "Risk/Reward Ratio") // Risk/Reward Ratio for take profit
// Calculations
ATR = ta.sma(ta.tr, AP)
src = input(close)
upT = low - ATR * coeff
downT = high + ATR * coeff
var MagicTrend = 0.0
MagicTrend := ta.cci(src, period) >= 0 ? (upT < nz(MagicTrend[1]) ? nz(MagicTrend[1]) : upT) : (downT > nz(MagicTrend[1]) ? nz(MagicTrend[1]) : downT)
// Define colors for Trend Magic
color1 = ta.cci(src, period) >= 0 ? color.rgb(0, 34, 252) : color.rgb(252, 4, 0)
isBlue = ta.cci(src, period) >= 0
isRed = ta.cci(src, period) < 0
// Convert bool to float (1 for true, 0 for false)
isBlueFloat = isBlue ? 1 : 0
isRedFloat = isRed ? 1 : 0
// Moving Averages
ema45 = ta.ema(close, 45)
sma90 = ta.sma(close, 90)
sma180 = ta.sma(close, 180)
// Plot Trend Magic
plot(MagicTrend, color=color1, linewidth=3)
// Alerts
alertcondition(ta.cross(close, MagicTrend), title="Cross Alert", message="Price - MagicTrend Crossing!")
alertcondition(ta.crossover(low, MagicTrend), title="CrossOver Alarm", message="BUY SIGNAL!")
alertcondition(ta.crossunder(high, MagicTrend), title="CrossUnder Alarm", message="SELL SIGNAL!")
// Perfect Order conditions
bullishPerfectOrder = ema45 > sma90 and sma90 > sma180 // Bullish Perfect Order
bearishPerfectOrder = ema45 < sma90 and sma90 < sma180 // Bearish Perfect Order
// Trend Magic color change detection
trendMagicTurnedBlue = ta.crossover(isBlueFloat, isRedFloat) // Red to Blue crossover (For long entry)
trendMagicTurnedRed = ta.crossunder(isBlueFloat, isRedFloat) // Blue to Red crossover (For short entry)
// Variables to store SMA90 at the entry
var float longSma90 = na
var float shortSma90 = na
// Trading logic based on Perfect Order and color change
longCondition = bullishPerfectOrder and trendMagicTurnedBlue // Buy when Perfect Order is bullish and Trend Magic turns red to blue
shortCondition = bearishPerfectOrder and trendMagicTurnedRed // Sell when Perfect Order is bearish and Trend Magic turns blue to red
// Strategy Entry
if (longCondition)
strategy.entry("Buy", strategy.long)
longSma90 := sma90 // Store SMA90 at entry for long position
if (shortCondition)
strategy.entry("Sell", strategy.short)
shortSma90 := sma90 // Store SMA90 at entry for short position
// Stop-Loss and Take-Profit calculations
// For Long Positions: stop at SMA90 (fixed at entry), take profit at 1.5x risk
if (longCondition and not na(longSma90))
longStopLoss = longSma90 // Use SMA90 at the time of entry
longRisk = close - longSma90 // Calculate risk
longTakeProfit = close + longRisk * riskRewardRatio // Calculate take profit
strategy.exit("Take Profit/Stop Loss", "Buy", stop=longStopLoss, limit=longTakeProfit)
// For Short Positions: stop at SMA90 (fixed at entry), take profit at 1.5x risk
if (shortCondition and not na(shortSma90))
shortStopLoss = shortSma90 // Use SMA90 at the time of entry
shortRisk = shortSma90 - close // Calculate risk
shortTakeProfit = close - shortRisk * riskRewardRatio // Calculate take profit
strategy.exit("Take Profit/Stop Loss", "Sell", stop=shortStopLoss, limit=shortTakeProfit)
// Plot Moving Averages
plot(ema45, color=color.green, title="EMA 45")
plot(sma90, color=color.blue, title="SMA 90")
plot(sma180, color=color.red, title="SMA 180")