
この戦略は,複数の時間周期の動動平均線組み合わせ戦略である.これは,異なる長さの指数移動平均 ((EMA) を使用して,トレンド判断と入場退出を行う.戦略名にあるMAXは,複数のEMAが使用されていることを示す.動は,EMAの長さが調整可能であることを示す.
この戦略は,7つの異なる速度のEMAを使用し,最速から最速まで,それぞれ:3サイクル,15サイクル,19サイクル50サイクル100サイクル150サイクルおよび200サイクルのEMAである.この7つのEMAは,長ポジションと短いポジションのシグナルを判断する際に,クローズ価格が7つのEMAを次々に突破する.これは,トレンド転換後の強さの入りを保証する.
さらに,戦略は,価格の創新高と閉盘価格の突破の歴史的高の2つの条件を組み合わせて,ロングポジションシグナルを確認し,創新低と閉盘価格の突破の歴史的低のショートポジションシグナルを確認するために使用し,偽の突破を回避します.
平仓条件は,close価格が,急速EMAからゆっくりEMAに次々に突破することを要求し,トレンドの逆転を示します.または,最新のK線の最低価格または最高価格が4つのEMAを突破し,取引がすぐに平仓すべきことを示します.
解決策は
この戦略の全体的な考え方は明確で,7つの異なる速度EMAでトレンドを判断し,二重平仓条件を設けて,トレンドの逆転に対してより敏感な判断ができます。しかし,戦略自体は止損を設定していません.非常に大きな損失のリスクがあり,また,早すぎる退場問題を引き起こす可能性もあります。将来は,止損,パラメータ最適化,指標フィルタリングなどの複数の次元から戦略の改善が求められ,安定した信頼性の高い定量化取引システムになります。
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="Crypto MAX Trend", shorttitle="Crypto MAX", overlay = true )
Length = input(3, minval=1)
Length2 = input(15, minval=1)
Length3 = input(19, minval=1)
//Length33 = input(25, minval=1)
Length4 = input(50, minval=1)
Length44 = input(100, minval=1)
Length5 = input(150, minval=1)
Length6 = input(171, minval=1)
Length66 = input(172, minval=1)
xPrice = input(close)
xEMA1 = ema(xPrice, Length)
xEMA2 = ema(xPrice, Length2)
xEMA3 = ema(xPrice, Length3)
//xEMA33 = ema(xPrice, Length33)
xEMA4 = ema(xPrice, Length4)
xEMA44 = ema(xPrice, Length44)
xEMA5 = ema(xPrice, Length5)
xEMA6 = ema(xPrice, Length6)
xEMA66 = ema(xPrice, Length66)
// plot(xEMA1, color=color.white)
// plot(xEMA2, color=color.red)
// plot(xEMA3, color=color.green)
// plot(xEMA4, color=color.purple)
// plot(xEMA44, color=color.gray)
// plot(xEMA5, color=color.maroon)
// plot(xEMA6, color=color.blue)
// plot(xEMA66, color=color.orange)
fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2000, title = "From Year", minval = 1970)
//monday and session
// To Date Inputs
toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2020, title = "To Year", minval = 1970)
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true
long = close > xEMA1 and xEMA1 > xEMA2 and xEMA2 > xEMA3 and xEMA3 > xEMA4 and xEMA4 > xEMA44 and xEMA44 > xEMA5 and xEMA5> xEMA6 and xEMA6> xEMA66 and close > high[1] and high[1] > high[2] and close > high[3] and close > high[4] and close > high[5] and high[5] > high[6] and time_cond
short = close < xEMA1 and xEMA1 < xEMA2 and xEMA2 < xEMA3 and xEMA3 < xEMA4 and xEMA4 < xEMA44 and xEMA44 < xEMA5 and xEMA5< xEMA6 and xEMA6< xEMA66 and close < low[1] and low[1] < low[2] and close < low[3] and close < low[4] and close< low[5] and low[5] < low[6] and time_cond
notlong = close < xEMA1
strategy.entry("long",1,when=long)
strategy.entry("short",0,when=short)
exitlong1 = xEMA1 < xEMA2 and xEMA2 < xEMA3 and xEMA3 < xEMA4
exitlong2 = crossunder(low,xEMA1) and crossunder(low,xEMA2) and crossunder(low,xEMA3) and crossunder(low,xEMA4)
exitshort1 = xEMA1 > xEMA2 and xEMA2 > xEMA3 and xEMA3 > xEMA4
exitshort2 = crossover(high,xEMA1) and crossover(high,xEMA2) and crossover(high,xEMA3) and crossover(high,xEMA4)
strategy.close("long", when = exitlong1 or exitlong2)
strategy.close("short", when= exitshort1 or exitshort2)