指数関数移動平均ブーンズ戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-08 16:47:39
タグ:

img

戦略の概要

指数的な移動平均 (EMA) ボーンズ戦略は,移動平均線の価格突破を追跡する戦略である.それは,キャンドルが移動平均線の下から反転するかどうかをチェックする.そうであれば,それは上昇信号である.キャンドルが移動平均線上から反転する場合は,それは下落信号である.

戦略名

指数関数移動平均ブーンズ戦略

戦略の論理

この戦略は指数的な移動平均線 (EMA) に基づいています. EMA線をリアルタイムで計算します. その後,価格が EMA線から反転しているかチェックします.

  • 価格が最初にEMA線を突破し,その後EMA線上に反転すると,それは上昇信号です.
  • 価格が最初にEMA線を突破し,その後EMA線を下回ると,それは下落信号です.

このようなリバウンドは 戦略への入口信号です

利点分析

トレンドに合わせて取引して 罠にはまらない

EMAの反転戦略は 価格逆転が確認された後にのみ開始されるので 傾向に逆らって取引をしたり 罠にかかったりすることは避けられます

低利回り 良質な履歴

指数関数移動平均を用いて,この戦略は価格データを効率的に平滑させ,市場のノイズをフィルターで処理し,少量の引き下げと良い歴史的な収益をもたらします.

簡単に理解し,柔軟なパラメータ調整

EMAのブーンズ戦略は単に移動平均値に依存しており,初心者が理解するのは簡単です.一方,EMA期間は異なる製品に適応するために柔軟に調整できます.

リスク分析

誤った信号を受けやすい

EMAラインの周りに密度の高い偽ブレイクがしばしば発生し,誤った信号を引き起こす可能性があります.EMAパラメータを調整し,ノイズをフィルターする必要があります.

トレンドに合わせて取引する ターニングポイントを予測できない

この戦略は本質的にトレンドに沿って取引する.価格のターニングポイントを予測できず,トレンドに従うことができる.これは周期的調整中に最高のエントリー機会を見逃す可能性があります.

ストップ・ロスは外す傾向がある.

移動平均線に近いストップ・ロスは,時にはヒットし,損失を拡大させる.これはより柔軟なストップ・ロスの方法を必要とします.

最適化

信号フィルタリングのための他の指標を組み込む

RSIやMACDのような指標が追加され 価格逆転を確認し 誤った信号をフィルタリングできます

ストップ・ロスの方法を最適化

ストップ・ロスの方法としては,タイム・ストップやボラティリティ・ストップなどより柔軟な方法が用いられる.

パラメータ最適化

最適なパラメータ組み合わせを見つけるために EMA 期間パラメータを最適化します. EMA パラメータは,市場サイクルを追跡するために動的化することもできます.

結論

EMAブーンズ戦略は,トレンドフォロー戦略としてシンプルで実用的なものです. 引き下げは小さく,理解が簡単です. 同時に,誤った信号や停止されるリスクもあります. より良い指標組み合わせ,ストップ損失方法,パラメータ選択を使用して戦略を最適化することで,安定した信頼性の高い定量戦略になります.


/*backtest
start: 2022-12-01 00:00:00
end: 2023-12-07 00:00:00
period: 1d
basePeriod: 1h
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/
// © tweakerID

// Simple strategy that checks for price bounces over an Exponential Moving Average. If the CLOSE of the candle bounces
// back from having it's LOW below the EMA, then it's a Bull Bounce. If the CLOSE of the candle bounces down from having it's
// high above the EMA, then it's a Bear Bounce. This logic can be reverted.

//@version=4
strategy("EMA Bounce", overlay=true, 
     default_qty_type=strategy.percent_of_equity, 
     default_qty_value=100, 
     initial_capital=10000, 
     commission_value=0.04, 
     calc_on_every_tick=false, 
     slippage=0)

direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))

/////////////////////// STRATEGY INPUTS ////////////////////////////////////////
title1=input(true, "-----------------Strategy Inputs-------------------")  

i_EMA=input(20, title="EMA Length")

/////////////////////// BACKTESTER /////////////////////////////////////////////
title2=input(true, "-----------------General Inputs-------------------")  

// Backtester General Inputs
i_SL=input(true, title="Use Swing Stop Loss and Take Profit")
i_SPL=input(defval=10, title="Swing Point Loopback")
i_PercIncrement=input(defval=.2, step=.1, title="Swing Point SL Perc Increment")*0.01
i_TPRRR = input(1.2, step=.1, title="Take Profit Risk Reward Ratio")

// Bought and Sold Boolean Signal
bought = strategy.position_size > strategy.position_size[1] 
 or strategy.position_size < strategy.position_size[1]

// Price Action Stop and Take Profit
LL=(lowest(i_SPL))*(1-i_PercIncrement)
HH=(highest(i_SPL))*(1+i_PercIncrement)
LL_price = valuewhen(bought, LL, 0)
HH_price = valuewhen(bought, HH, 0)
entry_LL_price = strategy.position_size > 0 ? LL_price : na 
entry_HH_price = strategy.position_size < 0 ? HH_price : na 
tp=strategy.position_avg_price + (strategy.position_avg_price - entry_LL_price)*i_TPRRR
stp=strategy.position_avg_price - (entry_HH_price - strategy.position_avg_price)*i_TPRRR


/////////////////////// STRATEGY LOGIC /////////////////////////////////////////

EMA=ema(close, i_EMA)
LowAboveEMA=low > EMA
LowBelowEMA=low < EMA
HighAboveEMA=high > EMA
HighBelowEMA=high < EMA
BullBounce=LowAboveEMA[1] and LowBelowEMA and close > EMA //and close > open
BearBounce=HighBelowEMA[1] and HighAboveEMA and close < EMA //and close < open
plot(EMA)

BUY=BullBounce
SELL=BearBounce

//Inputs
DPR=input(false, "Allow Direct Position Reverse")
reverse=input(false, "Reverse Trades")

// Entries
if reverse
    if not DPR
        strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)
        strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)
    else     
        strategy.entry("long", strategy.long, when=SELL)
        strategy.entry("short", strategy.short, when=BUY)
else
    if not DPR 
        strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)
        strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)
    else
        strategy.entry("long", strategy.long, when=BUY)
        strategy.entry("short", strategy.short, when=SELL)


SL=entry_LL_price
SSL=entry_HH_price
TP=tp
STP=stp

strategy.exit("TP & SL", "long", limit=TP, stop=SL, when=i_SL)
strategy.exit("TP & SL", "short", limit=STP, stop=SSL, when=i_SL)

/////////////////////// PLOTS //////////////////////////////////////////////////

plot(strategy.position_size > 0 ? SL : na , title='SL', style=plot.style_cross, color=color.red)
plot(strategy.position_size < 0 ? SSL : na , title='SSL', style=plot.style_cross, color=color.red)
plot(strategy.position_size > 0 ? TP : na, title='TP', style=plot.style_cross, color=color.green)
plot(strategy.position_size < 0 ? STP : na, title='STP', style=plot.style_cross, color=color.green)
// Draw price action setup arrows
plotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar, 
 color=color.green, title="Bullish Setup", transp=80, size=size.auto)
plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar, 
 color=color.red, title="Bearish Setup", transp=80, size=size.auto)


もっと