전략에 따른 추진력 중심의 삼중 확정 추세

저자:차오장, 날짜: 2024-01-05 15:46:21
태그:

img

전반적인 설명

이 전략은 트리플 확인 메커니즘을 사용하여 거래 신호를 생성합니다. 즉, 모멘텀 지표는 강력한 시장 추세를 확인하고, 슈퍼 트렌드 지표는 트렌드 방향을 확인하고, EMA 지표는 트렌드 방향을 추가적으로 확인합니다. 세 가지 지표가 기준을 충족 할 때만 전략은 긴 또는 짧은 거래 신호를 생성하여 높은 확률의 거래 기회만 선택되도록합니다.

전략 원칙

  1. 모멘텀 지표 (Momentum RSI)

    • 모멘텀 RSI 지표는 시장 트렌드의 강도를 결정하는 데 사용됩니다. 60 이상의 판독은 강력한 시장 트렌드를 나타냅니다.

    • 거래 신호는 극심한 황소 시장이나 곰 시장에서만 생성됩니다.

  2. 슈퍼트렌드 분석

    • 슈퍼트렌드 라인은 시장 트렌드 방향을 나타냅니다. 가격은 슈퍼트렌드 라인을 넘을 때만 포지션이 고려됩니다.

    • 가격이 슈퍼트렌드 라인을 상향으로 돌파하면 상승 추세로 전환됩니다. 하향 추세를 돌파하면 하향 추세로 전환됩니다.

  3. EMA 전략

    • EMA와 그 보조 트렌드 라인은 트렌드 방향을 확인하는 데 사용됩니다. 구매 신호는 EMA가 보조 트렌드 라인을 통해 상향으로 깨는 경우에만 나타납니다. 짧은 신호는 그 반대입니다.

세 가지 지표가 동시에 포지션 개설 조건을 충족시킬 때만 진정한 거래 신호가 발산됩니다. 이것은 잘못된 신호의 수를 크게 줄이고 전략의 안정성을 향상시킵니다.

이점 분석

이 전략은 매우 높은 안정성과 수익성을 가지고 있습니다. 주요 장점은:

  1. 여러 확인 메커니즘은 소음을 효과적으로 필터하고 높은 확률 거래를 선택합니다.

  2. 슈퍼트렌드 라인은 위험을 효과적으로 통제하기 위해 동적인 트레일링 스톱 로스를 가지고 있습니다.

  3. 트렌드 강도에 대한 판단과 결합하면 강한 트렌드에 대한 거래만 추가 위험을 피할 수 있습니다.

  4. EMA 지표는 거래 방향이 정확하다는 것을 확인하기 위한 추가 검증을 제공합니다.

  5. 완전히 매개 변수화되어 있어 거래자가 필요에 따라 사용자 정의할 수 있습니다.

위험 분석

이 전략의 주요 위험은 잘못된 거래 신호를 유발하는 비정상적인 파업에서 발생합니다. 주요 위험과 해결책은 다음을 포함합니다.

  1. 거짓 탈출 위험: 탈출 확인 메커니즘을 강화합니다.

  2. 더 큰 오스실레이션 범위 위험: 적절한 스톱 손실 범위를 조정합니다.

  3. 트렌드 역전 위험: 보유 기간을 단축하고 적시에 손해를 멈추는 위험.

최적화 방향

이 전략을 최적화하는 주요 방향은 다음과 같습니다.

  1. 매개 변수 최적화: 더 많은 품종에 맞게 지표 매개 변수를 조정합니다.

  2. 더 많은 필터링: 신호 품질을 향상시키기 위해 더 많은 지표를 결합하십시오.

  3. 복합 전략: 다른 전략과 결합하여 보완적인 이점을 활용합니다.

  4. 동적 매개 변수 조정: 시장 조건에 따라 매개 변수를 자동 조정합니다.

  5. 기계 학습: 알고리즘을 사용하여 자동으로 최적의 매개 변수를 찾습니다.

요약

이 전략은 추진력, 슈퍼트렌드 및 EMA 지표를 효과적으로 결합하여 여러 확인과 함께 높은 확률의 거래 전략을 달성합니다. 엄격한 브레이크아웃 확인 메커니즘은 또한 매우 강력한 안정성을 제공합니다. 동시에 매우 높은 사용자 정의성과 최적화 잠재력을 가지고 있습니다. 요약하자면,이 전략은 트렌드 추적과 브레이크아웃 거래의 장점을 통합하여 매우 유망한 알고리즘 거래 전략입니다.


/*backtest
start: 2022-12-29 00:00:00
end: 2024-01-04 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('The Flash-Strategy (Momentum-RSI, EMA-crossover, ATR)', shorttitle='The Flash-Strategy (Momentum-RSI, EMA-crossover, ATR)', overlay=true,initial_capital = 1000)
//// author -  Baby_whale_to_moon

// MOM Rsi indicator 
group_mom_rsi = "Rsi Of Momentum "
len = input.int(10, minval=1, title="Length Mom-Rsi", group =group_mom_rsi ,tooltip = 'This ind calculate Rsi value of Momentum we use this ind to determine power of trend')
src2 = close
mom = src2 - src2[len]
rsi_mom = ta.rsi(mom, len)
mom_rsi_val = input.int(60, minval=1, title="Mom-Rsi Limit Val", group =group_mom_rsi, tooltip = "When our Mom-Rsi value more then this we open LONG or Short, with help of this indicator we we determine the status of the trend")

// Super Trend Ind
group_supertrend = "SuperTrend indicator"
atrPeriod = input(10, "ATR Length SuperTrend", group = group_supertrend)
factor = input.float(3.0, "Factor SuperTrend", step = 0.01, group = group_supertrend)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

// Ema Indicator
group_most = "Ema indicator"
src = input(close, 'Source Ema Ind',group = group_most)
AP2 = input.int(defval=12, title='Length Ema Ind', minval=1,group = group_most)
Trail1 = ta.ema(src, AP2) //Ema func
AF2 = input.float(defval=1, title='Percent Ema Ind', minval=0.1,group = group_most) / 100
SL2 = Trail1 * AF2  // Stoploss Ema
Trail2 = 0.0
iff_1 = Trail1 > nz(Trail2[1], 0) ? Trail1 - SL2 : Trail1 + SL2
iff_2 = Trail1 < nz(Trail2[1], 0) and Trail1[1] < nz(Trail2[1], 0) ? math.min(nz(Trail2[1], 0), Trail1 + SL2) : iff_1
Trail2 := Trail1 > nz(Trail2[1], 0) and Trail1[1] > nz(Trail2[1], 0) ? math.max(nz(Trail2[1], 0), Trail1 - SL2) : iff_2

//Bull = ta.barssince(Trail1 > Trail2 and close > Trail2 and low > Trail2) < ta.barssince(Trail2 > Trail1 and close < Trail2 and high < Trail2)

//TS1 = plot(Trail1, 'ExMov', style=plot.style_line, color=Trail1 > Trail2 ? color.rgb(33, 149, 243, 100) : color.rgb(255, 235, 59, 100), linewidth=2)
//TS2 = plot(Trail2, 'ema', style=plot.style_line, color=Trail1 > Trail2 ? color.rgb(76, 175, 79, 30) : color.rgb(255, 82, 82, 30), linewidth=2)
//fill(TS1, TS2, Bull  ? color.green : color.red, transp=90)


// Strategy Sett
group_strategy = "Settings of Strategy"
Start_Time = input(defval=timestamp('01 January 2000 13:30 +0000'), title='Start Time of BackTest', group =group_strategy)
End_Time = input(defval=timestamp('30 April 2030 19:30 +0000'), title='End Time of BackTest', group =group_strategy)
dollar = input.float(title='Dollar Cost Per Position* ', defval=50000, group =group_strategy)
trade_direction = input.string(title='Trade_direction', group =group_strategy, options=['LONG', 'SHORT', 'BOTH'], defval='BOTH')
v1 = input(true, title="Version 1 - Uses SL/TP Dynamically ", group =group_strategy ,tooltip = 'With this settings our stoploss price increase or decrease with price to get better PNL score')

v2 = input(false, title="Version 2 -  Uses SL/TP Statically", group =group_strategy)
v2stoploss_input = input.float(5, title='Static Stop.Loss % Val', minval=0.01, group =group_strategy)/100
v2takeprofit_input = input.float(10, title='Static Take.Prof % Val', minval=0.01, group =group_strategy)/100

v2stoploss_level_long = strategy.position_avg_price * (1 - v2stoploss_input)
v2takeprofit_level_long = strategy.position_avg_price * (1 + v2takeprofit_input)

v2stoploss_level_short = strategy.position_avg_price * (1 + v2stoploss_input)
v2takeprofit_level_short = strategy.position_avg_price * (1 - v2takeprofit_input)

group_line = "Line Settings"
show_sl_tp = input.bool(title='  Show StopLoss - TakeProf Lines',inline = "1", defval=true, group =group_line)
show_trend_line = input.bool(title='  Show Trend Line',inline = '3' ,defval=true, group =group_line)
stoploss_colour = input.color(title='StopLoss Line Colour',inline = '2' ,defval=color.rgb(255, 255, 0), group =group_line)
up_trend_line_colour = input.color(title='Up Trend line Colour',inline = '4' ,defval=color.rgb(0, 255, 0, 30), group =group_line)
down_trend_line_colour = input.color(title='Down Trend line Colour',inline = '4' ,defval=color.rgb(255, 0, 0, 30), group =group_line)

//plot(supertrend ,color = strategy.position_size > 0 and show_sl_tp ? color.rgb(255, 0, 0) :show_sl_tp ? color.rgb(0, 255, 0) : na , style = plot.style_steplinebr,linewidth = 2)
// plot(supertrend ,color = show_sl_tp and v1 ? stoploss_colour : na , style = plot.style_steplinebr,linewidth = 2)

// plot(v2stoploss_level_long ,color = strategy.position_size > 0 and show_sl_tp and v2 ? stoploss_colour : na , style = plot.style_steplinebr,linewidth = 2)
// plot(v2stoploss_level_short ,color = strategy.position_size < 0 and show_sl_tp and v2 ? stoploss_colour : na , style = plot.style_steplinebr,linewidth = 2)
// plot(v2takeprofit_level_long  ,color = strategy.position_size > 0 and show_sl_tp and v2 ? up_trend_line_colour : na , style = plot.style_steplinebr,linewidth = 2)
// plot(v2takeprofit_level_short ,color = strategy.position_size < 0 and show_sl_tp and v2 ? up_trend_line_colour : na , style = plot.style_steplinebr,linewidth = 2)


TS2 = plot(Trail2, 'Ema Strategy', style=plot.style_line, color=show_trend_line and Trail1 < Trail2 ? down_trend_line_colour : show_trend_line ? up_trend_line_colour  : na, linewidth=2)

// bgcolor(buy_signal ? color.rgb(0, 230, 119, 80) : na)
// bgcolor(sell_signal ? color.rgb(255, 82, 82, 80) : na)

Time_interval = true
buy_signal = Trail1 > Trail2 and direction < 0 and rsi_mom > mom_rsi_val and Time_interval
sell_signal =Trail1 < Trail2 and direction > 0 and rsi_mom > mom_rsi_val and Time_interval


// Strategy entries 
if strategy.opentrades == 0 and buy_signal and ( trade_direction == 'LONG' or trade_direction == 'BOTH')
    strategy.entry('Long_0', strategy.long, qty=dollar / close)

if strategy.opentrades == 0 and sell_signal and ( trade_direction == 'SHORT' or trade_direction == 'BOTH')
    strategy.entry('Short_0', strategy.short, qty=dollar / close)


if close < supertrend and v1
    strategy.exit('Long_Close',from_entry = "Long_0", stop=supertrend, qty_percent=100)
if  v2 and strategy.position_size > 0
    strategy.exit('Long_Close',from_entry = "Long_0", stop=v2stoploss_level_long,limit= v2takeprofit_level_long  , qty_percent=100)
    
if close > supertrend and v1
    strategy.exit('Short_Close',from_entry = "Short_0", stop=supertrend, qty_percent=100)
if  v2 and strategy.position_size < 0
    strategy.exit('Short_Close',from_entry = "Short_0", stop=v2stoploss_level_short,limit= v2takeprofit_level_short ,qty_percent=100)
    

더 많은