
Chiến lược này xác định xu hướng hiện tại bằng cách tính toán tỷ lệ chiều dài bóng dương của đường K, nhận dạng xu hướng bằng ATR với bước sóng thực trung bình, mở vị trí đảo ngược tại điểm phá vỡ, thiết lập điểm dừng lỗ và nắm bắt xu hướng ngắn hạn.
Chiến lược này chủ yếu bằng cách tính tỷ lệ chiều dài bóng dương của đường K, để xác định hướng xu hướng hiện tại, khi đường dương quá dài thì được đánh giá là xu hướng xuống, khi đường dương quá dài thì được đánh giá là xu hướng lên.
Chính sách này có thể được giải thích như sau:
Đây là logic giao dịch cơ bản của chiến lược, bằng cách xác định điểm phá vỡ xu hướng để mở vị trí đảo ngược và tối ưu hóa lợi nhuận sau khi thiết lập điểm dừng lỗ.
Có thể kiểm soát rủi ro bằng cách dừng lỗ hợp lý, tối ưu hóa các tham số và dừng lỗ kịp thời.
Các chiến lược có thể được tối ưu hóa theo các khía cạnh sau:
Các chiến lược có thể được tối đa hóa thông qua thử nghiệm và tối ưu hóa đa phương.
Nhìn chung, chiến lược này là một chiến lược phá vỡ đường ngắn có hiệu quả ổn định, bằng cách nhận ra xu hướng và kiểm soát rủi ro để kiếm lợi nhuận từ biến động giá trong thời gian ngắn.
/*backtest
start: 2022-11-08 00:00:00
end: 2023-11-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ondrej17
//@version=4
strategy("longWickstrategy", overlay=true )
// Inputs
st_yr_inp = input(defval=2020, title='Backtest Start Year')
st_mn_inp = input(defval=01, title='Backtest Start Month')
st_dy_inp = input(defval=01, title='Backtest Start Day')
en_yr_inp = input(defval=2025, title='Backtest End Year')
en_mn_inp = input(defval=01, title='Backtest End Month')
en_dy_inp = input(defval=01, title='Backtest End Day')
sltp_inp = input(defval=0.8, title='N - % offset for N*SL and (2N)*TP')/100
// Dates
start = timestamp(st_yr_inp, st_mn_inp, st_dy_inp,00,00)
end = timestamp(en_yr_inp, en_mn_inp, en_dy_inp,00,00)
canTrade = time >= start and time <= end
// Indicators Setup
// Strategy Calcuations
lowerWick = (open > close) ? close-low : open - low
upperWick = (open > close) ? high-open : high-close
wickLength = max(lowerWick,upperWick)
candleLength = high-low
wickToCandleRatio = wickLength / candleLength
entryFilterCandleLength = candleLength > 0.75*atr(48)
// Entries and Exits
longCondition = entryFilterCandleLength and wickToCandleRatio > 0.5 and lowerWick > upperWick and canTrade and strategy.position_size == 0
shortCondition = entryFilterCandleLength and wickToCandleRatio > 0.5 and lowerWick < upperWick and canTrade and strategy.position_size == 0
strategy.entry("pendingLong", strategy.long, limit=low+wickLength/2, when = longCondition)
strategy.entry("pendingShort", strategy.short, limit=high-wickLength/2, when = shortCondition)
longStop = strategy.position_size > 0 ? strategy.position_avg_price*(1-sltp_inp) : na
longTP = strategy.position_size > 0 ? strategy.position_avg_price*(1+2*sltp_inp) : na
shortStop = strategy.position_size < 0 ? strategy.position_avg_price*(1+sltp_inp) : na
shortTP = strategy.position_size < 0 ? strategy.position_avg_price*(1-2*sltp_inp) : na
strategy.exit("longSLTP","pendingLong", stop=longStop, limit = longTP)
strategy.exit("shortSLTP","pendingShort", stop=shortStop, limit = shortTP)
plot(longStop, color=color.red, style=plot.style_linebr, linewidth=2)
plot(shortStop, color=color.red, style=plot.style_linebr, linewidth=2)
plot(longTP, color=color.green, style=plot.style_linebr, linewidth=2)
plot(shortTP, color=color.green, style=plot.style_linebr, linewidth=2)
plotLongCondition = longCondition ? high+abs(open-close) : na
plot(plotLongCondition, style=plot.style_circles, linewidth=4, color=color.green)
plotShortCondition = shortCondition ? high+abs(open-close) : na
plot(plotShortCondition, style=plot.style_circles, linewidth=4, color=color.red)