
이 전략은 수정된 거래량 진동기 지표에 기반하여 거래를 하는 트렌드 추적 전략이다. 거래량의 평균선을 사용하여 거래량이 증가한 신호를 식별하여 입점 또는 퇴출을 판단한다. 동시에 가격 자체의 트렌드 판단과 결합하여 가격 진동시 잘못된 신호를 피한다.
이러한 위험은 변수를 조정하고, 지표 계산 방법을 최적화하고, 다른 지표와 결합하여 확인하여 제어할 수 있습니다.
이 전략은 개선된 거래량 진동기를 통해 가격 추세를 판단하는 데 도움을 주며 두 개의 하위 값을 설정하여 포지션을 개시하고 상쇄합니다. 전체적으로 안정적인 트렌드 추적 전략입니다. 최적화 공간은 주로 매개 변수 조정, 신호 필터링 및 상쇄 전략의 측면입니다.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy('Volume Advanced', default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075, currency='USD')
startP = timestamp(input(2017, "Start Year"), input(12, "Start Month"), input(17, "Start Day"), 0, 0)
end = timestamp(input(9999, "End Year"), input(1, "End Month"), input(1, "End Day"), 0, 0)
_testPeriod() =>
iff(time >= startP and time <= end, true, false)
source = close
vol_length = input(34, title = "Volume - Length")
vol_smooth = input(200,title = "Volume - Smoothing")
volriselen = input(21, title = "Volume - Risinglength")
volfalllen = input(13, title = "Volume - Fallinglength")
threshold = input(1,"threshold")
threshold2 = input(1.2,step=0.1, title="Threshold 2")
direction = input(13,"amount of bars")
volsum = sum(volume, vol_length) / (sum(volume, vol_smooth) / (vol_smooth / vol_length))
LongEntry = (rising(volsum, volriselen) or crossover (volsum, threshold)) and close > close[direction]
ShortEntry = (rising(volsum, volriselen) or crossover (volsum, threshold)) and close < close[direction]
LongExit1 = falling (volsum,volfalllen)
ShortExit1 = falling (volsum,volfalllen)
LongExit2= (crossover(volsum, threshold2) and close < close[direction])
_state = 0
_prev = nz(_state[1])
_state := _prev
if _prev == 0
if LongEntry
_state := 1
_state
if ShortEntry
_state := 2
_state
if _prev == 1
if ShortEntry or LongExit1
_state := 0
_state
if _prev == 2
if LongEntry or ShortExit1
_state := 0
_state
_bLongEntry = _state == 1
_bLongClose = _state == 0
long_condition = _bLongEntry and close > close[direction]
strategy.entry('BUY', strategy.long, when=long_condition)
short_condition = _bLongClose or LongExit2
strategy.close('BUY', when=short_condition)
plot(volsum, color = color.green, title="Vol_Sum")
plot(threshold, color = color.fuchsia, transp=50, title="Threshold")
plot(threshold2, color=color.white, transp = 50, title="Threshold 2")