같은 높은/저한 전략

저자:차오장, 날짜: 2023-09-14 17:53:17
태그:

전략 논리

이 전략은 동일한 높은/저하 수준을 형성하는 가격 패턴을 기반으로 거래합니다. 연속적인 주간 이중 바닥 또는 이중 상위 형식이 거래를 유발합니다.

논리는 다음과 같습니다.

  1. 현재 또는 이전 바 높은 / 낮은 동일 하 고 / 낮은 2 바 전에 식별

  2. 이중 바닥 패턴은 낮은 브레이크오웃에 긴 트리거

  3. 더블 톱 패턴은 높은 브레이크오웃에 짧은 트리거

  4. 스톱 로스는 브레이크 아웃 수준 근처에 위치하고, ATR 멀티플릭스를 기준으로 수익을 취합니다.

그것은 같은 높은 / 낮은 수준을 깨고 트렌드 재개에 자본을 목표로합니다. 중지 및 이익 목표는 위험을 제어합니다.

장점

  • 같은 높은/하락 식별하기 쉬운, 명확한 탈출 신호

  • ATR 기반의 이익은 동적으로 추세를 추적합니다

  • 간단한 규칙, 정의된 위험

위험성

  • 같은 높고 낮은 패턴 덜 흔한

  • 너무 가까이 서면 멈출 위험이 있습니다.

  • ATR 파라미터 설정에 주의가 필요합니다.

요약

이 전략은 같은 높은 / 낮은 브레이크오웃에서 트렌드 거래를 포착합니다. 그러나 중지 / 이익 조정 및 낮은 빈도는 고려해야합니다.


/*backtest
start: 2023-09-06 00:00:00
end: 2023-09-13 00:00:00
period: 10m
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/
// © cherepanovvsb

//@version=5
strategy("SHL", overlay=true, margin_long=100, margin_short=100,initial_capital=100,default_qty_type = strategy.cash,default_qty_value =40,commission_type = strategy.commission.percent,commission_value =0.04,currency="EUR", process_orders_on_close=true)
atr = input.int(title="ATR length for abnormal candles", defval=5)
plotshape(low == low[1], style=shape.triangleup, location=location.belowbar, color=color.blue, title="1 Setup")
plotshape(high==high[1], style=shape.triangledown, location=location.abovebar, color=color.blue, title="1 Setup")
plotshape(low == low[1] and low[1]==low[2], style=shape.triangleup, location=location.belowbar, color=color.red, title="Triple Setup")
plotshape(low==high[1] or low==high[2] or low==high[3] or low==high[4] or low==high[5] or low==high[6], style=shape.triangleup, location=location.belowbar, color=color.green, title="Mirror Setup")
plotshape(high==low[1] or high==low[2] or high==low[3] or high==low[4] or high==low[5] or high==low[6], style=shape.triangledown, location=location.abovebar, color=color.green, title="Mirror Setup")
barcolor(high-low>2*ta.atr(atr)? color.yellow:na)


ATRlenght   = input.int(title="ATR length for take profit", defval=14, group="Strategy Settings")
rewardMultiplier= input.int(title="ATR multiplier", defval=5, group="Strategy Settings")

// Get ATR
atr1 = ta.atr(ATRlenght)

validlow =  low[1] == low[2] and not na(atr1)
validhigh = high[1]==high[2] and not na(atr1)

validlong = validlow and strategy.position_size == 0 and low[1]<low 
validshort = validhigh and strategy.position_size == 0 and high[1]>high

// Calculate Entrance, SL/TP
longStopPrice = low[1]-syminfo.mintick
longStopDistance = close - longStopPrice
longTargetPrice = close + (longStopDistance * rewardMultiplier)
shortStopPrice = high[1]+syminfo.mintick
shortStopDistance = shortStopPrice - close
shortTargetPrice = close - (shortStopDistance * rewardMultiplier)
var tradeStopPrice = 0.0
var tradeTargetPrice = 0.0
if validlong 
    tradeStopPrice := longStopPrice
    tradeTargetPrice := longTargetPrice
if validshort 
    tradeStopPrice := shortStopPrice
    tradeTargetPrice := shortTargetPrice
strategy.entry ("Long", strategy.long,1, when=validlong)
strategy.entry ("Short", strategy.short,1, when=validshort)

strategy.exit(id="Long Exit", from_entry="Long", limit=tradeTargetPrice, stop=tradeStopPrice, when=strategy.position_size > 0)
strategy.exit(id="Short Exit", from_entry="Short", limit=tradeTargetPrice, stop=tradeStopPrice, when=strategy.position_size < 0)

plot(strategy.position_size != 0 or validlong or validshort ? tradeStopPrice : na, title="Trade Stop Price", color=color.red, style=plot.style_linebr, transp=0)
plot(strategy.position_size != 0 or validlong or validshort ? tradeTargetPrice : na, title="Trade Target Price", color=color.green, style=plot.style_linebr, transp=0)

더 많은