
Bài viết này chủ yếu giới thiệu về một chiến lược kim tự tháp hai chiều giao dịch cổ phiếu được thiết kế dựa trên chỉ số tương đối mạnh (RSI). Chiến lược này sử dụng chỉ số RSI để đánh giá khu vực mua quá mức và bán quá mức của cổ phiếu, kết hợp với nguyên tắc tăng giá kim tự tháp để đạt được lợi nhuận.
Chiến lược này kết hợp các chỉ số RSI với chiến lược đặt cược kim tự tháp, trong khi phán đoán quá mua quá bán, có thể thu được nhiều lợi nhuận hơn bằng cách đặt cược. Mặc dù độ chính xác của phán đoán RSI vẫn còn phải được cải thiện, nhưng chiến lược giao dịch có hiệu quả ổn định có thể được tạo ra bằng cách tối ưu hóa các tham số hợp lý, kết hợp với các chỉ số khác. Chiến lược này có một số tính phổ biến, là một phương pháp giao dịch định lượng tương đối đơn giản và trực tiếp.
/*backtest
start: 2023-12-30 00:00:00
end: 2024-01-29 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RafaelZioni
strategy(title='Simple RSI strategy', overlay=false)
SWperiod = 1
look = 0
OverBought = input(80, minval=50)
OverSold = input(25, maxval=50)
bandmx = hline(100)
bandmn = hline(0)
band1 = hline(OverBought)
band0 = hline(OverSold)
//band50 = hline(50, color=black, linewidth=1)
fill(band1, band0, color=color.purple, transp=98)
src = close
len = input(5, minval=1, title="RSI Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
p = 100
//scale
hh = highest(high, p)
ll = lowest(low, p)
scale = hh - ll
//dynamic OHLC
dyno = (open - ll) / scale * 100
dynl = (low - ll) / scale * 100
dynh = (high - ll) / scale * 100
dync = (close - ll) / scale * 100
//candle color
color_1 = close > open ? 1 : 0
//drawcandle
hline(78.6)
hline(61.8)
hline(50)
hline(38.2)
hline(23.6)
plotcandle(dyno, dynh, dynl, dync, title="Candle", color=color_1 == 1 ? color.green : color.red)
plot(10, color=color.green)
plot(55, color=color.black)
plot(80, color=color.black)
plot(90, color=color.red)
long = rsi <= OverSold ? 5 : na
//Strategy
golong = rsi <= OverSold ? 5 : na
longsignal = golong
//based on https://www.tradingview.com/script/7NNJ0sXB-Pyramiding-Entries-On-Early-Trends-by-Coinrule/
//set take profit
ProfitTarget_Percent = input(3)
Profit_Ticks = close * (ProfitTarget_Percent / 100) / syminfo.mintick
//set take profit
LossTarget_Percent = input(10)
Loss_Ticks = close * (LossTarget_Percent / 100) / syminfo.mintick
//Order Placing
strategy.entry("Entry 1", strategy.long, when=strategy.opentrades == 0 and longsignal)
strategy.entry("Entry 2", strategy.long, when=strategy.opentrades == 1 and longsignal)
strategy.entry("Entry 3", strategy.long, when=strategy.opentrades == 2 and longsignal)
strategy.entry("Entry 4", strategy.long, when=strategy.opentrades == 3 and longsignal)
strategy.entry("Entry 5", strategy.long, when=strategy.opentrades == 4 and longsignal)
strategy.entry("Entry 6", strategy.long, when=strategy.opentrades == 5 and longsignal)
strategy.entry("Entry 7", strategy.long, when=strategy.opentrades == 6 and longsignal)
if strategy.position_size > 0
strategy.exit(id="Exit 1", from_entry="Entry 1", profit=Profit_Ticks, loss=Loss_Ticks)
strategy.exit(id="Exit 2", from_entry="Entry 2", profit=Profit_Ticks, loss=Loss_Ticks)
strategy.exit(id="Exit 3", from_entry="Entry 3", profit=Profit_Ticks, loss=Loss_Ticks)
strategy.exit(id="Exit 4", from_entry="Entry 4", profit=Profit_Ticks, loss=Loss_Ticks)
strategy.exit(id="Exit 5", from_entry="Entry 5", profit=Profit_Ticks, loss=Loss_Ticks)
strategy.exit(id="Exit 6", from_entry="Entry 6", profit=Profit_Ticks, loss=Loss_Ticks)
strategy.exit(id="Exit 7", from_entry="Entry 7", profit=Profit_Ticks, loss=Loss_Ticks)