삼각형 파업 트렌드 전략

저자:차오장, 날짜: 2023-09-20 14:24:16
태그:

전반적인 설명

이것은 트렌드를 따르는 전략입니다. 가격이 상승 삼각형 형성에서 벗어날 때 길게 이동하고 빠른 EMA가 중간 EMA를 넘을 때 포지션을 닫습니다. 손실 중지 및 이익 취득 또한 위험을 제어하도록 설정됩니다.

전략 논리

  1. 트렌드 방향을 결정하기 위해 빠른 EMA와 중간 EMA를 사용하십시오. 중간 EMA를 넘어서 빠른 EMA는 긴 신호입니다.

  2. 상승 삼각형이 형성되는지 결정하기 위해 마지막 N 바의 가장 높고 가장 낮은 가격을 사용하십시오. 삼각형 형성은 긴 신호를 제공합니다.

  3. 진입 후, 빠른 EMA가 중간 EMA를 넘으면 트렌드 반전을 표시하고 출구 신호를 제공합니다.

  4. 스톱 로스 출구에 대한 엔트리 가격 아래의 특정 비율로 스톱 로스를 설정합니다.

  5. 부분적인 수익을 위해 입시 가격보다 특정 비율로 수익 목표를 설정하십시오.

  6. 전체 트렌드 방향을 결정하기 위해 200일 EMA를 사용하세요. 트렌드가 상승할 때만 거래하세요.

이점 분석

  1. 삼각형 형식은 거짓 탈출을 필터링하고 진입 정확도를 향상시킵니다.

  2. 빠른 EMA 대 중간 EMA는 트렌드와 통합을 합리적으로 분할하여 윙사 (whipsaws) 를 피합니다.

  3. 합리적인 스톱 로스 및 수익 취득 설정은 단일 거래 손실을 제어합니다.

  4. 상승 추세에서만 거래하면 불안한 시기를 피할 수 있습니다.

위험 분석

  1. 너무 좁은 삼각형 범위는 트렌드를 놓칠 수 있지만 너무 넓은 범위는 불필요한 거래를 증가시킬 수 있습니다. 매개 변수 N는 최적화되어야합니다.

  2. 너무 가까운 스톱 손실은 조기에 중단되는 경향이 있지만 너무 넓은 손실은 손실을 제어하지 못합니다. 매개 변수를 평가하고 최적화하십시오.

  3. 부적절 한 부분적 인 취득 설정은 이익 과잉으로 이어질 수 있습니다. 적절한 비율을 평가하십시오.

  4. 잘못된 트렌드 지표 매개 변수는 잘못된 위치 방향으로 이어질 수 있습니다. 여러 제품 백테스트 최적화가 필요합니다.

개선 방향

  1. 최적의 값을 찾기 위해 삼각형 결정에 대한 매개 변수 N를 최적화합니다.

  2. 트렌드 정확성을 높이기 위해 다른 EMA 기간 조합을 테스트합니다.

  3. 제품 특성에 따라 스톱 로스 및 수익 매개 변수를 최적화합니다.

  4. 신호 품질을 향상시키기 위해 MACD 패턴, 볼링거 브레이크오웃 등과 같은 다른 지표를 추가하십시오.

  5. 트렌드가 계속될 때 수익을 늘리는 재개 메커니즘을 추가합니다.

요약

이 전략은 전반적으로 삼각형 형식으로 신호 정확성을 향상시키는 견고합니다. 추가 향상을위한 큰 매개 변수 최적화 공간이 있습니다. 또한 더 많은 보조 지표를 추가하거나 더 큰 효과를 위해 스톱 손실 / 수익을 개선하려고 노력하십시오. 전반적으로이 전략은 전략에 따라 품질 추세가 될 가능성이 있습니다.


/*backtest
start: 2023-08-20 00:00:00
end: 2023-09-19 00:00:00
period: 1h
basePeriod: 15m
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/
// © mohanee

//@version=4

strategy(title="TrianglePoint strategy", overlay=true,pyramiding=2, default_qty_value=3, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)
// variables  BEGIN

numPeriods=input(9,title="Number of Bars")
fastEMA = input(13, title="fast EMA", minval=1)
slowEMA = input(65, title="slow EMA", minval=1)

stopLoss = input(title="Stop Loss%", defval=5, minval=1)


HH = highest(close[1],numPeriods)
LL = lowest(close[1],numPeriods)
tringlePoint =  low > LL and high < HH

fastEMAval= ema(close, fastEMA)
slowEMAval= ema(close, slowEMA)
two100EMAval= ema(close, 200)

//plot emas
plot(fastEMAval, color = color.green, linewidth = 1, transp=0)
plot(slowEMAval, color = color.orange, linewidth = 1, transp=0)
plot(two100EMAval, color = color.purple, linewidth = 2, transp=0)

longCondition=fastEMAval>two100EMAval and tringlePoint

//plotshape(triP,style=shape.triangleup,text="Buy",color=color.green,location=location.belowbar)
//plotshape(longCondition,style=shape.triangleup,text="Buy",color=color.green,location=location.belowbar)

//Entry
strategy.entry(id="TBT LE", comment="TBT LE" , long=true,  when= longCondition and strategy.position_size<1)   

//Add
strategy.entry(id="TBT LE", comment="Add" , long=true,  when= longCondition and strategy.position_size>=1 and close<strategy.position_avg_price)   


//barcolor(strategy.position_size>=1 ? color.blue : na)

//Take profit
takeProfitVal=   strategy.position_size>=1 ?  (strategy.position_avg_price * (1+(stopLoss*0.01) )) : 0.00
//strategy.close(id="TBT LE", comment="Profit Exit",  qty=strategy.position_size/2,  when=close>=takeProfitVal and close<open and close<fastEMAval)   //crossunder(close,fastEMAval)
barcolor(strategy.position_size>=1  ? (close>takeProfitVal? color.purple : color.blue): na)

//Exit
strategy.close(id="TBT LE", comment="TBT Exit",   when=crossunder(fastEMAval,slowEMAval))


//stoploss
stopLossVal=   strategy.position_size>=1 ?  (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00

//stopLossVal= close> (strategy.position_avg_price * (1+(stopLoss*0.01) )) ? lowest(close,numPeriods) : (strategy.position_avg_price * (1-(stopLoss*0.01) ))


strategy.close(id="TBT LE", comment="SL Exit",   when= close < stopLossVal)

더 많은