일별 종가 비교를 기반으로 한 양적 거래 전략


생성 날짜: 2023-11-21 14:34:11 마지막으로 수정됨: 2023-11-21 14:34:11
복사: 0 클릭수: 782
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

일별 종가 비교를 기반으로 한 양적 거래 전략

개요

이 전략은 ?? 일선 종결 가격 비교 전략 ?? 이라고 하며, 일선 종결 가격에 기초하여 거래 결정을 하는 양적 전략이다. 이 전략은 현재 일선 종결 가격과 전날 일선 종결 가격의 차이를 계산하여 거래 신호를 생성한다. 차이가 설정된 ?? 값을 초과할 때 구매 또는 판매 작업을 수행한다.

전략 원칙

이 전략의 핵심 논리는 현재 K 선의 종결 가격과 이전 K 선의 종결 가격을 비교하는 것이다.

  1. 현재 일계 종식 가격과 전날 일계 종식 가격의 차이를 계산합니다.
  2. 계산된 차이는 전날의 닫기 가격과의 비율입니다.
  3. 비율이 설정된 긍정적 인 스레드보다 크면 구매 신호를 생성합니다. 비율이 설정된 부정적인 스레드보다 작으면 판매 신호를 생성합니다.
  4. 신호에 따라 추가 또는 빈 창고 위치

이 전략은 스톱로스 및 스톱 스톱 조건을 설정하지 않고, 하락 조건에 의해 형성되는 거래 신호에 의존하여 입시 및 평화적인 위치를 수행한다.

우위 분석

  • 간단한 사고방식, 쉽게 이해할 수 있고, 양자 거래에 대한 입문 학습에 적합합니다.
  • 거래가 너무 자주 발생하지 않도록, 거래가 일일 종결 가격에만 기반을 두어야 합니다.
  • 트레이딩 주파수를 조절할 수 있습니다.

위험 분석

  • 단위 손실을 제어할 수 없는 단위 손실 설정
  • 연속적인 거래 신호로 인해 과도한 거래가 발생할 수 있습니다.
  • 이 회수액이 너무 커서 총 손실을 잘 통제할 수 없다.

최적화 방향

  • 단독 손실을 제어하기 위해 Stop Loss Logic을 추가합니다.
  • 포지션 개시 제한을 늘리고 과도한 거래를 방지한다
  • 최적화 매개 변수, 최적의 거래 주파수

요약하다

이 전략은 일선 종식 가격을 비교하여 거래 신호를 형성합니다. 아이디어는 간단하며 입문 학습에 적합합니다. 그러나 이 전략에는 약간의 위험이 있으며 실장 거래에 대한 추가 최적화가 필요합니다.

전략 소스 코드
/*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)