
어제 최고 가격을 돌파하는 전략은 트렌드 추적 전략으로, 어제 최고 가격을 돌파했을 때 다중 포지션을 열고, 하루 동안 여러 번 돌파해도 포지션을 열 수 있다. 트렌드를 추적하는 것이 주요 특징이며, 시장이 명백한 트렌드 행태를 보이고 변동률이 높은 상황에 적용된다.
이 전략은 출전과 출전 시기를 식별하는 일련의 지표를 도입합니다.
ROC 곡선 필터 - 당일 종결 가격과 전날 종결 가격의 상승과 하락이 설정된 문턱을 넘으면 전략을 시작합니다. 이 지표는 전략에 부합하지 않는 변동 시장을 필터링하는 데 사용됩니다.
브레이크 포인트 - 당일 최고 가격, 최저 가격, 오픈 가격을 기록한다. 가격이 당일 최고 가격을 돌파 할 때 입문 신호이다.
입점과 퇴출 조건 - 입점 후 중지 손실과 중지 비율을 설정하고, 수익을 잠금하기 위해 추적 손실을 활성화 할 수 있습니다. 특정 EMA에 대한 조건부 중지도 가능합니다.
최적화 구성 - 진입 전 간격 비율을 설정하여 진입 시기를 맞춤화하고 가짜 돌파구를 방지할 수 있습니다. 스톱 손실, 스톱 스, 스톱 손실의 동적 파라미터를 설정할 수 있습니다.
구체적으로, 전략은 당일 최고 가격을 기록하여 진입 시점을 판단한다. 가격이 당일 최고 가격을 초과할 때 다중 진입한다. 이후 정지 손실과 정지 탈퇴를 설정하고, 특정 EMA를 넘어가는 경우도 추적 중지 할 수 있다. 최적화 방법은 진입 전의 간격 비율을 설정하고, 위험을 제어하기 위해 정지 손실 비율을 조정하고, 수익을 잠금하기 위해 추적 중지 손실을 활성화한다.
이 전략은 다음과 같은 장점을 가지고 있습니다.
트렌드를 추적하고, 트렌드에서 수익을 얻습니다.
: : : :
하루 최고 가격을 고려하여 연속 입장을 피하십시오.
위험 관리에 도움이 되는 손해 차단 설정
스톱로스 설정을 추적하여 수익을 잠금할 수 있습니다.
매개 변수를 최적화하여 출전 시기를 조정할 수 있으며, 위험을 제어할 수 있다.
간단한 직관적이고 이해하기 쉬운 구현.
다공간 양방향으로 사용할 수 있다.
이 전략에는 다음과 같은 위험도 있습니다.
개척형 전략은 감금되기 쉽다. 입점 후 가격이 즉시 다시 떨어질 수 있다.
동향상태에서만 유효하며, 변동상태에서는 좋지 않다.
“지속이 너무 느려지면 손실이 더 커질 수 있습니다”.
진입 간격 비율은 합리적으로 설정해야 하며, 너무 극단적인 경우 손실이 증가할 수 있다.
가짜 돌파는 불필요한 손실을 초래할 수 있으며, 조정 및 최적화가 필요합니다.
이 거래량이 추후의 상황을 뒷받침할 수 있는지에 주목해야 한다.
다른 시간 주기 파라미터 설정 사이의 조율성에 주의해야 한다.
이 전략은 다음과 같은 측면에서 최적화될 수 있습니다.
거래량, 충격 지표 등과 같은 다른 기술 지표 판단을 추가하여 충격 상황에서 피하는 것입니다.
트렌드 품질을 판단하고 가짜 트렌드를 따르는 것을 피하기 위해 곡선 적합 지표를 추가하십시오.
진입 간격 설정에 대한 동적 최적화, 시장 변동률에 따라 간격 요구 사항을 조정한다.
스포드 스 설정에 대한 동적 최적화, 시장 조정 파라미터에 따라
다양한 품종에 대한 다른 주기 설정의 다른 매개 변수
기계학습 (Machine Learning) 을 이용한 트레이닝 (TRAINING) 은 다양한 변수들이 전략에 미치는 영향을 테스트한다.
Options 옵션 기능 최적화 설정
이 전략이 어떻게 쓰이는지를 연구해 보세요.
시간적 기간과 품종에 걸쳐 확장된 조합 전략.
이 전략은 어제의 최고 가격을 돌파한 트렌드 추적 아이디어를 기반으로 트렌드 상황에서 잘 작동한다. 그러나 위험과 변수 최적화 문제도 있다. 더 많은 판단 지표, 동적으로 최적화 된 변수 설정, 조합 전략으로 확장하는 등의 수단을 도입하여 더욱 최적화 할 수 있다.
/*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)