
Chiến lược này dựa trên sự di chuyển của các đường K liên tiếp, để đánh giá xem có mở vị trí bằng cách so sánh giá đóng cửa hiện tại với giá đóng cửa của ba đường K trước đó. Khi ba đường K liên tiếp tăng cao, mở vị trí nhiều đầu, ngược lại là bán. Đồng thời, chiến lược này sử dụng phương pháp dừng động, xác định điểm dừng dựa trên giá mở vị trí và phần trăm dừng lỗ được thiết lập.
Chiến lược này được sử dụng để đưa ra quyết định mở lỗ bằng cách đánh giá xu hướng của các đường K liên tục, đồng thời sử dụng phương pháp dừng lỗ động để kiểm soát rủi ro. Lập luận của chiến lược rõ ràng, dễ hiểu và thực hiện, áp dụng cho nhiều thị trường và giống. Tuy nhiên, trong ứng dụng thực tế, cần chú ý đến rủi ro không theo xu hướng của thị trường và tối ưu hóa các tham số như tỷ lệ dừng lỗ. Ngoài ra, việc giới thiệu nhiều chỉ số kỹ thuật, quản lý vị trí và các phương pháp khác có thể tiếp tục nâng cao hiệu suất chiến lược.
/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("4 Candle Entry and Exit Strategy", overlay=true)
// Define the stop loss percentage
stopLossPercent = input.float(11, title="Stop Loss Percentage", minval=0.1) / 100
// Identify if the previous 3 candles are consecutively higher
longCondition = close[3] > close[4] and close[2] > close[3] and close[1] > close[2]
// Identify if the previous 3 candles are consecutively lower
exitCondition = close[3] < close[4] and close[2] < close[3] and close[1] < close[2]
// Initialize the entry price and stop loss variables
var float entryPrice = na
var float stopLoss = na
// Update the entry price and stop loss if the long condition is met
if (longCondition)
entryPrice := close[1]
stopLoss := entryPrice * (1 - stopLossPercent)
// Enter the long position at the open of the 4th candle
if (longCondition)
strategy.entry("Long", strategy.long, qty=1)
// Exit the position if exit condition is met or stop loss is hit
if (exitCondition or (strategy.position_size > 0 and low <= stopLoss))
strategy.close("Long")
// Optional: Plot the entry and exit signals on the chart
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=exitCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")