Chiến lược đột phá theo xu hướng EMA


Ngày tạo: 2024-01-12 14:23:11 sửa đổi lần cuối: 2024-01-12 14:23:11
sao chép: 0 Số nhấp chuột: 620
1
tập trung vào
1617
Người theo dõi

Chiến lược đột phá theo xu hướng EMA

Tổng quan

Chiến lược này là một chiến lược phá vỡ theo dõi xu hướng dựa trên đường trung bình di chuyển chỉ số ((EMA)). Nó đánh giá hướng xu hướng trên khung thời gian đường trăng, đường tuần và đường mặt trời và thực hiện các thao tác nhập và thoát cụ thể trên đường mặt trời.

Nguyên tắc chiến lược

Xác định xu hướng

  1. Trên đường mặt trăng, giá cao hơn EMA ngày 8 và EMA ngày 8 cao hơn EMA ngày 21, được coi là xu hướng đa đầu;
  2. Trên đường tuần, giá cao hơn EMA ngày 8 và EMA ngày 8 cao hơn EMA ngày 21, được coi là xu hướng đa đầu;
  3. Trên đường nắng, giá cao hơn 8 ngày EMA, 8 ngày EMA cao hơn 21 ngày EMA, được đánh giá là xu hướng đa đầu;

Kích hiệu vào cửa

  1. Trong khi đó, các nhà đầu tư khác cũng có xu hướng giảm giá, trong khi các nhà đầu tư khác có xu hướng giảm giá, trong khi các nhà đầu tư có xu hướng giảm giá.
  2. Phản hồi tạo thành hình dạng Ring Low của Lower High và Lower Low;
  3. Giá đóng cửa cao hơn mức giá cao nhất của ngày trước là tín hiệu đảo ngược xu hướng;

Tín hiệu xuất phát

Thiết lập tiêu chuẩn Stop Loss để đạt được kết quả.

Phân tích lợi thế

  1. Cải thiện tính chính xác trong việc đánh giá xu hướng trong ba khung thời gian;
  2. Điểm thấp của sự hồi phục chạm vào sự hỗ trợ của EMA, tăng sự chắc chắn về sự tham gia;
  3. Theo dõi xu hướng và tiềm năng kiếm tiền.

Phân tích rủi ro

  1. Sự khác biệt giữa ba khung thời gian có thể dẫn đến tín hiệu sai;
  2. Một số người cho rằng điều này có thể gây ra một sự suy giảm đáng kể trong giá trị tài chính.
  3. Thị trường có thể bị phá vỡ bởi các đợt phá vỡ;

Hướng tối ưu hóa

  1. Thêm các chỉ số hỗ trợ như MACD, RSI;
  2. Tối ưu hóa các thiết lập tham số EMA;
  3. Điều chỉnh stop loss cùng với chỉ số biến động;

Tóm tắt

Chiến lược này nói chung là một chiến lược theo dõi xu hướng, tiềm năng lợi nhuận rất tốt khi đánh giá đúng xu hướng. Cần chú ý để ngăn chặn việc đánh giá xu hướng sai và điều chỉnh quá mức để tạo ra tín hiệu sai. Đồng thời, việc tối ưu hóa cài đặt dừng lỗ cũng là chìa khóa để tăng thêm lợi thế của chiến lược.

Mã nguồn chiến lược
/*backtest
start: 2023-01-11 00:00:00
end: 2024-01-11 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/
// © the_daily_trader

//@version=5
// ---------------------        Start of Code        ---------------------
strategy("Swing Trades Validator", overlay=true, margin_long=100, pyramiding = 0)

// Indicator Display Checks
TakeProfitPercent       = input.float(title="Profit Target %", defval=10, minval=1, step=0.05)
StopLossPercent         = input.float(title="Stop Loss %", defval=10, minval=1, step=0.05)
pullbackchoice          = input.bool(false, "Relaxed Entry Rules")

// EMAs
emaH            = ta.ema(close, 8)
emaHyest        = ta.ema(close[1], 8)
emaHyest1       = ta.ema(close[2], 8)
emaHyest2       = ta.ema(close[3], 8)
emaL            = ta.ema(close, 21)
emaLyest        = ta.ema(close[1], 21)
emaLyest1       = ta.ema(close[2], 21)
emaLyest2       = ta.ema(close[3], 21)
emaf            = ta.ema(close, 50)
emath           = ta.ema(close, 200)
emathhigh       = ta.ema(high, 200)
emathlow        = ta.ema(low, 200)
emaslowmonthly  = request.security(syminfo.tickerid, "M", emaL) // Monthly 21ema
emafastmonthly  = request.security(syminfo.tickerid, "M", emaH) // Monthly 8ema
emaslowweekly   = request.security(syminfo.tickerid, "W", emaL) // Weekly 21ema
emafastweekly   = request.security(syminfo.tickerid, "W", emaH) // Weekly 8ema
emaslowdaily    = request.security(syminfo.tickerid, "D", emaL) // Daily 21ema
emafastdaily    = request.security(syminfo.tickerid, "D", emaH) // Daily 8ema
emafdaily       = request.security(syminfo.tickerid, "D", emaf) // Daily 50ema
emathdaily      = request.security(syminfo.tickerid, "D", emath) // Daily ema
emathdailyhigh  = request.security(syminfo.tickerid, "D", emathhigh) // Daily ema High
emathdailylow   = request.security(syminfo.tickerid, "D", emathlow) // Daily ema Low
ema21yest       = request.security(syminfo.tickerid, "D", emaLyest) // Daily 21ema 1 day ago
ema21yest1      = request.security(syminfo.tickerid, "D", emaLyest1) // Daily 21ema 2 days ago
ema21yest2      = request.security(syminfo.tickerid, "D", emaLyest2) // Daily 21ema 3 days ago
ema8yest        = request.security(syminfo.tickerid, "D", emaHyest) // Daily 8ema 1 day ago
ema8yest1       = request.security(syminfo.tickerid, "D", emaHyest1) // Daily 8ema 2 days ago
ema8yest2       = request.security(syminfo.tickerid, "D", emaHyest2) // Daily 8ema 3 days ago


// Prices
monthopen       = request.security(syminfo.tickerid, 'M', open, barmerge.gaps_off, barmerge.lookahead_on)
monthclose      = request.security(syminfo.tickerid, 'M', close, barmerge.gaps_off, barmerge.lookahead_on)
weekopen        = request.security(syminfo.tickerid, 'W', open, barmerge.gaps_off, barmerge.lookahead_on)
weekclose       = request.security(syminfo.tickerid, 'W', close, barmerge.gaps_off, barmerge.lookahead_on)
dayopen         = request.security(syminfo.tickerid, 'D', open, barmerge.gaps_off, barmerge.lookahead_on)
dayclose        = request.security(syminfo.tickerid, 'D', close, barmerge.gaps_off, barmerge.lookahead_on)
threedayhigh    = request.security(syminfo.tickerid, 'D', high[3], barmerge.gaps_off, barmerge.lookahead_on)
twodayhigh      = request.security(syminfo.tickerid, 'D', high[2], barmerge.gaps_off, barmerge.lookahead_on)
yesthigh        = request.security(syminfo.tickerid, 'D', high[1], barmerge.gaps_off, barmerge.lookahead_on)
yestlow         = request.security(syminfo.tickerid, 'D', low[1], barmerge.gaps_off, barmerge.lookahead_on)

// Conditions 
monthlybullish          = emafastmonthly > emaslowmonthly
monthlybullishprice     = close > emafastmonthly
monthlybullishcandle    = monthclose > monthopen
weeklybullish           = emafastweekly > emaslowweekly
weeklybullishprice      = close > emafastweekly
weeklybullishcandle     = weekclose > weekopen
dailybullish1           = emafdaily > emathdaily
dailybullish2           = emafastdaily > emaslowdaily
dailybullishprice       = close > emafastdaily
dailybullishcandle      = dayclose > dayopen
ringlow                 = yestlow <= ema8yest
aggropullback           = twodayhigh < threedayhigh
pullback                = (pullbackchoice ? aggropullback : 0)
pullbackfailure         = dayclose > yesthigh and yesthigh < twodayhigh or pullback
emasetup                = ema8yest > ema21yest and ema8yest1 > ema21yest1 and ema8yest2 > ema21yest2

// Target Profit and Stop Loss Inputs
// Input parameters can be found at the beginning of the code
ProfitTarget        = (close * (TakeProfitPercent / 100)) / syminfo.mintick
StopLoss            = (close * (StopLossPercent / 100)) / syminfo.mintick

longCondition = monthlybullish and monthlybullishprice and weeklybullish and weeklybullishprice and dailybullish1 and dailybullish2 and dailybullishprice and monthlybullishcandle and weeklybullishcandle and dailybullishcandle and ringlow and pullbackfailure and emasetup

if (longCondition)
    strategy.entry("Long", strategy.long)
    strategy.exit ("Exit", "Long", profit = ProfitTarget, loss = StopLoss)
    // strategy.close("Long", qty_percent = 100)


// -----------xxxxxxxxxxx-------------    End of Code     -----------xxxxxxxxxxx---------------