ATR 손절매 기반 Ichimoku Kinko Hyo 전략


생성 날짜: 2023-09-14 20:06:11 마지막으로 수정됨: 2023-09-14 20:06:11
복사: 2 클릭수: 874
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 글은 ATR을 스톱로, 평선을 입점으로 사용하는 양적 거래 전략에 대해 자세히 설명한다. 이 전략은 동시에 윌리엄스 지표와 결합하여 거래 위험을 제어하기 위해 신호 검증을 수행한다.

1 전략

이 전략의 핵심 지표는 다음과 같습니다.

  1. ATR은 시장의 변동성을 역동적으로 반영하는 상쇄수준입니다.

  2. 이 선은 트렌드 방향에 대한 진입 신호를 제공합니다.

  3. 위계 입학을 방지하기 위해 William 지표에 대한 추가 검증을 수행하십시오.

구체적인 거래 논리는 다음과 같습니다.

가격이 첫 번째 평형선 아래로 내려가면 더 많이 하고, 그 다음에는 회수한다. 가격이 평균선 아래로 내려가면 더 많이 하지 않는다. 이는 트렌드 추적을 할 수 있다.

동시에, 윌리엄 지표가 방향과 일치하는지 확인하고, 일치하지 않으면 출전을 포기한다. 이것은 가짜 신호를 필터링 할 수 있다.

매번 입점할 때, ATR로 계산된 스톱로스를 설정한다. ATR은 동적으로 시장의 변동 정도를 반영하고, 합리적인 스톱로스를 설정한다.

스톱로스 또는 스톱 레벨이 트리거되면, 평점 포지션이 이득을 다.

2 전략적 장점

이 전략의 주요 장점은 다음과 같습니다.

첫째, ATR은 시장의 변동성에 따라 위험 통제를 설정하여 큰 손실을 효과적으로 피할 수 있습니다.

두 번째, 평행선 진입은 윌리엄스 지표 검증과 결합하여 신호 품질을 향상시킬 수 있습니다.

마지막으로, 스톱로스 스톱 설정은 또한 각 거래에 대해 정의된 리스크/이익을 제공합니다.

  1. 잠재적인 위험

그러나 우리는 다음과 같은 위험도 고려해야 합니다.

첫째, 동향이 변할 때, 평행선 신호가 지연되어 적시에 반응할 수 없습니다.

두 번째, 너무 급진적인 제약은 제약이 깨지는 것을 초래할 수 있습니다.

마지막으로, 변수 최적화가 잘못되면 과합이 발생할 수 있습니다.

네 가지 내용

이 글은 ATR을 막고, 평평한 입시를 기반으로 한 양자 거래 전략을 자세히 소개한다. 그것은 동적 막고 신호 필터링을 통해 좋은 위험 제어 효과를 얻을 수 있다. 그러나 우리는 또한 트렌드 돌파, 막고가 돌파되는 등의 문제를 예방한다. 전체적으로 이 전략은 간단한 효과적인 트렌드 추적 방법을 제공합니다.

전략 소스 코드
/*backtest
start: 2023-09-06 00:00:00
end: 2023-09-13 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// strategy("NNFX ft. ATR, Kijun-Sen, %R","NNFX-2",true,pyramiding=1,calc_on_order_fills=true,calc_on_every_tick=true,initial_capital = 1000, currency="USD",slippage=5,commission_type=strategy.commission.cash_per_contract,commission_value=0.000035)
strategy.initial_capital = 50000    
//INDICATOR---------------------------------------------------------------------    
    //Average True Range (1. RISK)
atr_period = input(14, "Average True Range Period")
atr = atr(atr_period)

    //Ichimoku Cloud - Kijun Sen (2. BASELINE)
ks_period = input(20, "Kijun Sen Period")
kijun_sen = (highest(high,ks_period) + lowest(low,ks_period))/2
base_long = open < kijun_sen and close > kijun_sen
base_short = open > kijun_sen and close < kijun_sen

    //Williams Percent Range (3. Confirmation#1)
use_wpr = input(true,"Use W%R?")
wpr_len = input(1, "Williams % Range Period")
wpr = -100*(highest(high,wpr_len) - close)/(highest(high,wpr_len) - lowest(low,wpr_len))
wpr_up = input(-25, "%R Upper Level")
wpr_low = input(-75, "%R Lower Level")
conf1_long = wpr >= wpr_up
conf1_short = wpr <= wpr_low
if(use_wpr == false)
    conf1_long := true
    conf1_short := true
//TRADE LOGIC-------------------------------------------------------------------
    //Long Entry
    //if -> WPR crosses below -39 AND MACD line is less than signal line
l_en = base_long and conf1_long
    //Long Exit
    //if -> WPR crosses above -14
l_ex = close < kijun_sen
    //Short Entry
    //if -> WPR crosses above -39 AND MACD line is greater than signal line
s_en = base_short and conf1_short
    //Short Exit
    //if -> WPR crosses under -14
s_ex = close > kijun_sen
    
//MONEY MANAGEMENT--------------------------------------------------------------
balance = strategy.netprofit + strategy.initial_capital //current balance
floating = strategy.openprofit          //floating profit/loss
isTwoDigit = input(false,"Is this a 2 digit pair? (JPY, XAU, XPD...")
risk = input(5,"Risk %")/100           //risk % per trade
equity_protector = input(30,"Equity Protection %")/100  //equity protection %
stop = atr*100000*input(1.5,"Average True Range multiplier")    //Stop level
if(isTwoDigit)
    stop := stop/100
target = input(150, "Target TP in Points")  //TP level
    //Calculate current DD and determine if stopout is necessary
equity_stopout = false
if(floating<0 and abs(floating/balance)>equity_protector)
    equity_stopout := true
    
    //Calculate the size of the next trade
temp01 = balance * risk     //Risk in USD
temp02 = temp01/stop        //Risk in lots
temp03 = temp02*100000      //Convert to contracts
size = temp03 - temp03%1000 //Normalize to 1000s (Trade size)
if(size < 1000)
    size := 1000            //Set min. lot size

//TRADE EXECUTION---------------------------------------------------------------
strategy.close_all(equity_stopout)      //Close all trades w/equity protector
is_open = strategy.opentrades > 0

if(true)
    strategy.entry("l_en",true,oca_name="a",when=l_en and not is_open)  //Long entry
    strategy.entry("s_en",false,oca_name="a",when=s_en and not is_open) //Short entry
    
    strategy.exit("S/L","l_en",loss=stop, profit=target)      //Long exit (stop loss)
    strategy.close("l_en",when=l_ex)            //Long exit (exit condition)
    strategy.exit("S/L","s_en",loss=stop, profit=target)      //Short exit (stop loss)
    strategy.close("s_en",when=s_ex)            //Short exit (exit condition)
    
//PLOTTING----------------------------------------------------------------------
plot(kijun_sen,"Kijun-Sen",color.blue,2)