어제의 높은 탈출 전략

저자:차오장, 날짜: 2023-11-06 10:49:57
태그:

img

전반적인 설명

어제의 높은 브레이크업 전략은 가격이 어제의 최고치를 넘어서면, 하루 동안 여러 번 브레이크업이 발생하더라도, 장기적으로 진행되는 트렌드를 따르는 시스템입니다. 트렌드 시장 조건을 따르는 것을 목표로합니다.

원칙

이 전략은 입력 및 출력 신호에 대한 여러 기술적 지표를 사용합니다.

  • ROC 필터 - 전략은 오늘날의 종료가 전날 종료와 비교하여 한계 이상의 가격 변화 비율을 갖는 경우에만 활성화됩니다. 이것은 트렌드가 아닌 변동성 시장을 필터합니다.

  • 트리거 포인트 - 오늘의 최고, 최저 및 오픈 가격을 기록합니다. 가격이 오늘날의 최고보다 넘을 때 긴 진입이 시작됩니다.

  • 진입 및 출입 조건 - 진입 후, 스톱 로스 및 영업률이 설정됩니다. 수익을 잠금하기 위해 트레일링 스톱을 활성화 할 수 있습니다. 가격이 참조 EMA 이하로 떨어지면 조건부 출입.

  • 구성 - 진입을 예상하거나 지연하는 격차 비율. 사용자 정의 가능한 스톱 손실, 이익 취득, 후속 스톱 비율.

특히, 엔트리 신호에 대한 오늘날의 높은 가격을 추적합니다. 가격이 오늘날의 최고보다 높을 때 긴 엔트리. 그 다음 트레일링 스톱이 활성화되어있는 스톱 손실 및 수익 출구가 설정됩니다. 주어진 EMA 아래에 가격이 넘어가면 대체 출구. 격차 비율을 설정하여 최적화, 위험을 제어하기 위해 스톱 손실 및 수익 비율을 조정하여 수익을 잠금 할 수 있습니다.

이점 분석

이 전략의 장점:

  • 트렌드를 따라가면서 트렌드 움직임을 통해 수익을 얻습니다.

  • 탈출 전략은 명확한 진입 신호를 제공합니다.

  • 오늘날의 높은 가격을 고려하고, 연속 출입을 피합니다.

  • 손해를 멈추고 이익을 취하는 것은 위험 통제에 도움이 됩니다.

  • 수익을 올리는 걸 막아주죠.

  • 입력 시기는 위험을 제어하기 위해 매개 변수 최적화로 조정할 수 있습니다.

  • 간단하고 직관적이며 이해하기 쉽고 실행하기 쉽습니다.

  • 긴 거래와 짧은 거래에 적용됩니다.

위험 분석

고려해야 할 위험:

  • 브레이크오웃 전략은 위프사 (Whipsaws) 에 민감합니다. 가격은 진입 후 즉시 역전될 수 있습니다.

  • 트렌딩 시장에서만 효과적이지만, 다양한 조건에서 실적은 낮습니다.

  • 합리적인 스톱 손실 비율이 필요하지만 너무 넓으면 손실을 증가시킬 수 있습니다.

  • 합리적인 격차 비율이 필요하지만 너무 공격적이면 손실을 증가시킬 수 있습니다.

  • 잘못된 탈출은 불필요한 손실을 일으킬 수 있습니다. 조정이 필요합니다.

  • 부피는 폭파 후에도 계속 유지되어야 합니다.

  • 시간 프레임에 걸쳐 매개 변수 간의 일관성이 필요합니다.

최적화 방향

가능한 최적화:

  • 부피, 변동성 같은 다른 지표들을 추가해 시장의 변동이 발생하지 않도록 합니다.

  • 트렌드 강도를 평가하기 위해 곡선 부착 지표를 추가하고 잘못된 트렌드를 피합니다.

  • 시장의 변동성에 기초한 진입 격차의 동적 최적화

  • 시장 조건에 따라 Stop Loss 및 Take Profit의 동적 최적화

  • 다른 기호와 시간 프레임에 대한 다른 매개 변수 세트

  • 기계 학습을 통해 전략 성능에 TEST 매개 변수가 영향을 미칩니다.

  • 설정 최적화를 위해 옵션 기능을 추가합니다.

  • 다양한 시장 조건에서 연구 적용 가능성.

  • 시간 프레임과 멀티 자산 전략을 확장합니다.

결론

이 전략은 어제의 높은 개념의 파업에 기반한 트렌딩 시장에서 괜찮은 성능을 제공합니다. 그러나 윙사 및 매개 변수 최적화 어려움의 위험이 있습니다. 판단, 동적 매개 변수 조정, 결합 전략 등으로 확장함으로써 추가 최적화가 가능합니다. 전반적으로 단기 트렌드를 따라 적합하지만 위험 통제 및 매개 변수 조정이 필요합니다.


/*backtest
start: 2023-10-06 00:00:00
end: 2023-11-05 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/
// Author: © tumiza 999 
// © TheSocialCryptoClub

//@version=5

strategy("Yesterday's High v.17.07", overlay=true, pyramiding = 1,
         initial_capital=10000, 
         default_qty_type=strategy.percent_of_equity, default_qty_value=10,
         slippage=1, backtest_fill_limits_assumption=1, use_bar_magnifier=true,
         commission_type=strategy.commission.percent, commission_value=0.075
         )

// -----------------------------------------------------------------------------
// ROC Filter
// -----------------------------------------------------------------------------

// f_security function by LucF for PineCoders available here: https://www.tradingview.com/script/cyPWY96u-How-to-avoid-repainting-when-using-security-PineCoders-FAQ/
f_security(_sym, _res, _src, _rep) => request.security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1]
high_daily = f_security(syminfo.tickerid, "D", high, false)

roc_enable = input.bool(false, "", group="ROC Filter from CloseD", inline="roc")
roc_threshold = input.float(1, "Treshold", step=0.5, group="ROC Filter from CloseD", inline="roc")

closed = f_security(syminfo.tickerid,"1D",close, false)
roc_filter= roc_enable ? (close-closed)/closed*100  > roc_threshold  : true


// -----------------------------------------------------------------------------
// Trigger Point 
// -----------------------------------------------------------------------------

open_session = ta.change(time('D'))
price_session = ta.valuewhen(open_session, open, 0)
tf_session = timeframe.multiplier <= 60

bgcolor(open_session and tf_session ?color.new(color.blue,80):na, title = "Session")

first_bar = 0
if open_session
    first_bar := bar_index

var max_today = 0.0
var min_today = 0.0
var high_daily1 = 0.0
var low_daily1 = 0.0
var today_open = 0.0

if first_bar
    high_daily1 := max_today
    low_daily1 := min_today
    today_open := open
    max_today := high
    min_today := low


if high >= max_today
    max_today := high

if low < min_today
    min_today := low


same_day  = today_open == today_open[1]

plot( timeframe.multiplier <= 240 and same_day ? high_daily1 : na, color= color.yellow , style=plot.style_linebr, linewidth=1, title='High line')
plot( timeframe.multiplier <= 240 and same_day ? low_daily1 : na, color= #E8000D , style=plot.style_linebr, linewidth=1, title='Low line')

// -----------------------------------------------------------------------------
// Strategy settings 
// -----------------------------------------------------------------------------

Gap = input.float(1,"Gap%", step=0.5, tooltip="Gap di entrata su entry_price -n anticipa entrata, con +n posticipa entrata", group = "Entry")
Gap2 = (high_daily1 * Gap)/100

sl  = input.float(3, "Stop-loss", step= 0.5,  group = "Entry")
tp  = input.float(9, "Take-profit", step= 0.5, group = "Entry")
stop_loss_price = strategy.position_avg_price * (1-sl/100)
take_price = strategy.position_avg_price * (1+tp/100)

sl_trl = input.float(2, "Trailing-stop", step = 0.5, tooltip = "Attiva trailing stop dopo che ha raggiunto...",group = "Trailing Stop Settings")//group = "Trailing Stop Settings")
Atrl= input.float(1, "Offset Trailing", step=0.5,tooltip = "Distanza dal prezzo", group = "Trailing Stop Settings")
stop_trl_price_cond = sl_trl * high/syminfo.mintick/100
stop_trl_price_offset_cond = Atrl * high/syminfo.mintick/100

stop_tick = sl * high/syminfo.mintick/100
profit_tick = tp * high/syminfo.mintick/100

mess_buy = "buy"
mess_sell = "sell"

// -----------------------------------------------------------------------------
// Entry - Exit - Close
// -----------------------------------------------------------------------------

if close < high_daily1 and roc_filter
    strategy.entry("Entry", strategy.long, stop = high_daily1 + (Gap2), alert_message = mess_buy)

ts_n  = input.bool(true, "Trailing-stop", tooltip = "Attiva o disattiva trailing-stop", group = "Trailing Stop Settings")
close_ema = input.bool(false, "Close EMA", tooltip = "Attiva o disattiva chiusura su EMA", group = "Trailing Stop Settings")
len1 = input.int(10, "EMA length", step=1, group = "Trailing Stop Settings")
ma1 = ta.ema(close, len1)

plot(ma1, title='EMA', color=color.new(color.yellow, 0))

if ts_n == true
    strategy.exit("Trailing-Stop","Entry",loss= stop_tick, stop= stop_loss_price, limit= take_price, trail_points = stop_trl_price_cond, trail_offset = stop_trl_price_offset_cond, comment_loss="Stop-Loss!!",comment_profit ="CASH!!", comment_trailing = "TRL-Stop!!", alert_message = mess_sell)
else
    strategy.exit("TP-SL", "Entry",loss= stop_tick, stop=stop_loss_price, limit= take_price, comment_loss= "Stop-loss!!!", comment_profit = "CASH!!", alert_message = mess_sell)

if close_ema == true and ta.crossunder(close,ma1)
    strategy.close("Entry",comment = "Close" , alert_message = mess_sell)



더 많은