この戦略は,前日の最高価格に基づいて操作され,トレンドフォロー型の戦略である.これは,前日の最高価格を破るときに多ポジションを開く,その日に何度か破られたとしても,繰り返しポジションを開く.
LucF関数を使用して,反測を回避する際に最新のK線を覗く.
新しい取引日の開場かどうかを判断する. max_todayの最高値とmin_todayの最低値を記録する.
highとmax_todayを比較して,max_todayを更新する.
この記事の記事一覧はこちらから.
前の取引日の最高値と最低値を描いてください.
前日の最高値を破った時に開設ポイントを設定し,最高値に一定幅のGAPを加え,遅延または早期入場を行うことができる.
ストップレスのslとストップレスのtpを設定します.
価格が前日の最高値を突破したときに多仓を張る.
ストップポイントとストップポイントを設定します.
ストップ追跡を起動するかどうかを選択し,ストップ追跡を起動するための最低要件を設定し,ストップ追跡の距離を追跡することができます.
EMAの状態を判断する
これは比較的簡単なトレンド追跡戦略で,以下の利点があります.
戦略信号はシンプルで明確で 実行しやすい.
前日の最高値の突破によって形成されたトレンド確認信号を利用して,震動市場の騒音を効果的にフィルターすることができます.
GAPパラメータによって入場感度を調節することができる.
総リスクはコントロール可能で,ストップダストは明確です.
追随ストップを使用するかどうかを選択して,より多くの利益をロックすることができます.
EMAの判断と組み合わせれば,死の際にを避けることができます.
この戦略にはいくつかのリスクがあります.
破綻は損失を招く可能性があり,合理的な止損価格設定が必要である.
突破効果は市場がトレンド状態にあることによって決まります.
追跡ストップは,設定が不適切であれば過度に敏感になり,価格がわずかに調整され,ストップになります.
EMAは,パラメータの選択が不適切であれば,過度に敏感または鈍いかもしれないと判断する.
GAP,止損幅度,止損設定の追跡など,多くの変数に注目し,最適化する必要があります.
この戦略をさらに改善するには,以下のポイントを考慮する必要があります.
ストップを固定値からATRまたはトレンドの動的ストップに調整する.
標準差のフィルターで 突破の有効性を評価する
変動率に基づく条件の追加により,地震の無効突破を回避する.
EMAのパラメータを最適化し,判断を安定かつ正確にする.
市場変動の幅に合わせて,ストップを追跡するパラメータを最適化します.
異なる品種のパラメータの健性をテストする.
ポジションのサイズを動的に調整するメカニズムを追加します.
この戦略は,全体的にシンプルで実用的で,典型的なトレンド追跡戦略に属し,前日取引日の最高価格の突破はトレンドを追跡するための信号として,リスク管理は主にストップ・ロスを依拠して実現する.合理的なパラメータの最適化により,戦略がトレンド行情で優れた効果を得ることができる.しかし,ストップ・ロッド戦略とフィルタリング条件を制御する注意が必要です.
/*backtest
start: 2023-09-30 00:00:00
end: 2023-10-07 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
// © TheSocialCryptoClub
//@version=5
strategy("Yesterday's High", 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)