부피 가격 지표 균형 잡힌 거래 전략

저자:차오장, 날짜: 2023-11-24 14:35:13
태그:

img

전반적인 설명

이 전략은 멀티 타임프레임 볼륨 가격 지표 거래 전략이다. 이는 잠재적 인 긴 신호를 식별하기 위해 상대 강도 지수 (RSI), 평균 진실 범위 (ATR), 간단한 이동 평균 (SMA) 및 사용자 지정 볼륨 가격 조건을 포괄적으로 활용합니다. 특정 과판, 볼륨 가격 크로스오버, 가격 브레이크오브 및 기타 엔트리 조건이 충족되면이 전략은 긴 포지션을 설정합니다. 또한 거래 당 위험 보상 비율을 제어하기 위해 스톱 로스를 설정하고 수익 수준을 취합니다.

전략 논리

이 전략의 주요 내용은 다음과 같습니다.

  1. RSI가 과잉 판매 수준 이하로 떨어지고 최근 10 바 동안 과잉 판매 상태를 유지하면 과잉 판매 신호로 간주됩니다.
  2. 부피 가격 조건의 여러 세트가 정의되고, 이러한 모든 조건이 동시에 충족되어야 부피 가격 지표 긴 신호를 유발합니다.
  3. 닫기 가격이 13주기 SMA를 넘으면 가격 파업 신호로 간주됩니다.
  4. ATR의 작은 기간은 ATR의 큰 기간보다 낮습니다 또한 장기 신호를 기여합니다
  5. 전략은 위의 모든 신호를 결합하여 최종 장기 진입 결정을 내립니다.

특히, 이 전략은 RSI 지표의 길이와 과잉 판매 매개 변수를 설정하고 이러한 매개 변수에 기초하여 RSI 값을 계산합니다. RSI가 여러 차례 연속 바를 위해 과잉 판매 수준 이하로 유지되면 과잉 판매 신호가 유발됩니다.

또한, 전략은 3개의 볼륨 임계값을 정의하고, 다른 시간 프레임의 데이터에 기초하여 여러 개의 볼륨 가격 조건을 설정한다. 예를 들어, 90 기간의 볼륨 값은 49 기간의 1.5배 이상이다. 이 모든 볼륨 가격 조건이 동시에 충족될 때, 볼륨 가격 지표는 긴 신호를 생성한다.

가격 측면에서는 전략이 13 기간 SMA를 계산하고 가격이 SMA 위에 넘어가기 때문에 바 수를 계산합니다. 가격이 SMA 위에 넘어가고 브레이크 후 바 수가 5 미만되면 가격 브레이크 신호로 간주됩니다.

이 전략은 ATR 기간 매개 변수에 대해 5의 작은 기간과 14의 큰 기간을 지정합니다. 작은 기간 ATR이 큰 기간 ATR보다 낮을 때 시장 변동성이 하향으로 가속되고 장기 신호에 기여한다는 신호입니다.

마지막으로, 전략은 과잉 판매, 부피 가격, 가격 브레이크업 및 ATR 지표를 포함한 위의 모든 입시 기준을 고려합니다.이 모든 조건이 동시에 충족되면 최종 긴 신호가 활성화되고 긴 지위가 설정됩니다.

장점

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 멀티 타임프레임 볼륨 가격 조건 판단은 정확성을 향상시킵니다. 단일 타임프레임 대신 여러 개의 볼륨 가격 데이터를 다른 시간 프레임에 걸쳐 평가함으로써 전략은 거래 부피의 농도를 더 정확하게 판단 할 수 있습니다.

  2. 과잉 판매 + 부피 가격 + 가격 파업의 세 가지 확인 메커니즘은 신뢰할 수있는 엔트리 신호를 보장합니다. 과잉 판매 조건은 엔트리의 기본 타이밍을 제공하며, 부피 가격 및 가격 지표의 추가 확인은 긴 신호의 신뢰성을 더욱 보장합니다.

  3. 스톱 로스 및 영리 메커니즘은 거래당 위험을 엄격히 제어합니다. 스톱 로스 및 영리 매개 변수는 개인 위험 욕구에 따라 조정하여 수익을 극대화 할 수 있으며 거래당 위험을 합리적으로 제어 할 수 있습니다.

  4. 여러 지표를 통합하면 안정성이 높아집니다. 일부 지표가 실패하거나 오작동 할 경우에도 전략은 판단을 위해 다른 지표에 의존하고 일정 수준의 회복력을 보장 할 수 있습니다.

위험 과 대책

이 전략에는 몇 가지 위험도 있습니다.

  1. 매개 변수 구성 위험. 지표의 매개 변수 설정은 판단에 직접 영향을 미치며 부적절한 매개 변수는 거래 신호의 편향으로 이어질 수 있습니다. 합리적인 매개 변수 값은 신중하게 검증해야합니다.

  2. 제한된 수익 잠재력: 집단 판단을 위해 여러 지표를 통합하는 전략으로서, 그것의 신호는 시간 단위 당 상대적으로 적은 거래로 더 보수적 인 경향이 있으므로 수익 잠재력은 몇 가지 제약을 가지고 있습니다.

  3. 지표 분산 위험. 일부 지표가 긴 신호를 주고 다른 지표가 짧은 신호를 주고 있을 때, 전략은 최적의 결정을 결정할 수 없다. 지표들 사이의 그러한 잠재적 분산은 사전에 확인하고 해결되어야 한다.

최적화 방향

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

  1. 판단을 돕기 위해 기계 학습 모델을 통합합니다. 모델은 수동으로 정의된 매개 변수를 동적으로 조정하기 위해 볼륨 가격과 변동성 특성에 대해 훈련 할 수 있습니다.

  2. 수익을 취하는 전략의 정교성을 향상시키는 것, 예를 들어 수익을 취하는 후속 중지, 부분 수익을 취하는 것 등으로 수익 손실을 방지하면서 거래 당 수익을 더 높일 수 있습니다.

  3. 주문록 데이터 통합을 평가하십시오. 가격 및 부피 차트 데이터 외에도 주문록 데이터는 추가적인 참조 신호를 제공하기 위해 깊이 유동성 분포 정보를 공개합니다.

  4. 다른 지표와 테스트 조합. 이 전략은 주로 RSI, ATR 및 SMA와 같은 지표를 사용합니다. 볼링거 밴드 및 KDJ와 같은 다른 지표도 거래 신호의 소스를 다양화하고 최적화하기 위해 결합 할 수 있습니다.

결론

이 전략은 잠재적인 긴 진입 기회를 식별하기 위해 RSI, ATR, SMA 및 사용자 지정 볼륨 가격 조건을 포함한 지표의 조합을 활용합니다. 멀티 타임프레임 볼륨 가격 평가, 트리플 확인 메커니즘 및 스톱 로스 / 취업 수익 위험 통제와 같은 장점이 있습니다. 그럼에도 불구하고 매개 변수 구성, 제한된 수익 잠재력과 같은 위험도 주목해야합니다. 미래에 이 전략은 기계 학습 증강, 더 정교한 취업 이익 설계, 주문 책 데이터의 통합 및 확장 된 지표 조합을 통해 더욱 향상 될 수 있습니다.


/*backtest
start: 2023-10-24 00:00:00
end: 2023-11-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © Kimply_Tr
//@version=5

// Strategy settings and parameters
strategy(title='Volume ValueWhen Velocity', overlay=true)

// Define the stop-loss and take-profit percentages for the long strategy
long_stoploss_value = input.float(defval=3, title='Stop-Loss (SL) %', minval=0, group='▶ Stop Loss/Take Profit => Long-Strategy', inline='2')
long_stoploss_percentage = close * (long_stoploss_value / 100) / syminfo.mintick  // Calculate long stop-loss percentage
long_takeprofit_value = input.float(defval=2, title='Take-Profit (TP) %', minval=0, group='▶ Stop Loss/Take Profit => Long-Strategy', inline='2')
long_takeprofit_percentage = close * (long_takeprofit_value / 100) / syminfo.mintick  // Calculate long take-profit percentage

// Define parameters related to ValueWhen occurrences
occurrence_ValueWhen_1 = input.int(title='occurrence_ValueWhen_1', defval=1, maxval=100, step=1, group="▶ ValueWhen",tooltip ="Its value must be smaller than (occurrence_ValueWhen_2)")  
occurrence_ValueWhen_2 = input.int(title='occurrence_ValueWhen_2', defval=5, maxval=100, step=1, group="▶ ValueWhen" ,tooltip="Its value must be greater than (occurrence_ValueWhen_1)")
distance_value=input.int(title='distance_value_occurrence', defval=170, maxval=5000, step=1, group="▶ ValueWhen" ,tooltip="It indicates the minimum distance between the occurrences of 1 and 2, i.e. the difference between the occurrences of 1 and 2 is greater than (distance_value_occurrence)")

// Define RSI-related parameters
rsi_over_sold = input.int(defval=60, minval=1, title='Oversold Level', group='▶ RSI',inline ='2')  // Input for oversold level in RSI
rsi_length = input.int(defval=40, minval=1, title='RSI Length', group='▶ RSI',inline ='2')  // Input for RSI length
rsi = ta.rsi(close, rsi_length)  // Calculate RSI

// Define volume thresholds
volume_threshold1 = input.float(title='volume_threshold_1', defval=0.5, maxval=10, step=0.1, group="▶ Volume")  
volume_threshold2 = input.float(title='volume_threshold_2', defval=0.4, maxval=10, step=0.1, group="▶ Volume")  
volume_threshold3 = input.float(title='volume_threshold_3', defval=0.62, maxval=10, step=0.1, group="▶ Volume")  

// ATR (Average True Range)
// Define ATR parameters
atr_small = input.int(title='ATR_Small', defval=5, maxval=500, step=1, group="▶ Atr",inline ='2') 
atr_big = input.int(title='ATR_Big ', defval=14, maxval=500, step=1, group="▶ Atr",inline ='2') 

atr_value3 = ta.atr(15)  // Calculate ATR value 3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Date Range
// Define the date range for back-testing
start_date = input.int(title='Start Day', defval=1, minval=1, maxval=31, group='▶ Time-Period for Back-Testing', inline='1')  // Input for start day
end_date = input.int(title='until Day', defval=1, minval=1, maxval=31, group='▶ Time-Period for Back-Testing', inline='1')  // Input for end day
start_month = input.int(title='Start Month', defval=7, minval=1, maxval=12, group='▶ Time-Period for Back-Testing', inline='2')  // Input for start month
end_month = input.int(title='until Month', defval=1, minval=1, maxval=12, group='▶ Time-Period for Back-Testing', inline='2')  // Input for end month
start_year = input.int(title='Start Year', defval=2022, minval=1800, maxval=3000, group='▶ Time-Period for Back-Testing', inline='3')  // Input for start year
end_year = input.int(title='until Year', defval=2077, minval=1800, maxval=3000, group='▶ Time-Period for Back-Testing', inline='3')  // Input for end year
in_date_range = time >= timestamp(syminfo.timezone, start_year, start_month, start_date, 0, 0) and time < timestamp(syminfo.timezone, end_year, end_month, end_date, 0, 0)  // Check if the current time is within the specified date range
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
was_over_sold = ta.barssince(rsi <= rsi_over_sold) <= 10  // Check if RSI was oversold in the last 10 bars
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
getVolume(symbol, bar) =>
    request.security(syminfo.tickerid, "D", volume)[bar]  // Function to get volume data for a specific symbol and bar

getVolume2(symbol, bar) =>
    request.security(syminfo.tickerid, "39", volume)[bar]  // Function to get volume data for a specific symbol and bar 2
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

firstCandleColor1 = request.security(syminfo.tickerid, "D", close[2] > open[1] ? 1 : 0)
firstCandleColor2 = request.security(syminfo.tickerid, "1", close[2] > open[0] ? 1 : 0)
firstCandleColor3 = request.security(syminfo.tickerid, "W", close[1] > open[1] ? 1 : 0)

firstCandleColor= ((firstCandleColor1+firstCandleColor2)) > firstCandleColor3 ? 1 : 0

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sma = ta.sma(close, 13)  // Calculate the simple moving average (SMA) of the close price over 13 periods
numCandles = ta.barssince(close > sma)  // Count the number of candles since the close price crossed above the SMA
atr1=request.security(syminfo.tickerid, "30", ta.atr(atr_small)<ta.atr(atr_big))  // Get the ATR value for the specific security and timeframe (30 minutes) and check if ATR_small is less than ATR_big

prevClose = ta.valuewhen(close > sma, close, occurrence_ValueWhen_1)  // Get the close price when it first crosses above the SMA based on occurrence_ValueWhen_1
prevCloseBarsAgo = ta.valuewhen(close > sma, close, occurrence_ValueWhen_2)  // Get the close price when it first crosses above the SMA based on occurrence_ValueWhen_2
prevCloseChange =  (prevCloseBarsAgo - prevClose )  // Calculate the change in the close price between the occurrences of crossing above the SMA

atrval=(atr_value3>140) or (atr_value3 < 123)  // Check if atr_value3 is either greater than 140 or less than 123

Condition =  getVolume(syminfo.tickerid, 90) > volume_threshold1 * getVolume(syminfo.tickerid, 49)   and getVolume(syminfo.tickerid, 110) > volume_threshold3 * getVolume(syminfo.tickerid, 49)  and getVolume2(syminfo.tickerid, 30) > volume_threshold2 * getVolume2(syminfo.tickerid, 55) and getVolume2(syminfo.tickerid, 7) > volume_threshold2 * getVolume2(syminfo.tickerid, 3)  // Check multiple volume conditions

buy_signal=Condition  and atrval and firstCandleColor==0 and  was_over_sold and  prevCloseChange> distance_value and atr1 and  numCandles<5  // Determine if the buy signal is generated based on various conditions

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Long Strategy
// Enter long position if the buy signal conditions are met and within the specified date range
if buy_signal and in_date_range
    strategy.entry('Long', strategy.long, alert_message='Open Long Position')  // Enter long position
    strategy.exit('Long SL/TP', from_entry='Long', loss=long_stoploss_percentage, profit=long_takeprofit_percentage, alert_message='Your SL/TP-Limit for the Long-Strategy has been activated.')  // Exit long position with stop-loss and take-profit




더 많은