국경을 넘나드는 단기적 돌파구 반전 5EMA 전략

저자:차오장, 날짜: 2024-01-30 15:30:19
태그:

img

이 문서에서는 5EMA 지표에 기반한 단기 역전 거래 전략을 소개합니다. 이 전략은 주로 5EMA 지표를 사용하여 가격 트렌드를 판단하고 가격이 EMA를 통과 할 때 거래를 역전합니다.

전략 개요

이 전략은 고주파 거래에 주로 사용되는 단기 정량 전략입니다. 이 전략은 동시에 상승 및 하락 신호를 판단하고 양 방향으로 거래 할 수 있습니다. 거래 신호는 가격이 5EMA 지표를 통과 할 때 생성되며 돌파 방향에 따라 긴 또는 짧은 포지션을 입력합니다.

이 전략의 장점은 단기 가격 반전 기회를 포착하고 빠르게 시장에 진출하는 것입니다. 주요 위험은 가짜 브레이크로 인한 손실에서 발생합니다. 매개 변수를 최적화함으로써 위험을 줄일 수 있습니다.

전략 원칙

  1. 5주기 EMA 지표를 사용하여 단기 가격 추세를 결정합니다.

  2. 가격이 EMA 지표를 통과하는지 판단합니다.

  3. 가격이 EMA를 위에서 아래로 돌파하면 판매 신호가 생성됩니다.

  4. 가격이 EMA를 밑에서 위로 돌파하면 구매 신호가 생성됩니다.

  5. 단일 손실을 제한하기 위해 Stop Loss 및 Take Profit를 설정합니다.

EMA 지표는 단기 트렌드를 효과적으로 결정할 수 있기 때문에 가격이 상당한 반전을 보이는 경우 거래 기회를 신속하게 파악 할 수 있습니다. 5EMA 매개 변수는 상대적으로 유연하며 시장에 신속하게 반응하여 고주파 거래에 적합합니다.

전략 의 장점

  • 빠른 반응, 단기 거래 기회의 고 빈도 포착에 적합
  • 양방향 거래는 동시에 길고 짧을 수 있습니다.
  • 적당한 스톱 로스 및 수익 취득 설정, 단일 손실 제한
  • 간단한 매개 변수 설정, 전략을 최적화하기 쉽습니다

전략 의 위험 과 해결책

  • 허위 파기 위험으로 인한 불필요한 손실
    • 지표의 안정성을 보장하기 위해 EMA 사이클 매개 변수를 최적화
  • 과도한 거래 빈도는 쉽게 최고치를 추구하고 최저치를 죽일 수 있습니다.
    • 하루 최대 거래 수 제한

전략의 최적화 방향

  • 가장 좋은 사이클 포트폴리오를 찾기 위해 EMA 지표 매개 변수를 최적화
  • 가짜 브레이크의 확률을 줄이기 위해 필터를 높여
  • 하루 최대 거래 수 제한
  • 추세 방향을 결정하기 위해 다른 지표를 결합

요약

일반적으로 이것은 매우 실용적인 단기 브레이크아웃 전략입니다. 가격 반전을 결정하기 위해 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"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © samscripter

//@version=5
strategy("5 ema strategy",overlay = true,process_orders_on_close = true)

// Choose trade direction

t_dir = input.string("Both", title="Trade Direction",options=["Long", "Short", "Both"],group = 'Trade Direction Set')

long_side  = t_dir == "Long" or t_dir == "Both"
short_side = t_dir == "Short" or t_dir == "Both"

// number of trade
mx_num =input.int(4,title = 'number Of trade',group = 'Maximum Number Of Trade')
var hi =0.0
var lo =0.0

var group_ma1="Ema Set"

//Ema 1
on_ma=input.bool(true,"Enable EMa 1 Plot On/Off"  ,group =group_ma1)
ma_len= input.int(5, minval=1, title="Ema Length",group =group_ma1)
ma_src = input.source(close, title="Ema Source"   ,group = group_ma1)
ma_out = ta.ema(ma_src, ma_len)

// buy and sell ema condition  
plot(on_ma?ma_out:na, color=color.white, title="MA")


if close>ma_out and open>ma_out and low>ma_out and high>ma_out
    lo:=low

if close<ma_out and open<ma_out and low<ma_out and high<ma_out
    hi:=high
    
// condition when price is crossunder lo take sell and when price crossoing hi take buy 
var buyp_sl =float(na)
var sellp_sl =float(na)

//count number trade since day stra
var count_buysell=0

if  close>hi[1] 
    if strategy.position_size==0 and count_buysell<mx_num and long_side
        strategy.entry('El',strategy.long,comment = 'Long')
        count_buysell:=count_buysell+1
        buyp_sl:=math.min(low,low[1])
    hi:=na
if  close<lo[1]
    if strategy.position_size==0 and count_buysell<mx_num and short_side
        strategy.entry('Es',strategy.short,comment = 'short')
        count_buysell:=count_buysell+1
        sellp_sl:=math.max(high,high[1])
    lo:=na

//take profit multiply 

tpnew = input.float(title="take profit", step=0.1, defval=1.5, group='Tp/SL')


//stop loss previous candle high and previous candle low
buy_sl = ta.valuewhen(strategy.position_size != 0 and strategy.position_size[1] == 0,buyp_sl , 0)
sell_sl= ta.valuewhen(strategy.position_size != 0 and strategy.position_size[1] == 0,sellp_sl, 0)

//take profit
takeProfit_buy = strategy.position_avg_price - ((buy_sl - strategy.position_avg_price) *tpnew)
takeProfit_sell = strategy.position_avg_price - ((sell_sl - strategy.position_avg_price) *tpnew)


//  Submit exit orders
if strategy.position_size > 0
    strategy.exit(id='XL', stop=buy_sl,limit=takeProfit_buy,comment_loss = 'Long Sl',comment_profit = 'Long Tp')

if strategy.position_size < 0
    strategy.exit(id='XS', stop=sell_sl,limit=takeProfit_sell,comment_loss = 'Short Sl',comment_profit = 'Short Tp')
    
//plot data
plot(series=strategy.position_size < 0 ?sell_sl : na, style=plot.style_circles, color=color.red, linewidth=2, title="St red Stop")
plot(series=strategy.position_size > 0 ?buy_sl  : na, style=plot.style_circles, color=color.green, linewidth=2, title="St green Stop")


// plot take profit
plot(series=strategy.position_size < 0 ? takeProfit_sell : na, style=plot.style_circles, color=color.orange, linewidth=2, title="take profit sell")
plot(series=strategy.position_size > 0 ? takeProfit_buy: na, style=plot.style_circles, color=color.blue, linewidth=2, title="take profit buy")

if ta.change(time('D'))
    count_buysell:=0

더 많은