일일 폐쇄 가격 비교에 기초한 양적 거래 전략

저자:차오장, 날짜: 2023-11-21 14:34:11
태그:

img

전반적인 설명

이 전략은 Daily Close Price Comparison Strategy라고 불린다. 그것은 매일 폐쇄 가격에 기초하여 거래 결정을 내리는 양적 거래 전략이다. 전략은 현재 매일 폐쇄 가격과 이전 매일 폐쇄 가격 사이의 차이를 계산하여 거래 신호를 생성한다. 차이가 설정된 임계치를 초과하면 구매 또는 판매 주문이 실행된다.

전략 논리

이 전략의 핵심 논리는 현재 촛불 / 바와 이전 촛불 / 바 사이의 폐쇄 가격을 비교하는 것입니다. 구체적으로:

  1. 현재 하루 닫기 가격과 이전 하루 닫기 가격 (오늘 - 어제) 의 차이를 계산합니다.
  2. 차이와 어제의 닫기 가격의 비율을 계산합니다 (차 / 어제의 닫기)
  3. 이 비율이 설정된 긍정적 임계보다 크다면 구매 신호가 생성됩니다. 이 비율이 설정된 부정적인 임계보다 작다면 판매 신호가 생성됩니다.
  4. 신호에 따라 긴 또는 짧은 포지션을 입력

이 전략은 스톱 로스를 설정하거나 수익을 취하는 조건을 설정하지 않으며, 진입 및 출구에 대한 문턱 트리거 신호에 의존합니다.

이점 분석

  • 간단한 논리, 이해하기 쉽다, 양자 거래 초보자에게 적합
  • 매일 닫는 가격에만 의존하고 너무 빈번한 거래를 피합니다.
  • 거래 빈도는 기준값을 조정하여 제어할 수 있습니다.

위험 분석

  • 스톱 로스 없이 단일 거래 손실을 통제할 수 없습니다.
  • 연속적인 거래 신호를 생성하여 거래가 과도하게 될 수 있습니다.
  • 마감액이 많고 전체 손실을 잘 조절할 수 없습니다.

최적화 방향

  • 단일 거래 손실을 제어하기 위해 스톱 로스 로직을 추가
  • 과도한 거래를 피하기 위한 항목 제한 수
  • 최적의 거래 빈도를 찾기 위해 매개 변수를 최적화

결론

이 전략은 매일 폐쇄 가격을 비교하여 거래 신호를 생성합니다. 논리는 간단하고 초보자가 배우기에 적합합니다. 그러나 특정 위험을 포함하고 라이브 거래를 위해 추가 최적화가 필요합니다.


/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Daily Close Comparison Strategy (by ChartArt) correct results", shorttitle="CA_-_Daily_Close_Strat", overlay=false)

// ChartArt's Daily Close Comparison Strategy
//
// Version 1.0
// Idea by ChartArt on February 28, 2016.
//
// This strategy is equal to the very
// popular "ANN Strategy" coded by sirolf2009,
// but without the Artificial Neural Network (ANN).
//
// Main difference besides stripping out the ANN
// is that I use close prices instead of OHLC4 prices.
// And the default threshold is set to 0 instead of 0.0014
// with a step of 0.001 instead of 0.0001.
//
// This strategy goes long if the close of the current day
// is larger than the close price of the last day.
// If the inverse logic is true, the strategy
// goes short (last close larger current close).
//
// This simple strategy does not have any
// stop loss or take profit money management logic.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 

threshold = input(title="Price Difference Threshold correct results", type=float, defval=0, step=0.004)

getDiff() =>
    yesterday=request.security(syminfo.tickerid, 'D', close[1])
    today=close
    delta=today-yesterday
    percentage=delta/yesterday
    
closeDiff = getDiff()
 
buying = closeDiff > threshold ? true : closeDiff < -threshold ? false : buying[1]

hline(0, title="zero line")

bgcolor(buying ? green : red, transp=25)
plot(closeDiff, color=silver, style=area, transp=75)
plot(closeDiff, color=aqua, title="prediction")

longCondition = buying
if (longCondition)
    strategy.entry("Long", strategy.long)

shortCondition = buying != true
if (shortCondition)
    strategy.entry("Short", strategy.short)

더 많은