
この戦略は,主に移動平均HMAとEMAが形成される均線収束を利用して,買い時を判断する.HMA上でのEMAの穿戴は,収束の終了とみなされ,新しい上昇傾向が形成され,したがってHMA上でのEMAの穿戴と同時に買いする.
この戦略は同時にRSI指標と組み合わせて,超買超売りを検出する. RSIが70を下回ると買入が許され,RSIが80を超えると部分停止が考慮される.
この戦略は200周期のEMAとHMAを使って均線システムを構築する.その中で,HMA指標はEMA改良設計によるより敏感な移動平均指標である.HMA上でEMAを穿戴すると,収束期が終了し,株価が上昇し始めることを示している.この時点で,RSI指標がオーバーバイがないことを示している場合は,買入シグナルを生成する.
ポジションが確立された場合,株価が下がれば,HMAは再びEMAを下落させ,新しい整理が開始されたことを示す.その一方で,RSIが80を超えると,部分的に停止し,20%,損失を防ぐ.
この戦略の取引論理は比較的単純で,主にHMAとEMAの多空交差で,RSIの高低の判断と組み合わせて,より安定した取引戦略を形成する.
この戦略の最大の利点は,EMAとHMAの整合取引形態を利用して,大部分のFalse Breakをフィルターして,利益率を上げることができるということです.同時に,RSI指標の補助も,リスクを効果的に制御することができます.この2つの組み合わせは,整合の揺れ市場にこの戦略を非常に適しています.
さらに,この戦略は3つの指標のみを使用し,論理的に単純であり,パラメータの最適化と反測を容易にし,戦略の検証と改善に役立ちます.
この戦略には一定の利点があるが,注意すべきリスクもある.例えば,ポジションの保有期間は比較的長くなり,十分な資金のサポートが必要である.横断整理の時期を遭遇した場合,すぐに脱出を止めることができず,損失の拡大が起こりやすい状況である.
さらに,この戦略は主に均線指標に依存し,価格が異常な突破が発生した場合,ストップ・メカニズムが十分に機能しない可能性があり,より大きなリスクをもたらす.さらに,パラメータ設定は戦略のパフォーマンスに影響し,最適なパラメータを見つけるために大量にテストする必要があります.
この戦略は,上記のリスクを考慮して,以下のような点で最適化できます.
波動率指標と組み合わせて,市場の変動に応じてポジションを動的に調整する.
傾向指標の判断を高め,不必要な逆転取引を避ける.
移動平均のパラメータを最適化して,現在の市場特性に近いものにします.
時間の無駄を最大限なくして,単一損失の過剰な問題を回避します.
この戦略は,全体的に比較して古典的なシンプルな整合振動戦略である.これは,主に株式指数と熱い個人株の短線および中期取引に適用され,比較して安定したアルファ値を得ることができる.パラメータの最適化と風力管理措置の強化とともに,この戦略のパフォーマンスは,大きく向上する余地がある.
/*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"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mohanee
//@version=4
strategy(title="EMA_HMA_RSI_Strategy", overlay=true, pyramiding=2, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed,
//longCondition = crossover(sma(close, 14), sma(close, 28))
//if (longCondition)
//strategy.entry("My Long Entry Id", strategy.long)
//shortCondition = crossunder(sma(close, 14), sma(close, 28))
//if (shortCondition)
// strategy.entry("My Short Entry Id", strategy.short)
//HMA
HMA(src1, length1) => wma(2 * wma(src1, length1/2) - wma(src1, length1), round(sqrt(length1)))
var stopLossVal=0.00
//variables BEGIN
length=input(200,title="EMA and HMA Length") //square root of 13
rsiLength=input(13, title="RSI Length")
takePartialProfits = input(true, title="Take Partial Profits (if this selected, RSI 13 higher reading over 80 is considered for partial closing ) ")
stopLoss = input(title="Stop Loss%", defval=8, minval=1)
//variables END
//RSI
rsi13=rsi(close,rsiLength)
ema200=ema(close,length)
hma200=HMA(close,length)
//exitOnAroonOscCrossingDown = input(true, title="Exit when Aroon Osc cross down zero ")
// Drawings
//Aroon oscillator
arronUpper = 100 * (highestbars(high, length+1) + length)/length
aroonLower = 100 * (lowestbars(low, length+1) + length)/length
aroonOsc = arronUpper - aroonLower
aroonMidpoint = 0
//oscPlot = plot(aroonOsc, color=color.green)
//midLine= plot(aroonMidpoint, color=color.green)
//topLine = plot(90,style=plot.style_circles, color=color.green)
//bottomLine = plot(-90,style=plot.style_circles, color=color.red)
//fill(oscPlot, midLine, color=aroonOsc>0?color.green:color.red, transp=50)
//fill(topLine,bottomLine, color=color.blue)
//fill(topLine,oscPlot, color=aroonOsc>90?color.purple:na, transp=25)
// RSI
//plot(rsi13, title="RSI", linewidth=2, color=color.purple)
//hline(50, title="Middle Line", linestyle=hline.style_dotted)
//obLevel = hline(80, title="Overbought", linestyle=hline.style_dotted)
//osLevel = hline(30, title="Oversold", linestyle=hline.style_dotted)
//fill(obLevel, osLevel, title="Background", color=rsi13 >=30 ? color.green:color.purple, transp=65) // longTermRSI >=50
hullColor = hma200 > hma200[2] ? #00ff00 : #ff0000
plot(hma200, title="HULL 200", color=hullColor, transp=25)
plot(ema200, title="EMA 200", color=color.orange)
//Entry--
strategy.initial_capital = 50000
strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, long=true, when=strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70 ) // // aroonOsc<0
//Add
if(strategy.position_size>=1 and close < strategy.position_avg_price and ( crossover(rsi13,30) or crossover(rsi13,40) ) ) // hma200 < ema200 and hma200 > hma200[2] and hma200[2] < hma200[3] ) //and crossover(rsi13,30) aroonOsc<0 //and hma200 > hma200[2] and hma200[2] <= hma200[3] //crossover(rsi13,30)
qty1=(strategy.initial_capital * 0.10)/close
//stopLossVal:= abs(strategy.position_size)>1 ? ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00
strategy.entry(id="Long Entry", comment="Add", qty=qty1, long=true ) //crossover(close,ema34) //and close>ema34 //crossover(rsi5Val,rsiBuyLine) -- SL="+tostring(stopLossVal, "####.##")
//stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-0.5) : 0.00
stopLossVal:= abs(strategy.position_size)>1 ? ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00
//stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-stopLoss*0.01) : 0.00
barcolor(color=strategy.position_size>=1? rsi13>80 ? color.purple: color.blue:na)
//close partial
if(takePartialProfits==true)
strategy.close(id="Long Entry", comment="Partial X points="+tostring(close - strategy.position_avg_price, "####.##"), qty_percent=20 , when=abs(strategy.position_size)>=1 and crossunder(rsi13, 80) and close > strategy.position_avg_price ) //close<ema55 and rsi5Val<20 //ema34<ema55
//close All
//if(exitOnAroonOscCrossingDown)
// strategy.close(id="Long Entry", comment="Exit All points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and crossunder(aroonOsc, 0) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89
//close All on stop loss
strategy.close(id="Long Entry", comment="Stoploss X points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and close < stopLossVal ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89
strategy.close(id="Long Entry", comment="hmaXema X points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and close > strategy.position_avg_price and crossunder(hma200,ema200) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89