
この戦略は,実際の波幅 (True Range) と重量移動平均 (WMA) を利用して,トレンド判断を可能にするクロス期指数を構築する.同時に,複数のポジションを累積したピラミッド加仓機構と,安定した利益を追求するための複数のストップダスト機構を備えている.
この戦略は,まず上方波の幅 ((sub) と下方波の幅 ((baja) を計算し,それから,それぞれ,快線 (corto) 周期と遅線 (largo) 周期のWMAを計算する.快線・遅線差値は,再びWMAを介して指標 ((ind) を計算する.指標が上を0突破すると買入信号が生じ,下を0突破すると売り信号が生じます.
入札後,戦略は5つのポジションを予備し,等比 ((一倍) 累積方式でピラミッド加仓を実現する.同時に,ストップ・メカニズムを設定し,その後,ポジションを開く際には,現在の浮動がストップ・ラインより低いかどうかを判断して,リスクを制御する.
この戦略は,長期間の判断,ピラミッド加減,多重損失停止などの仕組みを統合し,リスクを効果的に管理し,安定した利益を追求することができる.
跨期判断 急速・遅い線の組み合わせによってトレンド判断システムを確立し,市場ノイズを効果的にフィルターし,トレンドの転換点を識別することができる.ピラミッド加仓は,トレンドの開始段階でより多くの利益を上げることができ,多重な止損機構は,単一の損失を効果的に制御することができる.
この戦略の主なリスクは,急激な逆転を引き起こし,ストップ・ローズ・カットオフを誘発する突然の事件が起こり,損失が生じることにある.また,パラメータの設定が不適切であれば,戦略の安定性にも影響を与える.
市場が逆転するリスクに対して,適切な緩解のストップラインに対応することができる.最適化パラメータの設定,周期パラメータの調整,ポジション位数などの戦略の安定性を高める.
この戦略は以下の点で最適化できます.
統計的指標判断を加え,波動率,取引量などの指標修正パラメータを組み合わせ,戦略をより適応的にする.
機械学習モデルの判断を増やし,LSTMなどの深度学習モデルの補助判断を利用し,戦略の正確性を向上させる.
ポジション管理の仕組みを最適化し,ポジションの成長をより合理的にするために,浮動率に比例して加仓幅を調整することを考えることができます.
期貨の套利モデルと組み合わせた期貨の套利を利用して,リスクをさらにコントロールする.
この戦略は,全体として,実際の波幅指標に基づいて構築されたクロスサイクルトレンド戦略であり,ピラミッド加仓と複数のストップダスの仕組みを有し,リスクを効果的に制御し,安定した利益を追求し,非常に実用的な量化取引戦略である.しかし,状況の逆転とパラメータの最適化の問題を注意する必要があるが,統計学,機械学習などの側面からさらに最適化することができる.
/*backtest
start: 2023-01-10 00:00:00
end: 2024-01-16 00:00:00
period: 1d
basePeriod: 1h
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/
// © MaclenMtz
//@version=5
strategy("[MACLEN] Rangos", shorttitle="Rangos [https://t.me/Bitcoin_Maclen]", overlay=false )
//------WINDOW----------
i_startTime = input(defval = timestamp("01 Jan 2022 00:00 -0700"), title = "Start Time", group = "Backtest Window")
i_endTime = input(defval = timestamp("31 Dec 2025 00:00 -0700"), title = "End Time")
window = true
//-----------------------------
sube = close>close[1] ? ta.tr : 0
baja = close<close[1] ? ta.tr : 0
corto = input(10)
largo = input(30)
suavizado = input(10)
fastDiff = ta.wma(sube, corto) - ta.wma(baja,corto)
slowDiff = ta.wma(sube, largo) - ta.wma(baja, largo)
ind = ta.wma(fastDiff - slowDiff, suavizado)
iColor = ind>0 ? color.green : ind<0 ? color.red : color.black
plot(ind, color=iColor)
plot(0, color=color.white)
long = ind[1]<ind and ind[2]<ind[1] and ind<0
short = ind[1]>ind and ind[2]>ind[1] and ind>0
plotshape(long and not long[1], style = shape.xcross, color=color.green, location=location.bottom, size=size.tiny)
plotshape(short and not short[1], style = shape.xcross, color=color.red, location=location.top, size=size.tiny)
//Contratos
contrato1 = input(50000)/(16*close)
c1 = contrato1
c2 = contrato1
c3 = contrato1*2
c4 = contrato1*4
c5 = contrato1*8
//cap_enopentrade = strategy.opentrades == 1 ? c1: strategy.opentrades == 2 ? c1+c2: strategy.opentrades == 3 ? c1+c2+c3: strategy.opentrades == 4 ? c1+c2+c3+c4: strategy.opentrades == 5 ? c1+c2+c3+c4+c5 : 0
openprofit_porc = math.round((close-strategy.position_avg_price)/strategy.position_avg_price * 100,2)
porc_tp = input.float(6.5)
safe = input(-6)
//----------------Strategy---------------------------
if strategy.opentrades == 0
strategy.entry('BUY1', strategy.long, qty=c1, when = long and not long[1] and window)
if strategy.opentrades == 1
strategy.entry('BUY2', strategy.long, qty=c2, when = long and not long[1] and window and openprofit_porc<safe)
if strategy.opentrades == 2
strategy.entry('BUY3', strategy.long, qty=c3, when = long and not long[1] and window and openprofit_porc<safe)
if strategy.opentrades == 3
strategy.entry('BUY4', strategy.long, qty=c4, when = long and not long[1] and window and openprofit_porc<safe)
if strategy.opentrades == 4
strategy.entry('BUY5', strategy.long, qty=c5, when = long and not long[1] and window and openprofit_porc<safe)
min_prof = strategy.openprofit>0
strategy.close_all(when=short and min_prof)
plot(openprofit_porc)