Chiến lược đột phá xu hướng dựa trên MA thích nghi và đường xu hướng

Tác giả:ChaoZhang, Ngày: 2023-09-19 15:49:37
Tags:

Tổng quan

Chiến lược này sử dụng trung bình động thích nghi và đường xu hướng đột phá cho các mục nhập và RSI cho các mục tiêu thoát.

Chiến lược logic

  1. Tính toán MA thích nghi 99 giai đoạn để xác định xu hướng tổng thể.

  2. Tính toán mức cao địa phương 14 giai đoạn cho kháng cự đường xu hướng phía trên.

  3. Đi dài khi gần phá vỡ trên đường xu hướng và không có lệnh trong tháng này.

  4. Tính toán chỉ số RSI 14 giai đoạn và thoát tại chỉ số RSI trên 70 (được mua quá mức).

  5. Theo dõi tháng nhập cuối cùng để đảm bảo một giao dịch mỗi tháng.

Phân tích lợi thế

  1. MA thích nghi theo dõi động sự thay đổi xu hướng.

  2. Sự đột phá đường xu hướng cải thiện độ chính xác nhập cảnh.

  3. RSI đánh giá hiệu quả mức mua quá mức / bán quá mức để kiểm soát rủi ro.

  4. Một giao dịch mỗi tháng làm giảm tần suất và phí.

  5. Logic đơn giản và rõ ràng, dễ hiểu và thực hiện.

Phân tích rủi ro

  1. Các thông số không chính xác có thể gây ra các mục không ghi.

  2. Các chỉ số thoát cố định không thể thích nghi kịp thời với thị trường.

  3. Khả năng rút tiền.

  4. Không kiểm soát rủi ro trong thời gian giữ lâu.

  5. Quá nhiều bộ lọc có thể ngăn chặn các mục nhập.

Hướng dẫn tối ưu hóa

  1. Kiểm tra các thông số khác nhau cho các thiết lập tối ưu.

  2. Thêm các bộ lọc để cải thiện tính mạnh mẽ của chiến lược.

  3. Phát triển các chiến lược dừng lại năng động và kéo dài.

  4. Tối ưu hóa logic nhập để xác định những sự đột phá mạnh mẽ hơn.

  5. Kiểm tra các dụng cụ và khung thời gian phù hợp.

  6. Thêm bộ lọc xu hướng để tránh đột phá sai.

Tóm lại

Chiến lược này tích hợp phân tích xu hướng và dao động để có hiệu ứng theo xu hướng ổn định. Việc tối ưu hóa thêm các thông số, lối ra động vv có thể làm cho nó trở thành một hệ thống lượng tử đáng tin cậy.


/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-18 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Bannos Strategy', shorttitle='Bannos', overlay=true)

//The provided script is an indicator for TradingView written in Pine Script version 5. The indicator is used to determine entry and exit points for a trading strategy. Here's a detailed breakdown of what the script does:

// Strategy Definition:

// Bannos Strategy is the full name, with a short title Bannos.
// The overlay=true option indicates that the strategy will be overlayed on the price chart.
// Tracking Entry Month:

// A variable lastEntryMonth is set up to track the month of the last entry.
// currentMonth identifies the current month.
// Trend Regularity Adaptive Moving Average (TRAMA):

// It takes an input of length 99 as default.
// It uses adaptive calculations to track trend changes.
// Trendlines with Breaks:

// Identifies local peaks over a given period (in this case, 14) and calculates a slope based on these peaks.
// Relative Strength Index (RSI):

// Uses a length of 14 (default) to calculate the RSI.
// RSI is an oscillation indicator that indicates overbought or oversold conditions.
// Strategy Logic for Long Entry:

// A long position is opened if:
// The close price is above the TRAMA.
// There's a crossover of the close price and the upper trendline.
// The position is taken only once per month.
// Strategy Logic for Long Exit:

// The long position is closed if the RSI exceeds 70, indicating an overbought condition.
// Plotting:

// The TRAMA is plotted in red on the chart.
// A horizontal line is also drawn at 70 to indicate the RSI's overbought zone.
// In summary, this strategy aims to enter a long position when certain trend and crossover conditions are met, and close the position when the market is considered overbought as per the RSI. Additionally, it ensures entries only occur once a month.
//



// Variable pour suivre le mois de la dernière entrée
var float lastEntryMonth = na
currentMonth = month(time)

// Parameters for Trend Regularity Adaptive Moving Average (TRAMA)
length_trama = input(99)
src_trama = close
ama = 0.
hh = math.max(math.sign(ta.change(ta.highest(length_trama))), 0)
ll = math.max(math.sign(ta.change(ta.lowest(length_trama)) * -1), 0)
tc = math.pow(ta.sma(hh or ll ? 1 : 0, length_trama), 2)
ama := nz(ama[1] + tc * (src_trama - ama[1]), src_trama)

// Parameters for Trendlines with Breaks
length_trend = 14
mult = 1.0
ph = ta.pivothigh(length_trend, length_trend)
upper = 0.
slope_ph = 0.
slope_ph := ph ? mult : slope_ph
upper := ph ? ph : upper - slope_ph

// Parameters for RSI
rsiLength = 14
up = ta.rma(math.max(ta.change(close), 0), rsiLength)
down = ta.rma(-math.min(ta.change(close), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

// Strategy Logic for Long Entry
longCondition = close > ama and ta.crossover(close, upper) and (na(lastEntryMonth) or lastEntryMonth != currentMonth)
if (longCondition)
    lastEntryMonth := currentMonth
    strategy.entry('Long', strategy.long)

// Strategy Logic for Long Exit
exitCondition = rsi > 70
if (exitCondition)
    strategy.close('Long')

// Plotting
plot(ama, 'TRAMA', color=color.red)
hline(70, 'Overbought', color=color.red)


Thêm nữa