
この戦略は,二重EMA均線が金叉多多,死叉空のクラシックなトレンドをフォローする戦略を利用し,ATR指数とADX指数を使って追加のフィルタリングを行い,強いトレンドの時に追跡し,震動の時にリスクを制御する.
この戦略は主に以下の点に基づいています.
より短い8周期EMA平均線とより長い20周期EMA平均線を用いて金叉と死叉の信号を形成する.EMA平均線はそれ自体が傾向に従う性質を有する.
ATR指標は,最近の波動幅を反映している.ATR指標の正規化により,EMA均線交差のフィルタリング条件を動的に調整することができ,強烈なトレンドを追跡する際に要求を低下させ,震動的な状況でフィルタリング要求を高め,リスクを制御することができる.
ADX指標はトレンドの強さを判断する.ADX値が30以上になると,強いトレンドが発生したと考えられ,その時点で,時宜に損保を停止する.
牛市では金叉が多し,熊市では死叉が空きをする.
取引量フィルターで,取引量が増えると入場します.
ドル指数は,ドルが強くなると,ストープ・ペードやストップ・アップ幅が拡大する.
超トレンド指数と組み合わせて,市場全体の動きを判断し,空調のタイミングを判断する.
この戦略は,トレンド指数と震動指数の完全な組み合わせで,動的にパラメータを調整し,トレンドを追跡しながらリスクを制御することができます.
双EMA均線システムを使用してトレンド判断し,EMAは滑らかであり,偽突破を効果的にフィルターすることができる.
ATR指標はEMA均線交差フィルタリング条件を動的に調整し,戦略を異なる市場環境に柔軟に適応させることができる.
ADX指数と取引量は,震動の状況で被套を避けるための補助判断指標として用いられる.
ドル指数と超トレンド指数で大きなトレンドを判断し,意思決定の正確さを向上させる.
リスク管理のパラメータは,ドルが強くなると自動的に調整され,ドルが強くなるとストップ・ローズとストップ・アップ幅が拡大されます.
シンプルで直観的な金叉死叉取引シグナルとストップ・ストップ・ストップ戦略を使用して,容易に実現し,反省する.
二重EMA均線システムは,トレンドの臨界点判断の遅れがあることを排除する.
ATRパラメータの選択を間違えた場合,極端に過激に保守的になる可能性があります.
ADX指標のパラメータは最適化が必要で,ADX高点を不適切に選択するとトレンドを逃す可能性があります.
ドル指数と超トレンド指数では誤差があるかもしれない.
ストップ幅が小さすぎると損失が増加し,幅が広い場合のストップ幅は容易に落とし込まれる.
MACDなどの他の指標と組み合わせてトレンドの臨界点を判断することも考えられます.
ATRのパラメータ空間を,より多くの歴史データを使って訓練し,最適なパラメータ範囲を見つける.
異なるADXパラメータをテストし,ADX高点判断を最適化する.
ドル指数や市場全体の動きを判断する変数を追加する.
測定データに基づいて最適の止損幅を計算する.
移動停止または振動停止に変更することを考慮することができます.
ポジション開設のサイズと保持周期の最適化を継続する.
この戦略は,クラシックな二重EMA均線システムと複数の補助指標を統合し,パラメータの自動最適化により,より完全なトレンドフォロー戦略を実現する. 市場環境の変化に柔軟に適応し,トレンドを追跡しながらリスクを制御することができる.しかし,より良い安定した収益を得るため,止損と指標のパラメータに対してさらなるテストと最適化が必要である.この戦略は,アイデアを参考にして改善する価値がある.
/*backtest
start: 2023-10-15 00:00:00
end: 2023-11-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Refactored Advanced EMA Cross with Normalized ATR Filter, Controlling ADX", shorttitle="ALP V5", overlay=true)
// Initialize variables to track if a buy order has been placed and number of periods since the last buy
var bool hasBought = false
var int barCountSinceBuy = 0
// Define EMA periods
emaShort = ta.ema(close, 8)
emaLong = ta.ema(close, 20)
// Define ATR period and normalization
atrLength = 14
atrValue = ta.atr(atrLength)
maxHistoricalATR = ta.highest(atrValue, 20)
minHistoricalATR = ta.lowest(atrValue, 20)
normalizedATR = (atrValue - minHistoricalATR) / (maxHistoricalATR - minHistoricalATR)
// Define ADX parameters
adxValue = ta.rma(close, 14)
adxHighLevel = 30
isADXHigh = adxValue > adxHighLevel
// Initialize risk management variables
var float stopLossPercent = na
var float takeProfitPercent = na
var float trailingStop = na
// Calculate USD strength (simplified)
usd_strength = close / ta.ema(close, 50) - 1
// Adjust risk parameters based on USD strength
if (usd_strength > 0)
stopLossPercent := 3
takeProfitPercent := 6
else
stopLossPercent := 4
takeProfitPercent := 8
// Initialize position variable
var float positionPrice = na
// Volume filter
minVolume = ta.sma(volume, 14) * 1.5
isVolumeHigh = volume > minVolume
// Piyasa yönü için süper trend göstergesi
[supertrendValue, supertrendDirection] = ta.supertrend(4, 14) // Use a factor of 3 and ATR period of 10
bool isBullMarket = supertrendDirection < 0
bool isBearMarket = supertrendDirection > 0
// Yükselen piyasa için alım koşulu
buyConditionBull = isBullMarket and ta.crossover(emaShort, emaLong) and normalizedATR > 0.2
// Düşen piyasa için alım koşulu
buyConditionBear = isBearMarket and ta.crossover(emaShort, emaLong) and normalizedATR > 0.5
// Genel alım koşulu
buyCondition = buyConditionBull or buyConditionBear
// Yükselen ve düşen piyasalar için farklı satış koşulları
sellConditionBull = isBullMarket and (ta.crossunder(emaShort, emaLong) or isADXHigh)
sellConditionBear = isBearMarket and (ta.crossunder(emaShort, emaLong) or isADXHigh)
// Genel satış koşulu
sellCondition = sellConditionBull or sellConditionBear
// Buy condition
if (buyCondition)
strategy.entry("Buy", strategy.long)
positionPrice := close
hasBought := true // Set the flag to true when a buy order is placed
barCountSinceBuy := 0 // Reset the bar counter when a buy order is placed
// Increase the bar counter if a buy has been executed
if (hasBought)
barCountSinceBuy := barCountSinceBuy + 1
// Calculate stop-loss and take-profit levels
longStopLoss = positionPrice * (1 - stopLossPercent / 100)
longTakeProfit = positionPrice * (1 + takeProfitPercent / 100)
// Final Sell condition, now also checks if a buy has occurred before and if at least 5 periods have passed
finalSellCondition = sellCondition and hasBought and barCountSinceBuy >= 3 and isVolumeHigh
if (finalSellCondition)
strategy.close("Buy")
positionPrice := na
hasBought := false // Reset the flag when a sell order is placed
barCountSinceBuy := 0 // Reset the bar counter when a buy order is closed
// Implement stop-loss, take-profit, and trailing stop
strategy.exit("Stop Loss", "Buy", stop=longStopLoss)
strategy.exit("Take Profit", "Buy", limit=longTakeProfit)
//strategy.exit("Trailing Stop", "Buy", trail_price=close, trail_offset=trailingStop * close / 100)
var label l = na
if (buyCondition)
l := label.new(bar_index, high, text="buy triggered " + str.tostring(usd_strength))
label.delete(l[1])
if (finalSellCondition)
l := label.new(bar_index, high, text="sell triggered " + str.tostring(usd_strength))
label.delete(l[1])
// Plot signals
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=finalSellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")