
Chiến lược này tính toán xu hướng của giá lệch khỏi chỉ số TSI, sau đó xử lý moving average của TSI để tạo ra moving average của chỉ số TSI. Kết hợp với hướng đường K của giá, xác định giá cổ phiếu hiện đang trong xu hướng tăng hoặc xu hướng giảm, tạo ra tín hiệu mua và bán.
Chiến lược này bao gồm một số bước:
Thông qua các bước trên, bạn có thể xác định hướng của xu hướng tổng thể hiện tại, kết hợp với xu hướng thực tế của giá, tạo ra tín hiệu giao dịch.
Chiến lược này sử dụng chỉ số TSI để xác định hướng xu hướng và kết hợp với đường K của giá để tạo ra tín hiệu giao dịch, có thể nắm bắt xu hướng một cách hiệu quả, mua xu hướng tăng và bán xu hướng giảm. Tuy nhiên, cũng có một số rủi ro cần được tối ưu hóa để tăng sự ổn định. Nhìn chung, chiến lược này dễ hiểu trực quan và phù hợp cho các nhà giao dịch quen thuộc với các chỉ số kỹ thuật.
/*backtest
start: 2023-10-29 00:00:00
end: 2023-11-05 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="TSIHULLBOT", shorttitle="TSICCIHULL", default_qty_type=strategy.percent_of_equity, default_qty_value=100)
long = input(title="Long Length", type=input.integer, defval=50)
short = input(title="Short Length", type=input.integer, defval=50)
signal = input(title="Signal Length", type=input.integer, defval=7)
price = input(title="Source",type=input.source,defval=open)
lineupper = input(title="Upper Line", type=input.integer, defval=250)
linelower = input(title="Lower Line", type=input.integer, defval=-250)
double_smooth(price, long, short) =>
fist_smooth = hma(price, long)
hma(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))*5
tsihmaline=(hma(tsi_value,signal))*5
clr = tsihmaline < tsi_value ? color.red : color.lime
clr2 = tsi_value < tsi_value[1] ? color.red : color.lime
i1=plot(lineupper+3, color=color.black, linewidth=3)
i2=plot(linelower+3, color=color.black, linewidth=3)
i3=plot(lineupper, color=clr)
i4=plot(linelower, color=clr)
trendv=tsihmaline/5.6
plot(trendv, linewidth=7, color=color.black)
plot(trendv, linewidth=4, color=color.yellow)
j1=plot(tsi_value, linewidth=5, color=color.black)
j2=plot(tsi_value[1], linewidth=5, color=color.black)
j3=plot(tsi_value, color=clr2)
j4=plot(tsi_value[1], color=clr2)
fill(i3,i4,color=clr,transp=90)
fill(j3,j4,color=clr2,transp=15)
longCondition = tsihmaline>tsihmaline[1] and price>price[1]
if (longCondition)
strategy.entry("Buy ⤴️", strategy.long)
shortCondition = tsihmaline<tsihmaline[1] and price<price[1]
if (shortCondition)
strategy.entry("Sell ⤵️", strategy.short)