TSI 크로스오버 전략

TSI EMA ATR TEMA
생성 날짜: 2024-06-07 16:36:24 마지막으로 수정됨: 2024-06-07 16:36:24
복사: 7 클릭수: 628
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

TSI 크로스오버 전략

개요

이 전략은 TSI 지표를 주요 거래 신호로 사용한다. TSI 지표가 신호선과 교차하고 TSI 지표가 하계 또는 상계보다 높을 때 전략은 포지션 개설 신호를 발생시킨다. 이 전략은 또한 EMA 및 ATR과 같은 지표를 사용하여 전략의 성능을 최적화한다. 전략은 특정 거래 시간 내에만 작동하며 과도한 거래를 제어하기 위해 최소 거래 주파수를 설정한다.

전략 원칙

  1. TSI 지표값과 신호 선값을 계산한다.
  2. 현재 거래가 허용되는 시간 범위 안에 있는지 판단하고 현재 바는 최소 최소 바를 최소로 지난 거래로부터 간격화한다.
  3. 만약 TSI 지표가 아래에서 위로 신호선을 통과하고, 이 시점 신호선은 지정된 하위 한계보다 낮다면, 다중 신호가 생성된다.
  4. 만약 TSI 지표가 위아래로 신호선을 통과하고, 이 시점 신호선은 지정된 상위 한계보다 높으면 공백 신호가 발생한다.
  5. 만약 현재 다중 상위 포지션을 보유하고 있다면, TSI 지표가 위아래로 신호선을 통과하면, 모든 다중 상위 포지션을 평행한다.
  6. 현재 공백을 가지고 있다면, TSI 지표가 아래에서 위로 신호선을 통과하면 모든 공백을 평행한다.

우위 분석

  1. 전략 논리는 명확하고, TSI 지표의 교차를 유일한 청정 포지션 조건으로 사용하며, 간단하고 이해하기 쉽습니다.
  2. 거래 시간 및 거래 빈도를 제한함으로써 과도한 거래의 위험을 효과적으로 통제합니다.
  3. 적당한 시간에 스톱포드를 중지하고, 반대 신호가 발생했을 때 평평한 위치를 결정하여, 단일 거래의 위험 을 제어한다.
  4. EMA, ATR 등과 같은 여러 지표를 사용하여 판단을 보조하여 전략의 안정성을 강화합니다.

위험 분석

  1. 정책은 TSI 지표의 파라미터를 선택하는데 민감하며, 다른 파라미터는 성능에 큰 차이를 가져오며 신중하게 선택해야 한다.
  2. 포지션 개설 및 포지션 조건은 비교적 간단하며, 추세 판단과 변동률 제약이 없으며, 불안정한 상황에서는 손실이 발생할 수 있다.
  3. 포지션 관리와 자금 관리의 부족으로 인출을 통제하기 어렵고, 연속적인 손실이 발생하면 대규모 인출이 발생할 수 있습니다.
  4. 트렌드 추적을 하지 않고 그냥 텅 빈 반전만 하면, 많은 트렌드 진행 기회를 놓칠 수 있다.

최적화 방향

  1. TSI 지표의 매개 변수를 최적화하여 더 안정적인 매개 변수 조합을 찾습니다. 유전 알고리즘과 같은 방법을 사용하여 자동으로 최적화를 찾을 수 있습니다.
  2. MA나 MACD와 같은 트렌드 판단 지표를 추가하여 포지션을 개시할 때 우세한 방향을 선택하여 성공률을 높인다.
  3. ATR과 같은 변동성 지표를 추가하여 높은 변동성 시장 환경에서 거래 횟수를 줄일 수 있습니다.
  4. 포지션 관리 모델을 도입하여, 최근 시장의 성과와 계정 순가 등에 따라 각각의 거래의 포지션 크기를 동적으로 조정한다.
  5. 트렌드 추적의 논리를 증가시킬 수 있고, 트렌드 상황 속에서 계속 입지를 유지하며, 전략의 큰 상황을 포착하는 능력을 향상시킬 수 있다.

요약하다

이 전략은 TSI 지표를 중심으로, TSI와 신호선의 교차로 거래 신호를 생성한다. 동시에 거래 시간 및 거래 주파수를 제한하여 위험을 제어한다. 전략의 장점은 논리적으로 간단하고 명확하며, 적시에 손해 중지이다. 그러나 단점은 트렌드 판단과 포지션 관리의 부족이며, TSI 매개 변수에 민감하며, 역동 상황을 포착하여 트렌드 상황을 놓칠 수 있다.

전략 소스 코드
/*backtest
start: 2024-05-30 00:00:00
end: 2024-06-06 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nikgavalas

//@version=5
strategy("TSI Entries", overlay=true, margin_long=100, margin_short=100)

//
// INPUTS
//

// Define the start and end hours for trading
string sessionInput = input("1000-1530", "Session")

// Day of the week.
string daysInput = input.string("23456", tooltip = "1 = Sunday, 7 = Saturday")

// Minimum number of bar's between entries
requiredBarsBetweenEntries = input.int(12, "Required Bars Between Entries")

// Show debug labels
bool showDebugLabels = input.bool(false, "Show Debug Labels")

//
// FUNCTIONS
//

//@function Define the triple exponential moving average function
tema(src, len) => tema = 3 * ta.ema(src, len) - 3 * ta.ema(ta.ema(src, len), len) + ta.ema(ta.ema(ta.ema(src, len), len), len)

//@function Atr with EMA
atr_ema(length) =>
    trueRange = na(high[1])? high-low : math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1]))
    //true range can be also calculated with ta.tr(true)
    ta.ema(trueRange, length)

//@function Check if time is in range
timeinrange() => 
    sessionString = sessionInput + ":" + daysInput
    inSession = not na(time(timeframe.period, sessionString, "America/New_York"))

//@function Displays text passed to `txt` when called.
debugLabel(txt, color, y, style) =>
    if (showDebugLabels) 
        label.new(bar_index, y, text = txt, color = color, style = style, textcolor = color.black, size = size.small)


//
// INDICATOR CODE
//

long = input(title="TSI Long Length", defval=8)
short = input(title="TSI Short Length", defval=8)
signal = input(title="TSI Signal Length", defval=3)
lowerLine = input(title="TSI Lower Line", defval=-50)
upperLine = input(title="TSI Upper Line", defval=50)

price = close
double_smooth(src, long, short) =>
	fist_smooth = ta.ema(src, long)
	ta.ema(fist_smooth, short)

pc = ta.change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(math.abs(pc), long, short)
tsiValue = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
signalValue = ta.ema(tsiValue, signal)

//
// COMMON VARIABLES
//

var color trendColor = na
var int lastEntryBar = na

bool tradeAllowed = timeinrange() == true and (na(lastEntryBar) or bar_index - lastEntryBar > requiredBarsBetweenEntries)

// 
// CROSSOVER
//

bool crossOver = ta.crossover(tsiValue, signalValue)
bool crossUnder = ta.crossunder(tsiValue,signalValue)

if (tradeAllowed) 
	if (signalValue < lowerLine and crossOver == true)
		strategy.entry("Up", strategy.long)
		lastEntryBar := bar_index

	else if (signalValue > upperLine and crossUnder == true)

		strategy.entry("Down", strategy.short)
		lastEntryBar := bar_index

// 
// EXITS
// 

if (strategy.position_size > 0 and crossUnder == true)
	strategy.close("Up", qty_percent = 100)

else if (strategy.position_size < 0 and crossOver == true)
	strategy.close("Down", qty_percent = 100)