
Chiến lược này là một chiến lược theo dõi xu hướng và đảo ngược giao dịch dựa trên đường trung bình di chuyển đơn giản. Nó sử dụng đường trung bình giao nhau của đường 1 và đường 4 để xác định hướng xu hướng và tạo ra tín hiệu mua và bán.
Khi đường 1 ngày đi từ trên xuống, nó sẽ tạo ra tín hiệu bán; và khi đường 1 ngày đi từ dưới xuống, nó sẽ tạo ra tín hiệu mua. Bằng cách này, bạn có thể đánh giá điểm biến của xu hướng thị trường bằng cách giao thoa giữa đường trung bình di chuyển nhanh và đường trung bình di chuyển chậm.
Thiết lập điểm dừng lỗ và điểm dừng bán sau khi đưa ra thị trường. Cài đặt điểm dừng lỗ là 10 điểm dưới giá mua và điểm dừng là 100 điểm trên giá mua. Điều này có thể hạn chế tổn thất và khóa lợi nhuận.
Các rủi ro này có thể được giảm bằng cách điều chỉnh tham số đường trung bình, thiết lập cơ chế dừng lỗ động hoặc thêm các phán đoán chỉ số khác.
Chiến lược này nói chung là một chiến lược giao dịch song song song song song điển hình. Nó sử dụng các điểm chuyển đổi xu hướng đánh giá chéo đường trung bình nhanh và chậm, thiết lập rủi ro kiểm soát dừng lỗ, đơn giản, thực tế, dễ hiểu, phù hợp với người mới bắt đầu.
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © cesarpieres72
//@version=5
strategy("300% STRATEGY", overlay=true, margin_long=10, margin_short=10)
var float lastLongOrderPrice = na
var float lastShortOrderPrice = na
longCondition = ta.crossover(ta.sma(close, 1), ta.sma(close, 4))
if (longCondition)
strategy.entry("Long Entry", strategy.long) // Enter long
shortCondition = ta.crossunder(ta.sma(close, 1), ta.sma(close, 4))
if (shortCondition)
strategy.entry("Short Entry", strategy.short) // Enter short
if (longCondition)
lastLongOrderPrice := close
if (shortCondition)
lastShortOrderPrice := close
// Calculate stop loss and take profit based on the last executed order's price
stopLossLong = lastLongOrderPrice - 170 // 10 USDT lower than the last long order price
takeProfitLong = lastLongOrderPrice + 150 // 100 USDT higher than the last long order price
stopLossShort = lastShortOrderPrice + 170 // 10 USDT higher than the last short order price
takeProfitShort = lastShortOrderPrice - 150 // 100 USDT lower than the last short order price
// Apply stop loss and take profit to long positions
strategy.exit("Long Exit", from_entry="Long Entry", stop=stopLossLong, limit=takeProfitLong)
// Apply stop loss and take profit to short positions
strategy.exit("Short Exit", from_entry="Short Entry", stop=stopLossShort, limit=takeProfitShort)