
この戦略は,移動平均と価格差を計算して市場のトレンド方向を判断し,トレンド条件を満たしているときにより多くポジションを開くことで,揺れのある状況で頻繁にポジションを開くのを避ける.
この戦略は,移動平均と価格変動の幅の判断を組み合わせて,トレンド状況における価格上昇の機会を捕捉することを目的としています.
価格上昇が移動平均線を突破するとき,現在の多頭行情にあることを示している.このとき,最近3周期の最高価格と最低価格の差が自身の20周期平均値より大きい場合,最近波動範囲が拡大したことを示す,価格がより大幅な上昇が発生する可能性があり,このとき,多開ポジションを行う.
ポジション開設後,固定比率のストップ・プローダを設定し,価格が価格を下回ると平仓を積極的にストップし,下サイドリスクをコントロールする.
リスク対策:
この戦略は,シンプルで有効な指標判断によって,トレンド状況で高効率なポジション開設の考えを実現し,小規模な振動を効果的にフィルターし,無意味な取引を避けることができます.同時に,戦略のリスク管理も相応しく位置づけられ,潜在的な損失をうまく制御できます.さらなる最適化により,より良い取引効果が得られることが期待されます.
/*backtest
start: 2023-02-21 00:00:00
end: 2024-02-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estrategia de Diferencia HL y MA para Criptomonedas", shorttitle="HL MA Crypto Strategy-Ortiz", overlay=true)
// Definir longitud de MA y HL
ma_length = input(20, title="Longitud MA")
hl_length = input(3, title="Longitud HL")
exit_below_price = input(0.98, title="Salir por debajo de precio")
// Calcular MA
ma = ta.sma(close, ma_length)
// Calcular HL
hh = ta.highest(high, hl_length)
ll = ta.lowest(low, hl_length)
hl = hh - ll
// Condiciones de tendencia alcista
bullish_trend = close > ma
// Condiciones de entrada y salida
long_condition = close > ma and close > ma[1] and hl > ta.sma(hl, ma_length)
short_condition = false // No operar en tendencia bajista
exit_condition = low < close * exit_below_price
// Entrada y salida de la estrategia
if (long_condition)
strategy.entry("Buy", strategy.long)
if (short_condition)
strategy.entry("Sell", strategy.short)
if (exit_condition)
strategy.close("Buy")
// Plot de señales en el gráfico
plotshape(long_condition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(short_condition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")