モメントブレイク戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-13 17:08:53
タグ:

img

概要

この戦略は,移動平均値,ラガーRSI指標,ADX指標を組み合わせてブレイクアウト取引を実施する.高速移動平均値がスロームービング平均値を超えるとロングになり,ラガーRSI値は80を超えると,ADX値は20を超えると,高速移動平均値がスロームービング平均値を超えるとショートになり,ラガーRSI値は20未満,ADX値は20を超えるとロングになる.この戦略は市場の勢力の特徴を把握し,トレンド開発の開始時に市場に参入する.

原則

この戦略は,主に次の指標を用いて,傾向と導入時期を決定しています.

  1. 移動平均の組み合わせ: 16 日間 EMA, 48 日間 EMA, 200 日間 SMA.短期平均が長期平均を上回る場合,上昇傾向が決定され,低くなると下落傾向が決定される.

  2. ラグエール RSI インジケーターは,過剰購入と過剰販売のゾーンを決定します. RSI 80 以上は長い信号で,20未満は短い信号です.

  3. ADX インディケーターはトレンドの状態を決定します. ADXは20を超えるとトレンドを示し,ブレイクアウト取引に適しています.

エントリーシグナルは移動平均の組み合わせの方向によって決定され,エントリータイミングはラガーRSIによって決定され,トレンドではない市場はADXによってフィルタリングされます. エクジットシグナルは移動平均が戻ったときに生成されます. 戦略判断の全体的な枠組みはかなり合理的で,異なる指標が一緒に働き,ロング/ショートエントリーと出口を決定します.

優位性

この戦略の利点は以下の通りです.

  1. トレンドの勢いを捕捉する: 戦略はトレンドの発展の始まりに市場に入り,トレンドから指数関数的な利益を得ます.

  2. 限られた損失: 適切に設定されたストップ損失は,個々の取引からの損失を制限します. 損する取引でさえ,利益を得るチャンスがあります.

  3. 精密な組み合わせ指標:移動平均値,ラグエールRSI,ADXは,市場方向とエントリータイミングを比較的正確に決定することができます.

  4. シンプルな実施: 戦略は3つの指標のみを使用し,理解し実行するのが簡単です.

リスク

この戦略にはいくつかのリスクもあります:

  1. トレンド逆転リスク: トレンドをフォローする戦略として,トレンド逆転が間に合わない場合,大きな損失が発生する可能性があります.

  2. 引き上げリスク: 変動市場では,ストップがヒットし,口座引き上げにつながる可能性があります.

  3. パラメータ最適化リスク: 失敗を避けるために,異なる市場に対して指標のパラメータを調整する必要があります.

対策:

  1. ストップ損失を厳格に制限し,単一の取引損失を制限する.

  2. 指標パラメータとブレイクドローシュルを最適化する

  3. 引き上げを管理するために先物取引などを使用する.

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

戦略を最適化する方法には以下の通りがあります.

  1. パラメータ最適化:移動平均期間の組み合わせ,ラガーRSIパラメータ,ADXパラメータをテストして最適な設定を見つけます.

  2. ブレイクアウト最適化: 取引の頻度と収益性をバランスするために,異なる移動平均ブレイクアウトの値をテストする.

  3. エントリー最適化: より正確なエントリータイミングのために,ラガーレRSIと組み合わせた他の指標をテストします.

  4. エグジット最適化:移動平均値と組み合わせて他のエグジット信号を研究する.

  5. 利回りとストップ・ロスの最適化: 収益を最適化するために異なる戦略をテストする.

概要

この戦略は,移動平均値,ラグエールRSI,ADXの組み合わせを使用してエントリーとアウトートを決定することで,トレンドの動きを効果的に捉える.トレンドの展開に早期に入ってトレンド走行を注意深く追跡することで,指数関数的な利益を得ることができ,ストップ損失は損失を制限するのに役立ちます.この戦略は,市場判断を快適に行う投資家だけでなく,パラメータ最適化後に自動取引を行う人々にも適しています.全体的に,戦略は強力な実用性を持っています.


/*backtest
start: 2023-12-05 00:00:00
end: 2023-12-12 00:00:00
period: 1m
basePeriod: 1m
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/
// © PtGambler

//@version=5
strategy("3MA + Laguerre RSI + ADX [Pt]", shorttitle = "3MA+LaRSI+ADX[Pt]", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills = false, max_bars_back = 500)


// ********************************** Trade Period / Strategy Setting **************************************
startY = input(title='Start Year', defval=2011, group = "Backtesting window")
startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Backtesting window")
startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Backtesting window")
finishY = input(title='Finish Year', defval=2050, group = "Backtesting window")
finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Backtesting window")
finishD = input.int(title='Finish Day', defval=31, minval=1, maxval=31, group = "Backtesting window")
timestart = timestamp(startY, startM, startD, 00, 00)
timefinish = timestamp(finishY, finishM, finishD, 23, 59)
use_entry_sess = input.bool(false, 'Use Entry Session Window', group = "Trading Session")
t1_session = input("0930-1555:23456", "Entry Session", group="Trading Session", tooltip = "Entry Signal only generated within this period.") 
t1 = time(timeframe.period, t1_session)
window = true

margin_req = input.float(1, title="Margin Requirement / Leverage", step=0.1, group = "Trading Options")
qty_per_trade = input.float(100, title = "% of initial capital per trade", group = "Trading Options")
reinvest = input.bool(defval=false,title="Reinvest profit", group = "Trading Options")
reinvest_percent = input.float(defval=100, title = "Reinvest percentage", group="Trading Options")

close_eod = input.bool(false, "All trades will close at the close of trading window", group = "Trading Options")
close_b4_open = input.bool(false, "Position must hit either SL/PT before entering new trade", group = "Trading Options")

profit = strategy.netprofit 
strategy.initial_capital = 50000
float trade_amount = math.floor(strategy.initial_capital*margin_req / close) 

if strategy.netprofit > 0 and reinvest
    trade_amount := math.floor((strategy.initial_capital* (qty_per_trade/100)+(profit*reinvest_percent*0.01))*margin_req/ close) 
else
    trade_amount := math.floor(strategy.initial_capital* (qty_per_trade/100)*margin_req / close)  

// ******************************************************************************************

group_ma = "Moving Average Ribbon"
group_larsi = "Laguerre RSI"
group_adx = "ADX"
group_SL = "Stop Loss / Profit Target"

// ----------------------------------------- MA Ribbon -------------------------------------

ema1_len = input.int(16, "Fast EMA Length", group = group_ma)
ema2_len = input.int(48, "Slow EMA Length ", group = group_ma)
sma1_len = input.int(200, "Slow SMA Length", group = group_ma)

ema1 = ta.ema(close, ema1_len)
ema2 = ta.ema(close, ema2_len)
sma1 = ta.sma(close, sma1_len)

plot(ema1, "EMA 1", color.white, linewidth = 2)
plot(ema2, "EMA 2", color.yellow, linewidth = 2)
plot(sma1, "SMA 1", color.purple, linewidth = 2)

ma_bull = ema1 > ema2 and ema2 > sma1   
ma_bear = ema1 < ema2 and ema2 < sma1

// ------------------------------------------ Laguerre RSI ---------------------------------------

alpha = input.float(0.2, title='Alpha', minval=0, maxval=1, step=0.1, group = group_larsi)

gamma = 1 - alpha
L0 = 0.0
L0 := (1 - gamma) * close + gamma * nz(L0[1])
L1 = 0.0
L1 := -gamma * L0 + nz(L0[1]) + gamma * nz(L1[1])

L2 = 0.0
L2 := -gamma * L1 + nz(L1[1]) + gamma * nz(L2[1])

L3 = 0.0
L3 := -gamma * L2 + nz(L2[1]) + gamma * nz(L3[1])

cu = (L0 > L1 ? L0 - L1 : 0) + (L1 > L2 ? L1 - L2 : 0) + (L2 > L3 ? L2 - L3 : 0)

cd = (L0 < L1 ? L1 - L0 : 0) + (L1 < L2 ? L2 - L1 : 0) + (L2 < L3 ? L3 - L2 : 0)

temp = cu + cd == 0 ? -1 : cu + cd
LaRSI = temp == -1 ? 0 : cu / temp
LaRSI := LaRSI * 100

bull_LaRSI = LaRSI > 80
bear_LaRSI = LaRSI < 20

// --------------------------------------- ADX  ------------------------

adxlen = input(14, title="ADX Smoothing", group = group_adx)
dilen = input(14, title="DI Length", group = group_adx)
dirmov(len) =>
	up = ta.change(high)
	down = -ta.change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
	minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = ta.rma(ta.tr, len)
	plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
	minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
	[plus, minus]
adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)

active_adx = sig > 20 //and sig > sig[1]

// ******************************* Profit Target / Stop Loss *********************************************

use_SLPT = input.bool(false, 'Use Fixed SL / PT', group = group_SL)
SL = input.float(50, 'Stop loss in ticks', step = 1, group = group_SL) * syminfo.mintick
PT = input.float(100, "Profit target in ticks", step = 1, group = group_SL) * syminfo.mintick

var L_PT = 0.0
var S_PT = 0.0
var L_SL = 0.0
var S_SL = 0.0

if strategy.position_size > 0
    L_SL := L_SL[1]
    L_PT := L_PT[1]
else if strategy.position_size < 0
    S_SL := S_SL[1]
    S_PT := S_PT[1]
else
    L_SL := close - SL
    L_PT := close + PT
    S_SL := close + SL
    S_PT := close - PT

entry_line = plot(use_SLPT and strategy.position_size != 0 ? strategy.opentrades.entry_price(0) : na, "Entry Price", color.white, linewidth = 1, style = plot.style_linebr)

L_PT_line = plot(use_SLPT and strategy.position_size > 0 ? L_PT : na, "L PT", color.green, linewidth = 2, style = plot.style_linebr)
S_PT_line = plot(use_SLPT and strategy.position_size < 0 ? S_PT : na, "S PT", color.green, linewidth = 2, style = plot.style_linebr)

L_SL_line = plot(use_SLPT and strategy.position_size > 0 ? L_SL : na, "L SL", color.red, linewidth = 2, style = plot.style_linebr)
S_SL_line = plot(use_SLPT and strategy.position_size < 0 ? S_SL : na, "S SL", color.red, linewidth = 2, style = plot.style_linebr)

fill(L_PT_line, entry_line, color = color.new(color.green,90))
fill(S_PT_line, entry_line, color = color.new(color.green,90))
fill(L_SL_line, entry_line, color = color.new(color.red,90))
fill(S_SL_line, entry_line, color = color.new(color.red,90))


// ---------------------------------- Strategy setup ------------------------------------------------------

L_entry1 = ma_bull and bull_LaRSI and active_adx
S_entry1 = ma_bear and bear_LaRSI and active_adx

L_exit1 = ta.crossunder(ema1, ema2)
S_exit1 = ta.crossover(ema1, ema2)

// Trigger zones
bgcolor(ma_bull ? color.new(color.green ,90) : na)
bgcolor(ma_bear ? color.new(color.red,90) : na)

if L_entry1 and (use_entry_sess ? window : true) and (close_b4_open ? strategy.position_size == 0 : true)
    strategy.entry("Long", strategy.long, trade_amount)

if S_entry1 and (use_entry_sess ? window : true) and (close_b4_open ? strategy.position_size == 0 : true)
    strategy.entry("Short", strategy.short, trade_amount)

if use_SLPT
    strategy.exit("Exit Long", "Long", limit = L_PT, stop = L_SL, comment_profit = "Exit Long, PT hit", comment_loss = "Exit Long, SL hit")
    strategy.exit("Exit Short", "Short", limit = S_PT, stop = S_SL, comment_profit = "Exit Short, PT hit", comment_loss = "Exit Short, SL hit")
else
    if L_exit1
        strategy.close("Long", comment = "Exit Long")

    if S_exit1
        strategy.close("Short", comment = "Exit Short")

if use_entry_sess and not window and close_eod
    strategy.close_all(comment = "EOD close")


もっと