추세 추종 그리드 전략


생성 날짜: 2023-12-08 12:05:17 마지막으로 수정됨: 2023-12-08 12:05:17
복사: 0 클릭수: 1241
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

추세 추종 그리드 전략

개요

이 전략은 단지 더 많은 것을 하지 않고 공백을 만들지 않고, 큰 트렌드 상향 시기를 선택하는 트렌드 추적 격자 전략이다. 기본 격자 크기는 1배의 ATR이며, 아래로 추적하는 1위, 2위, 3위 격자를 구축하고, 5위 상쇄한다. 공백이 있을 때 가격이 상위 1개의 격자를 뚫면, 전체 격자는 상향으로 이동하여 추적 가격을한다.

전략 원칙

  1. EMA 평균선을 사용하여 큰 트렌드 방향을 판단하고, EMA12이 EMA144보다 크면 큰 트렌드 상승으로 판단
  2. 큰 트렌드일 때만 더 많이 투자하세요.
  3. 격자 크기는 기본적으로 ATR의 1배이고, 배수를 조정할 수 있습니다.
  4. 1단계, 2단계, 3단계 격자를 구축하여 아래로 추격하는 가격, 각각 더 많은 상장을 개설하는 것
  5. 그래프 5에서 스톱포인트를 설정합니다
  6. 포지션 개설 후 정지점과 정지점을 설정
  7. 가격 상승이 하락점을 통과했을 때
  8. 가격 하락이 스톱포인트 평점을 촉발할 때
  9. 포지션이 모두 청산된 후, 가격이 마지막 격자를 다시 돌파하면 격자 위치와 수를 재계산하고 상향 추적합니다.

이 전략은 EMA를 통해 큰 트렌드 방향을 판단하고, 그레드 전략과 결합하여 추적하여, 큰 트렌드 상향상황에서 더 큰 수익을 얻을 수 있다. 그레드는 여러 가격점을 설정하고, 포지션을 세분화하여, 단일 포지션의 위험을 줄일 수 있다. 스톱 스톱 손실 설정은 이익을 얻을 수 있도록 잠금하고, 최대 손실을 제어한다. 포지션이 모두 평형되면, 그레드 고점을 재 계산하여, 다시 포지션을 열 수 있게 하여, 수익을 극대화한다.

우위 분석

  1. EMA를 통해 큰 트렌드 방향을 판단하고, 역동적인 포지션을 피하십시오.
  2. 네트워크 전략은 한 개의 창고에 대한 위험을 줄여서 수량으로 창고를 건설할 수 있습니다.
  3. 스톱 스톱 손실 설정은 최대 손실을 제어하는 수익을 고정합니다.
  4. 포지션 평준화 후, 그레이트를 재계산하여 수익을 늘릴 수 있습니다.

이 전략의 주요 장점은 트렌드 거래와 격자 거래를 결합하여 트렌드 방향의 정확성을 보장하고 격자 전략의 위험 분산을 실현하는 것입니다. 또한, 포지션 평소 후 격자를 재 계산하면 무한히 회수 할 수 있으며, 따라서 시장에서 큰 파장이 발생할 때 큰 돈을 벌 수 있습니다.

위험 분석

  1. 트렌드 판단이 틀릴 수도 있고, 잘못된 방향으로 갈 수도 있습니다.
  2. “그림”이 “그림”이 “그림”이 “그림”이 “그림”입니다.
  3. 손실이 너무 빨리 멈췄고, 모든 지점이 평평해졌다.
  4. 하지만, 그 후로, 다시 좋은 입구로 들어갈 수 없게 되었습니다.

주요한 위험은 큰 추세를 잘못 판단하여 역동적으로 지점을 구축하여 큰 손실을 초래할 수 있습니다. 또한, 시장 상황이 급격하게 흔들리면 여러 개의 격자가 동시에 갇혀있는 경우 손실이 증가합니다. 또한 가격의 급격한 하락이 스톱 손실을 유발하면 지점이 완전히 평정되어 수익을 얻을 수있는 기회를 잃게됩니다. 가격 반발 후 다시 초기 최적의 격자 위치에 들어가는 것은 어렵습니다.

EMA 파라미터를 최적화하여 큰 트렌드를 판단하는 정확도를 높일 수 있다. 그리드 간격과 오프닝 수를 조정하는 것도 전체 손실을 제어할 수 있다. 스톱포트 위치의 설정은 시장의 변동 빈도를 고려할 필요가 있다. 또한, 일부 포지션이 수익을 얻은 후에 멈춘 것을 고려할 수도 있다.

최적화 방향

이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.

  1. EMA 파라미터를 최적화하여 큰 트렌드 판단의 정확성을 향상시킵니다.
  2. 격자 간격과 수를 조정하여 수익 위험 비율을 최적화합니다.
  3. 부분 포지션 스톱, 이동 스톱 등과 같은 스톱 스톱 로직을 개선합니다.
  4. 재입학 조건 제한을 강화하여 재발전 과정에서 재입학을 방지합니다.
  5. K선 모양, 지표 민감도 등과 같은 더 많은 지표와 함께 진출 시기를 판단합니다.
  6. 비정상적인 상황을 판단하고, 비정상적인 상황에서 큰 손실을 피하십시오.

이러한 최적화 조치들을 통해, 전략은 큰 상황에서의 더 큰 수익을 얻을 수 있고, 동시에 위험을 통제하고, 일반적인 충격적인 흐름에서의 손실을 줄일 수 있다.

요약하다

이 전략은 트렌드 거래와 격자 거래의 유기적인 결합이다. 그것은 EMA를 사용하여 큰 방향을 판단하고, 그레드 전략을 사용하여 포지션을 잇다. 위험 통제가 위치하고, 정지 손실 및 격자 재 계산의 추적 장치가 있다. 전체적으로, 이 전략은 시장의 큰 추세에서 좋은 수익을 얻을 수 있으며, 또한 위험을 통제한다.

전략 소스 코드
/*backtest
start: 2022-12-01 00:00:00
end: 2023-12-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/
// © zxcvbnm3260

//@version=5
strategy("grid strategy long", overlay=true)


// 版本更新记录:
// v1.0 2021/11/09 只做多、不做空,选择大趋势向上的时间段。网格大小默认为1倍ATR,往下1、2、3个网格吃单,第5个网格止损。空仓时到达往上一个网格则网格整体抬升。(Only go long, not short, choose a time period when the general trend is up. The default grid size is 1x ATR, the next one, two, and three grids will take orders, and the fifth grid will stop loss. When the empty position reaches the upper grid, the grid as a whole rises.)


X_ATR = input.float(title='网格大小是多少倍ATR?', defval = 1)


// 1.基础变量
ema169 = ta.ema(close, 169)
ema144 = ta.ema(close, 144)
ema12 = ta.ema(close, 12)

ema576 = ta.ema(close, 576)
ema676 = ta.ema(close, 676)

plot(ema169, color=color.new(color.orange, 0), linewidth=2)
// plot(ema144, color=color.orange)
plot(ema12,  color=color.blue)
// plot(ema676, color=color.orange, linewidth=1)

mtr = math.max(high - low, math.abs(close[1] - high), math.abs(close[1] - low))
atr = ta.ema(mtr, 30)

is_0930 = hour(time, 'GMT-4') == 9  and minute(time, 'GMT-4') == 30
is_1500 = hour(time, 'GMT-4') == 15 and minute(time, 'GMT-4') == 00
is_1530 = hour(time, 'GMT-4') == 15 and minute(time, 'GMT-4') == 30

is_yangxian = close>open
is_yinxian = close<open

// 2.基本趋势标记

big_trend  = ema12 >= ema169 ? 1 : 0
big_trend2 = ema12 <= ema169 ? 1 : 0

// 背景的变色处理:
bgcolor(big_trend == 1 ? color.new(color.green, 90) : color.new(color.red, 90) )

// 3.网格点位初始化

grid_size = atr * X_ATR // 网格大小
        
price_entry1 = open - grid_size*1
price_entry2 = open - grid_size*2
price_entry3 = open - grid_size*3
price_stop_loss = open - grid_size*5

price_exit1 = price_entry1 + grid_size*1
price_exit2 = price_entry2 + grid_size*1
price_exit3 = price_entry3 + grid_size*1

qty1 = int(1000/price_entry1)
qty2 = int(1000/price_entry2)
qty3 = int(1000/price_entry3)


// 标出各种点位
slm_lines_time(time, price_entry1, price_entry2, price_entry3, price_stop_loss, price_exit1)=>
    time2 = time + 1000*3600*24*5
    line.new(time, price_stop_loss, time2, price_stop_loss, color=color.red, xloc = xloc.bar_time, width=2)  // 止损位
    line.new(time, price_entry1, time2, price_entry1, color=color.green, xloc = xloc.bar_time)  // 
    line.new(time, price_entry2, time2, price_entry2, color=color.green, xloc = xloc.bar_time)  // 
    line.new(time, price_entry3, time2, price_entry3, color=color.green, xloc = xloc.bar_time)  // 
    line.new(time, price_exit1,  time2, price_exit1,  color=color.green, xloc = xloc.bar_time, width=2)  // 

slm_lines(time, price_entry1, price_entry2, price_entry3, price_stop_loss, price_exit1)=>
    line.new(bar_index, price_stop_loss, bar_index[5], price_stop_loss, color=color.red, xloc = xloc.bar_index, width=2)  // 止损位
    line.new(bar_index, price_entry1, bar_index[5], price_entry1, color=color.green, xloc = xloc.bar_index)  // 
    line.new(bar_index, price_entry2, bar_index[5], price_entry2, color=color.green, xloc = xloc.bar_index)  // 
    line.new(bar_index, price_entry3, bar_index[5], price_entry3, color=color.green, xloc = xloc.bar_index)  // 
    line.new(bar_index, price_exit1,  bar_index[5], price_exit1,  color=color.green, xloc = xloc.bar_index, width=2)  // 


// 4.网格点位更新和下单

is_entry0 = big_trend==1 and year>=2020

var is_entry = false

// 未进场时:
if is_entry0 and not is_entry
    is_entry := true
    
    grid_size := atr * X_ATR // 网格大小
    
    price_entry1 := close - grid_size*1
    price_entry2 := close - grid_size*2
    price_entry3 := close - grid_size*3
    price_stop_loss := close - grid_size*5
    
    price_exit1 := price_entry1 + grid_size*1
    price_exit2 := price_entry2 + grid_size*1
    price_exit3 := price_entry3 + grid_size*1
    
    qty1 := int(1000/price_entry1)
    qty2 := int(1000/price_entry2)
    qty3 := int(1000/price_entry3)
    
    // slm_lines(time, price_entry1, price_entry2, price_entry3, price_stop_loss, price_exit1)
    
    strategy.entry("open1", strategy.long, qty1, limit = price_entry1)
    strategy.entry("open2", strategy.long, qty2, limit = price_entry2)
    strategy.entry("open3", strategy.long, qty3, limit = price_entry3)
    
    strategy.exit("close1", qty = qty1, limit = price_exit1, stop = price_stop_loss)
    strategy.exit("close2", qty = qty2, limit = price_exit2, stop = price_stop_loss)
    strategy.exit("close3", qty = qty3, limit = price_exit3, stop = price_stop_loss)

// 已进场的各类情况

// 1.止损
if is_entry and close <= price_stop_loss
    strategy.close_all()
    is_entry := false

// 2.网格抬升
if is_entry and close >= price_exit1
    is_entry := false