범위 필터 구매 판매 신호 전략

저자:차오장, 날짜: 2024-03-08 17:06:50
태그:

img

전반적인 설명

범위 필터 구매 판매 신호 전략은 매우 실용적인 수치적 거래 전략이다. 가격 변동 범위를 사용하여 구매 및 판매 신호를 필터링하여 낮은 변동성 시장에서 잘못된 신호를 줄이고 높은 변동성 시장에서 신호 품질을 향상시킵니다. 전략 이름은 전략의 주요 기능을 정확하게 요약합니다.

전략 논리

이 전략은 먼저 특정 기간 동안 자산 가격의 변동 범위를 계산합니다. 구체적으로, 특정 기간 내에서 가장 높은 가격과 가장 낮은 가격 사이의 차이를 계산하여 가격 변동의 폭을 결정합니다.

그 후 구매 및 판매 신호를 생성합니다. 그러나 모든 신호가 진입을 유발하지는 않지만 가격 변동 범위 필터링 조건을 충족해야합니다. 예를 들어, 가격 변동 범위를 통과 할 때만 구매 신호가 발급됩니다.

이러한 방식으로 전략은 낮은 변동성 시장 환경에서 대부분의 잘못된 신호를 필터링하여 불필요한 진입을 피합니다. 높은 변동성에서는 더 큰 방향 움직임을 포착하여 이익을 얻습니다.

장점

이 전략의 가장 큰 장점은 신호의 필터링 강도를 동적으로 조정할 수 있다는 것입니다. 낮은 변동성에서는 고품질 신호만을 선택하지만 높은 변동성에서는 시장에서 제공하는 더 많은 기회를 잡을 수 있습니다.

고정 매개 변수 필터와 비교하면 이 전략은 더 지능적이고 적응력이 있습니다. 시장이 어떤 상태에 있든 상관없이 우수한 위험 보상을 제공합니다.

또한, 단일 운영 조건에 비해, 이 전략은 더 신뢰할 수 있는 거래 신호를 제공하기 위해 트렌드 방향 판단을 통합합니다. 동시에, 그것은 또한 개별 거래의 위험을 효과적으로 제어하기 위해 스톱 손실 및 수익 기능을 가지고 있습니다.

위험성

전략의 주요 위험은 변동성 범위 매개 변수 설정에 있습니다. 설정 범위가 너무 크거나 너무 작다면 신호 품질과 수익 기회에 부정적인 영향을 줄 것입니다.

또한, 전략은 강한 단기 오시일레이션 추세를 가진 시장에서 상대적으로 적은 수익 기회를 가지고 있습니다. 다른 주기 시스템을 조합하는 것이이 문제를 완화시키는 데 도움이됩니다.

최적화 방향

이 전략은 다음과 같은 측면에서 최적화 될 수 있습니다.

  1. 적응적 매개 변수 알고리즘을 사용하여 변동 범위 매개 변수를 자동으로 최적화하여 더 지능적이고 역동적으로 만듭니다.

  2. 통합 함정을 피하기 위해 큰 사이클 트렌드에 기반한 필터링 규칙을 강화하십시오.

  3. 전략의 다양한 주기를 결합하여 시스템을 형성하고 전반적인 안정성을 향상시킵니다.

  4. 매개 변수 설정과 필터링 규칙의 효과를 향상시키기 위해 기계 학습 알고리즘을 추가합니다.

결론

범위 필터 구매 판매 신호 전략은 매우 실용적이고 효과적인 양적 거래 전략입니다. 그것은 필터 강도를 동적으로 조정하고 다른 시장 환경에서 우수한 위험 보상을 제공할 수 있습니다. 동시에, 특히 매개 변수 최적화 및 규칙 최적화에서이 전략을 최적화하는 데 여전히 큰 잠재력이 있습니다. 전반적으로,이 전략은 안정적인 초과 수익을 추구하는 양적 거래자에게 훌륭한 기본 솔루션을 제공합니다.


/*backtest
start: 2023-03-02 00:00:00
end: 2024-03-07 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/

// Credits to the original Script - Range Filter DonovanWall https://www.tradingview.com/script/lut7sBgG-Range-Filter-DW/
// This version is the old version of the Range Filter with less settings to tinker with

//@version=5
strategy(title='Range Filter - B&S Signals', shorttitle='[Doan]_RF-B&S Signals', overlay=true)

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Functions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
longLossPerc = input.float(title='Long Stop Loss (%)', minval=0.0, step=0.1, defval=1) * 0.01
shortLossPerc = input.float(title='Short Stop Loss (%)', minval=0.0, step=0.1, defval=1) * 0.01

longTakePerc = input.float(title='Long Take(%)', minval=0.0, step=0.1, defval=1) * 0.01
shortTakePerc = input.float(title='Short Take (%)', minval=0.0, step=0.1, defval=1) * 0.01

emaLength = input.int(200, title="EMA Length")

// Determine stop loss price

//Range Size Function
rng_size(x, qty, n) =>
    wper = n * 2 - 1
    avrng = ta.ema(math.abs(x - x[1]), n)
    AC = ta.ema(avrng, wper) * qty
    rng_size = AC

//Range Filter Function
rng_filt(x, rng_, n) =>
    r = rng_
    var rfilt = array.new_float(2, x)
    array.set(rfilt, 1, array.get(rfilt, 0))
    if x - r > array.get(rfilt, 1)
        array.set(rfilt, 0, x - r)
    if x + r < array.get(rfilt, 1)
        array.set(rfilt, 0, x + r)
    rng_filt1 = array.get(rfilt, 0)

    hi_band = rng_filt1 + r
    lo_band = rng_filt1 - r
    rng_filt = rng_filt1
    [hi_band, lo_band, rng_filt]

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Source
rng_src = input(defval=close, title='Swing Source')

//Range Period
rng_per = input.int(defval=20, minval=1, title='Swing Period')

//Range Size Inputs
rng_qty = input.float(defval=3.5, minval=0.0000001, title='Swing Multiplier')

//Bar Colors
use_barcolor = input(defval=false, title='Bar Colors On/Off')

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Filter Values
[h_band, l_band, filt] = rng_filt(rng_src, rng_size(rng_src, rng_qty, rng_per), rng_per)

//Direction Conditions
var fdir = 0.0
fdir := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir
upward = fdir == 1 ? 1 : 0
downward = fdir == -1 ? 1 : 0

//Trading Condition
longCond = rng_src > filt and rng_src > rng_src[1] and upward > 0 or rng_src > filt and rng_src < rng_src[1] and upward > 0
shortCond = rng_src < filt and rng_src < rng_src[1] and downward > 0 or rng_src < filt and rng_src > rng_src[1] and downward > 0

CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1

//Colors
filt_color = upward ? #05ff9b : downward ? #ff0583 : #cccccc
bar_color = upward and rng_src > filt ? rng_src > rng_src[1] ? #05ff9b : #00b36b : downward and rng_src < filt ? rng_src < rng_src[1] ? #ff0583 : #b8005d : #cccccc


ema = ta.ema(close, emaLength)

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Outputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
longStopPrice = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)

longTakePrice = strategy.position_avg_price * (1 + longTakePerc)
shortTakePrice = strategy.position_avg_price * (1 - shortTakePerc)

//Filter Plot
filt_plot = plot(filt, color=filt_color, linewidth=3, title='Filter', transp=67)

//Band Plots
h_band_plot = plot(h_band, color=color.new(#05ff9b, 100), title='High Band')
l_band_plot = plot(l_band, color=color.new(#ff0583, 100), title='Low Band')

//Band Fills
fill(h_band_plot, filt_plot, color=color.new(#00b36b, 92), title='High Band Fill')
fill(l_band_plot, filt_plot, color=color.new(#b8005d, 92), title='Low Band Fill')

//Bar Color
barcolor(use_barcolor ? bar_color : na)
// Entry
strategy.entry("Long", strategy.long, when=longCondition)
strategy.entry("Short", strategy.short, when=shortCondition)

plot(ema)

//Plot Buy and Sell Labels
plotshape(longCondition, title='Buy Signal', text='BUY', textcolor=color.white, style=shape.labelup, size=size.normal, location=location.belowbar, color=color.new(color.green, 0))
plotshape(shortCondition, title='Sell Signal', text='SELL', textcolor=color.white, style=shape.labeldown, size=size.normal, location=location.abovebar, color=color.new(color.red, 0))

//Alerts
alertcondition(longCondition, title='Buy Alert', message='BUY')
alertcondition(shortCondition, title='Sell Alert', message='SELL')





더 많은