
이 전략은 이중 시간 스케일 동전 전략이다. 그것은 상위 시간 주기에서 간단한 이동 평균을 사용하여 트렌드 방향을 판단하고, 하위 시간 주기에서 축점 (PivotLow와 PivotHigh) 을 사용하여 역점을 식별한다. 상위 시간 주기에서 상승 추세와 하위 시간 주기에서 수평 축점이 있을 때 더 많이 열리고, 상위 시간 주기에서 하향 추세와 하위 시간 주기에서 수평 축점이 있을 때 빈 공간이다.
이 전략의 주요 원칙은 상위 레벨 시간 주기의 트렌드 방향이 하위 레벨 시간 주기의 움직임을 영향을 미친다는 것입니다. 상위 레벨 시간 주기에서 상승 추세가 나타났을 때, 하위 레벨 시간 주기의 회전이 구매 기회일 가능성이 더 높습니다. 상위 레벨 시간 주기에서 하향 추세가 나타났을 때, 하위 레벨 시간 주기의 반동은 빈 기회일 가능성이 더 높습니다. 이 전략은 간단한 이동 평균 (SMA) 을 사용하여 상위 레벨 시간 주기의 트렌드 방향을 판단하고, 축점 (PivotLow 및 PivotHigh) 을 사용하여 하위 레벨 시간 주기의 전환점을 식별합니다.
이 쌍 시간 스케일 동력 전략은 높은 낮은 수준의 시간 주기 사이의 연결을 활용하여 높은 수준의 시간 주기에서 트렌드 방향을 판단하여 낮은 수준의 시간 주기에서 반전점을 포착하여 트렌드 따라와 반전 거래를 실현한다. 이 전략의 논리는 명확하고 장점은 분명하지만 동시에 위험도 있습니다.
/*backtest
start: 2023-04-19 00:00:00
end: 2024-04-24 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Riester
//@version=5
strategy("Dual Timeframe Momentum", overlay=true, precision=6, pyramiding=0, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=25.0, commission_value=0.05)
n = input.int(20, "Moving Average Period", minval=1)
src = input.source(close, "Source")
high_tf = input.timeframe("240", "Resolution")
pivot_l = input.int(5, "Pivot Let Bars")
pivot_r = input.int(2, "Pivot Right Bars")
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Calculations
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
// 1. Define low and high timeframe prices
low_src = src
high_src = request.security(syminfo.tickerid, high_tf, src)
// 2. Use simple moving average to determine trend of higher timeframe (up or down)
high_tf_ma = ta.sma(high_src, n)
plot(high_tf_ma, color=color.yellow)
high_tf_trend = high_tf_ma > high_tf_ma[1] ? 1 : -1
// 3. Use pivots to identify reversals on the low timeframe
low_tf_pl = ta.pivotlow(high_src, pivot_l, pivot_r)
plot(low_tf_pl, style=plot.style_line, linewidth=3, color= color.green, offset=-pivot_r)
low_tf_ph = ta.pivothigh(high_src, pivot_l, pivot_r)
plot(low_tf_ph, style=plot.style_line, linewidth=3, color= color.red, offset=-pivot_r)
bool long = low_tf_pl and high_tf_trend == 1
bool short = low_tf_ph and high_tf_trend == -1
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Plots
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
// this message is an alert that can be sent to a webhook, which allows for simple automation if you have a server that listens to alerts and trades programmatically.
enter_long_alert = '{"side": "Long", "order": "Enter", "price": ' + str.tostring(open) + ', "timestamp": ' + str.tostring(timenow) + '}'
exit_long_alert = '{"side": "Long", "order": "Exit", "price": ' + str.tostring(open) + ', "timestamp": ' + str.tostring(timenow) + '}'
if long
strategy.entry(id="Long", direction=strategy.long, limit=open, alert_message=enter_long_alert)
if short
strategy.close(id="Long", comment="Close Long", alert_message=exit_long_alert)