
이 전략은 3개의 이동 평균을 기반으로 한 트렌드 추적 전략이다. 그것은 빠른 라인, 중간 라인, 그리고 느린 라인의 교차를 계산하여 가격 추세를 판단하고 ATR 값으로 목표 가격과 중지 가격을 설정한다.
이 전략은 다음의 세 가지 이동 평균을 사용합니다.
빠른 선에서 중간 선, 중간 선에서 느린 선을 통과 할 때, 다중 추세로 판단; 빠른 선 아래에서 중간 선을 통과 할 때, 중간 선 아래에서 느린 선을 통과 할 때, 공허 추세로 판단.
이 전략은 일부 노이즈 트레이딩을 필터링하기 위해 여러 가지 보조 조건을 설정했습니다.
이 조건이 충족되면, 더 많은 또는 더 적은 신호가 발송됩니다. 매번 한 가지 포지션만 가지고, 평형 포지션 또는 손실을 막은 후에 다시 포지션을 열 수 있습니다.
타겟 가격과 스톱 스로드는 ATR 값에 따라 일정 배수를 설정한다.
이 전략은 다음과 같은 장점을 가지고 있습니다.
이 전략에는 다음과 같은 위험도 있습니다.
위험을 제어하기 위해, 이동 평균 파라미터를 적절히 조정하고 ATR 배수를 최적화하고 단일 손실을 너무 많이 피하기 위해 최대 보유 시간을 설정하는 것이 좋습니다.
이 전략은 다음과 같은 측면에서 최적화될 수 있습니다.
이 전략은 전체적으로 안정적인 트렌드를 따르는 전략이다. 그것은 주로 이동 평균을 기반으로 트렌드 방향을 판단하며, 특정 기술 지표 그룹이 보조적으로 작용하여 일부 잡음을 필터링 할 수 있다. 추가적인 최적화 공간이 남아 있지만, 전체적인 위험은 통제 가능하며, 중장선 트렌드를 따르는 데 적합하다.
/*backtest
start: 2024-01-02 00:00:00
end: 2024-02-01 00:00:00
period: 2h
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/
// © greenmask9
//@version=4
strategy("Dazzling Bolts", overlay=true)
//max_bars_back=3000
// 13 SMMA
len = input(10, minval=1, title="SMMA Period")
src = input(close, title="Source")
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len
// 55 EMA
emalength = input(55, title="EMA Period")
ema = ema(close, emalength)
// 100 SMA
smalength = input(110, title="SMA Period")
sma = sma(close, smalength)
emaforce = input(title="Force trend with medium EMA", type=input.bool, defval=true)
offsetemavalue = input(defval = 6)
bullbounce = smma>ema and ema>sma and low[5]>ema and low[2]<ema and close[1]>ema and (ema[offsetemavalue]>sma or (not emaforce))
bearbounce = smma<ema and ema<sma and high[5]<ema and high[2]>ema and close[1]<ema and (ema[offsetemavalue]<sma or (not emaforce))
plotshape(bullbounce, title= "Purple", location=location.belowbar, color=#ff33cc, transp=0, style=shape.triangleup, size=size.tiny, text="Bolts")
plotshape(bearbounce, title= "Purple", location=location.abovebar, color=#ff33cc, transp=0, style=shape.triangledown, size=size.tiny, text="Bolts")
strategy.initial_capital = 50000
ordersize=floor(strategy.initial_capital/close)
longs = input(title="Test longs", type=input.bool, defval=true)
shorts = input(title="Test shorts", type=input.bool, defval=true)
atrlength = input(title="ATR length", defval=12)
atrm = input(title="ATR muliplier",type=input.float, defval=2)
atr = atr(atrlength)
target = close + atr*atrm
antitarget = close - (atr*atrm)
//limits and stop do not move, no need to count bars from since
bullbuy = bullbounce and longs and strategy.opentrades==0
bb = barssince(bullbuy)
bearsell = bearbounce and shorts and strategy.opentrades==0
bs = barssince(bearsell)
if (bullbuy)
strategy.entry("Boltsup", strategy.long, ordersize)
strategy.exit ("Bolts.close", from_entry="Boltsup", limit=target, stop=antitarget)
if (crossover(smma, sma))
strategy.close("Boltsup", qty_percent = 100, comment = "Bolts.crossover")
if (bearsell)
strategy.entry("Boltsdown", strategy.short, ordersize)
strategy.exit("Bolts.close", from_entry="Boltsdown", limit=antitarget, stop=target)
if (crossunder(smma, sma))
strategy.close("Boltsdown", qty_percent = 100, comment = "Bolts.crossover")
// if (bb<5)
// bulltarget = line.new(bar_index[bb], target[bb], bar_index[0], target[bb], color=color.blue, width=2)
// bullclose = line.new(bar_index[bb], close[bb], bar_index[0], close[bb], color=color.blue, width=2)
// bullstop = line.new(bar_index[bb], antitarget[bb], bar_index[0], antitarget[bb], color=color.blue, width=2)
// if (bs<5)
// bulltarget = line.new(bar_index[bs], antitarget[bs], bar_index[0], antitarget[bs], color=color.purple, width=2)
// bullclose = line.new(bar_index[bs], close[bs], bar_index[0], close[bs], color=color.purple, width=2)
// bullstop = line.new(bar_index[bs], target[bs], bar_index[0], target[bs], color=color.purple, width=2)