적응성 MA와 트렌드 라인을 기반으로 하는 트렌드 브레이크 전략

저자:차오장, 날짜: 2023-09-19 15:49:37
태그:

전반적인 설명

이 전략은 입시에 적응 이동 평균과 트렌드 라인 브레이크오웃, 출시에 RSI를 사용합니다. 조건이 충족되면 트렌드에 입력하고 과소 구매 수준에서 이익을 취하고 한 달에 한 거래로 제한합니다.

전략 논리

  1. 전체 트렌드를 결정하기 위해 99주기 적응형 MA를 계산합니다.

  2. 상위 트렌드 라인 저항을 위한 14주기 지역 최고치를 계산합니다.

  3. 이달 트렌드 라인을 넘어서고 순서가 없는 경우

  4. RSI를 계산하고 RSI가 70 이상 (가장 구매) 에서 종료합니다.

  5. 매월 하나의 거래를 보장하기 위해 마지막 입력 달을 추적합니다.

이점 분석

  1. 적응형 MA는 동적으로 트렌드 변화를 추적합니다.

  2. 트렌드 라인 브레이크는 진입 정밀도를 향상시킵니다.

  3. RSI는 위험 통제를 위해 과소 구매/ 과소 판매 수준을 효과적으로 판단합니다.

  4. 한 달에 한 번 거래하면 빈도와 수수료를 줄일 수 있습니다.

  5. 단순하고 명확한 논리, 이해하기 쉽고 실행하기 쉽습니다.

위험 분석

  1. 부적절한 매개 변수는 놓친 항목을 일으킬 수 있습니다.

  2. 고정된 출구 지표는 시점에 맞춰 시장에 적응할 수 없습니다.

  3. 철수 가능성

  4. 장기간 보유 기간에 대한 위험 통제가 없습니다.

  5. 너무 많은 필터가 출입을 막을 수 있습니다.

최적화 방향

  1. 다양한 매개 변수를 테스트하여 최적의 설정을 얻습니다.

  2. 전략 안정성을 높이기 위해 필터를 추가합니다.

  3. 역동적이고 후속적인 정지 전략을 개발합니다.

  4. 더 강한 탈출을 확인하기 위해 입력 논리를 최적화하십시오.

  5. 적절한 도구와 시간 프레임을 테스트합니다.

  6. 트렌드 필터를 추가해서 가짜 브레이크를 피합니다.

요약

이 전략은 트렌드 분석과 오시일레이터를 통합하여 안정적인 트렌드 다음 효과를 제공합니다. 매개 변수, 동적 출구 등을 추가적으로 최적화하면 신뢰할 수있는 양자 시스템으로 만들 수 있습니다. 전반적으로 좋은 작동성을 가지고 있으며 개선 및 검증 가치가 있습니다.


/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-18 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Bannos Strategy', shorttitle='Bannos', overlay=true)

//The provided script is an indicator for TradingView written in Pine Script version 5. The indicator is used to determine entry and exit points for a trading strategy. Here's a detailed breakdown of what the script does:

// Strategy Definition:

// Bannos Strategy is the full name, with a short title Bannos.
// The overlay=true option indicates that the strategy will be overlayed on the price chart.
// Tracking Entry Month:

// A variable lastEntryMonth is set up to track the month of the last entry.
// currentMonth identifies the current month.
// Trend Regularity Adaptive Moving Average (TRAMA):

// It takes an input of length 99 as default.
// It uses adaptive calculations to track trend changes.
// Trendlines with Breaks:

// Identifies local peaks over a given period (in this case, 14) and calculates a slope based on these peaks.
// Relative Strength Index (RSI):

// Uses a length of 14 (default) to calculate the RSI.
// RSI is an oscillation indicator that indicates overbought or oversold conditions.
// Strategy Logic for Long Entry:

// A long position is opened if:
// The close price is above the TRAMA.
// There's a crossover of the close price and the upper trendline.
// The position is taken only once per month.
// Strategy Logic for Long Exit:

// The long position is closed if the RSI exceeds 70, indicating an overbought condition.
// Plotting:

// The TRAMA is plotted in red on the chart.
// A horizontal line is also drawn at 70 to indicate the RSI's overbought zone.
// In summary, this strategy aims to enter a long position when certain trend and crossover conditions are met, and close the position when the market is considered overbought as per the RSI. Additionally, it ensures entries only occur once a month.
//



// Variable pour suivre le mois de la dernière entrée
var float lastEntryMonth = na
currentMonth = month(time)

// Parameters for Trend Regularity Adaptive Moving Average (TRAMA)
length_trama = input(99)
src_trama = close
ama = 0.
hh = math.max(math.sign(ta.change(ta.highest(length_trama))), 0)
ll = math.max(math.sign(ta.change(ta.lowest(length_trama)) * -1), 0)
tc = math.pow(ta.sma(hh or ll ? 1 : 0, length_trama), 2)
ama := nz(ama[1] + tc * (src_trama - ama[1]), src_trama)

// Parameters for Trendlines with Breaks
length_trend = 14
mult = 1.0
ph = ta.pivothigh(length_trend, length_trend)
upper = 0.
slope_ph = 0.
slope_ph := ph ? mult : slope_ph
upper := ph ? ph : upper - slope_ph

// Parameters for RSI
rsiLength = 14
up = ta.rma(math.max(ta.change(close), 0), rsiLength)
down = ta.rma(-math.min(ta.change(close), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

// Strategy Logic for Long Entry
longCondition = close > ama and ta.crossover(close, upper) and (na(lastEntryMonth) or lastEntryMonth != currentMonth)
if (longCondition)
    lastEntryMonth := currentMonth
    strategy.entry('Long', strategy.long)

// Strategy Logic for Long Exit
exitCondition = rsi > 70
if (exitCondition)
    strategy.close('Long')

// Plotting
plot(ama, 'TRAMA', color=color.red)
hline(70, 'Overbought', color=color.red)


더 많은