이 전략은동력 쌍 슬라이드 창TSI 지표 전략이 전략의 핵심 아이디어는 쌍 EMA 슬라이딩 창을 사용하여 가격 변화를 평형시키고, 추세의 방향 변화를 결합하여, 시장의 매매력을 반영하는 동력 지표, 즉 TSI 지표를 구성하고, 거래 신호로 구매 또는 판매 결정을 수립하는 것입니다.
이 전략은 두 개의 슬라이드 창 두 개의 지수 이동 평균을 사용하여 가격 변화를 계산합니다. 외면 창 기간이 길고 내면 창 기간이 짧습니다. 두 개의 평준화를 통해 가격 데이터의 일부 무작위성을 제거합니다.
먼저 가격의 단위 변화를 계산해 봅시다.
pc = change(price)
다음으로, 이중 슬라이드 창을 사용하여 가격 변화를 두 번 조정합니다.
double_smoothed_pc = double_smooth(pc, long, short)
가격변동의 절대값을 다시 계산하고, 이중 슬라이딩 창을 사용하여 이중 평준화를 합니다:
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
마지막으로, 평준화 후의 가격 변화를 평준화 후의 가격 변화의 절대값으로 나누면 구매와 판매의 힘을 나타내는 TSI 지표가 나옵니다.
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
다양한 길이의 긴 창 기간을 설정함으로써 단기 시장 소음을 어느 정도 필터링 할 수 있으며, TSI 지표가 중장기 트렌드에서 매매 힘을 더 잘 반영 할 수 있습니다. TSI 지표에 이동 평균을 통과하면 구매 신호가 발생하고, TSI 지표 아래에 이동 평균을 통과하면 판매 신호가 발생합니다.
창 기간 파라미터를 조정하여 신호 평균 길이를 적절히 단축하여 최적화 할 수 있습니다. 시장이 흔들렸을 때 위험을 제어하기 위해 거래를 일시 중단 할 수 있습니다.
이 전략은 가격변동에 기초한 이중 평준화 계산으로 매매력을 반영하는 TSI 동력 지표, 이중 슬라이드 윈도우 필터 잡음, 가격변동의 변화도 이중 평준화, 지표가 더 안정적이고 신뢰할 수 있다; 표준화 비율을 채택하고, 비교가능성을 갖는다; 지표 통합 가격변동의 방향과 강도를 고품질 신호로; 매개 변수를 조정하여 지표의 민감도를 자유로이 제어할 수 있다. 매개 변수 최적화 및 리스크가 통제되는 경우에, 매우 실용적인 수치화 거래 전략 선택이다.
/*backtest
start: 2023-01-01 00:00:00
end: 2024-01-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("True Strength Indicator BTCUSD 2H", shorttitle="TSI BTCUSD 2H",initial_capital=1000, commission_value=0.2, commission_type =strategy.commission.percent, default_qty_value=100 , overlay = false, pyramiding=10, default_qty_type=strategy.percent_of_equity)
//BASED ON True Strength Indicator MTF
resCustom = input(title="Timeframe", defval="120" )
long = input(title="Long Length", defval=25)
short = input(title="Short Length", defval=13)
signal = input(title="Signal Length", defval=13)
length = input(title="Период", defval=300)
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2017, title = "From Year", minval = 2017)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2017)
start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
window() => true // create function "within window of time"
price = request.security(syminfo.tickerid,resCustom,close)
double_smooth(src, long, short) =>
fist_smooth = ema(src, long)
ema(fist_smooth, short)
pc = change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
tsi2=ema(tsi_value, signal)
plot(tsi_value, color=lime,linewidth=2)
plot(tsi2, color=red,linewidth=2)
hline(30, title="Zero")
hline(50, title="Zero",linewidth=2)
hline(70, title="Zero")
buy = crossover(tsi_value, tsi2)
sell = crossunder(tsi_value, tsi2)
if(buy)
strategy.entry("BUY", strategy.long, when = window())
if(sell)
strategy.entry("SELL", strategy.short, when = window())
//greentsi =tsi_value
//redtsi = tsi2
//bgcolor( greentsi>redtsi and rsiserie > 50 ? lime : na, transp=90)
//bgcolor( greentsi<redtsi and rsiserie < 50 ? red : na, transp=90)
//yellow1= redtsi > greentsi and rsiserie > 50
//yellow2 = redtsi < greentsi and rsiserie < 50
//bgcolor( yellow1 ? yellow : na, transp=80)
//bgcolor( yellow2 ? yellow : na, transp=50)
//bgcolor( yellow1 and yellow1[1] ? yellow : na, transp=70)
//bgcolor( yellow2 and yellow2[2] ? yellow : na, transp=70)
//bgcolor( rsiserie > 70 ? lime : na, transp=60)
//bgcolor( rsiserie < 30 ? red : na, transp=60)