双 EMA ゴールデンクロス 取引戦略

作者: リン・ハーンチャオチャン開催日:2023年12月7日 15:08:57
タグ:

img

概要

この戦略は,二重EMA黄金十字,標準化されたATRノイズフィルター,およびADXトレンドインジケーターを組み合わせて,トレーダーにより信頼性の高い購入信号を提供します. 偽の信号をフィルタリングし,より信頼性の高い取引機会を識別するために複数のインジケーターを統合します.

戦略原則

この戦略は8期と20期 EMAを使用して,EMAの双重黄金十字システムを構築する.より短い期間のEMAがより長い期間のEMAを超えると購入シグナルを生成する.

さらに,この戦略では,フィルタリングのためのいくつかの補助指標が設定されています.

  1. 14期間のATRは,市場でのわずかな価格変動をフィルタリングするために標準化されています.

  2. 14 期間の ADX は,トレンドの強さを特定する.トレードは強いトレンドでのみ考慮されます.

  3. 取引量が少ない時間帯をフィルタリングするために 14 期間のSMA のボリューム

  4. 4/14期間のスーパートレンド指標で 市場が上昇するか下落するか判断します

トレンド方向,標準化されたATR値,ADXレベル,ボリューム条件が満たされたときのみ,EMAの黄金十字が最終的に購入信号を誘発する.

戦略 の 利点

  1. 複数の指標の組み合わせによる信頼性

    EMA,ATR,ADX,スーパートレンドなどの指標を統合することで 強力なシグナルフィルタリングシステムと より高い信頼性が形成されます

  2. パラメータ調整の柔軟性

    標準化されたATR,ADX,保持期間等の限界値を最適化し,柔軟性を高めることができます.

  3. 牛市場と熊市場を区別する

    スーパートレンドを使って オスと熊の市場を特定し 逃した機会を回避します

戦略リスク

  1. パラメータ最適化における困難

    パラメータが多すぎて 最適な組み合わせを見つけるのが難しい

  2. 指標の故障リスク

    インディケーターの遅延性により,誤った信号が発生する危険性があります.適切なストップ損失理論は考慮する必要があります.

  3. 取引頻度が低い

    複数のフィルターにより頻度は低く,長期間の非取引は可能である.

オプティマイゼーションの方向性

  1. パラメータの組み合わせを最適化

    最適な組み合わせを見つけるには 大量のバックテストデータが必要です

  2. 機械学習を組み込む

    MLアルゴリズムを使って パーマータを自動的に最適化し 適応性を向上させる

  3. より多くの市場要因を考慮してください

    市場構造や感情などの指標を組み合わせることで 多様性が向上します

結論

この戦略は,トレンド,波動性およびボリューム価格要因を包括的に考慮する.マルチインジケーターフィルタリングとパラメータチューニングを通じて,信頼性の高い取引システムを形成する.信頼性は高く,最適化によってさらに改善することができる.


/*backtest
start: 2023-11-29 00:00:00
end: 2023-12-06 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/


//Description:
//This strategy is a refactored version of an EMA cross strategy with a normalized ATR filter and ADX control. 
//It aims to provide traders with signals for long positions based on market conditions defined by various indicators.

//How it Works:
//1. EMA: Uses short (8 periods) and long (20 periods) EMAs to identify crossovers.
//2. ATR: Uses a 14-period ATR, normalized to its 20-period historical range, to filter out noise.
//3. ADX: Uses a 14-period RMA to identify strong trends.
//4. Volume: Filters trades based on a 14-period SMA of volume.
//5. Super Trend: Uses a Super Trend indicator to identify the market direction.

//How to Use:
//- Buy Signal: Generated when EMA short crosses above EMA long, and other conditions like ATR and market direction are met.
//- Sell Signal: Generated based on EMA crossunder and high ADX value.

//Originality and Usefulness:
//This script combines EMA, ATR, ADX, and Super Trend indicators to filter out false signals and identify more reliable trading opportunities. 
//USD Strength is not working, just simulated it as PSEUDO CODE: [close>EMA(50)]

//Strategy Results:
//- Account Size: $1000
//- Commission: Not considered
//- Slippage: Not considered
//- Risk: Less than 5% per trade
//- Dataset: Aim for more than 100 trades for sufficient sample size

//Note: This script should be used for educational purposes and should not be considered as financial advice.

//Chart:
//- The script's output is plotted as Buy and Sell signals on the chart.
//- No other scripts are included for clarity.
//- Have tested with 30mins period
//- You are encouraged to play with parameters, let me know if you 

//@version=5
strategy("Advanced EMA Cross with Normalized ATR Filter, Controlling ADX", shorttitle="ALP V5", overlay=true )

// Initialize variables
var bool hasBought = false
var int barCountSinceBuy = 0

// Define EMA periods
emaShort = ta.ema(close, 8)
emaLong = ta.ema(close, 20)

// Define ATR parameters
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

// Calculate USD strength
// That's not working as usd strenght, since I couldn't manage to get usd strength 
//I've just simulated it as if the current close price is above 50 days average (it's likely a bullish trend), usd is strong (usd_strenth variable is positive)
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

// Market direction using Super Trend indicator
[supertrendValue, supertrendDirection] = ta.supertrend(4, 14)
bool isBullMarket = supertrendDirection < 0
bool isBearMarket = supertrendDirection > 0

// Buy conditions for Bull and Bear markets
buyConditionBull = isBullMarket and ta.crossover(emaShort, emaLong) and normalizedATR > 0.2
buyConditionBear = isBearMarket and ta.crossover(emaShort, emaLong) and normalizedATR > 0.5
buyCondition = buyConditionBull or buyConditionBear

// Sell conditions for Bull and Bear markets
sellConditionBull = isBullMarket and (ta.crossunder(emaShort, emaLong) or isADXHigh)
sellConditionBear = isBearMarket and (ta.crossunder(emaShort, emaLong) or isADXHigh)
sellCondition = sellConditionBull or sellConditionBear

// Final Buy and Sell conditions
if (buyCondition)
    strategy.entry("Buy", strategy.long)
    positionPrice := close
    hasBought := true
    barCountSinceBuy := 0

if (hasBought)
    barCountSinceBuy := barCountSinceBuy + 1

// Stop-loss and take-profit levels
longStopLoss = positionPrice * (1 - stopLossPercent / 100)
longTakeProfit = positionPrice * (1 + takeProfitPercent / 100)

// Final Sell condition
finalSellCondition = sellCondition and hasBought and barCountSinceBuy >= 3 and isVolumeHigh

if (finalSellCondition)
    strategy.close("Buy")
    positionPrice := na
    hasBought := false
    barCountSinceBuy := 0

// Implement stop-loss and take-profit
strategy.exit("Stop Loss", "Buy", stop=longStopLoss)
strategy.exit("Take Profit", "Buy", limit=longTakeProfit)

// 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")


もっと