Hệ thống điểm xoay dao động xu hướng


Ngày tạo: 2023-10-23 17:18:28 sửa đổi lần cuối: 2023-10-23 17:18:28
sao chép: 0 Số nhấp chuột: 744
1
tập trung vào
1617
Người theo dõi

Hệ thống điểm xoay dao động xu hướng

Tổng quan

Hệ thống điểm biến động xu hướng là một chiến lược theo dõi xu hướng sử dụng đường trung bình di chuyển, chỉ số CCI và chỉ số xu hướng siêu để xác định xu hướng, tham gia vào khi rút lui. Nó có thể xác nhận hướng của xu hướng và cung cấp tín hiệu tham gia khi rút lui.

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

Chiến lược này sử dụng EMA 21 chu kỳ làm trung bình di chuyển ngắn hạn và EMA 55 chu kỳ làm trung bình di chuyển dài hạn. EMA 21 ngày trên EMA 55 ngày cho thấy hiện đang trong xu hướng tăng và EMA 21 ngày dưới EMA 55 ngày cho thấy hiện đang trong xu hướng giảm.

Chỉ số CCI có thể cho thấy giá đã đạt đến mức cực đoan. Khi CCI đạt 100 hoặc -100 mặc định, đó là tín hiệu cấp một, 140/-140 là tín hiệu cấp hai, 180/-180 là tín hiệu cấp ba. Điều này cho thấy hiện tại có thể đang ở trạng thái quá mua hoặc quá bán.

Chỉ số siêu xu hướng có thể xác định hướng của xu hướng cụ thể. Nó kết hợp với độ dao động thực tế trung bình để xác định điểm dừng và điểm vào của xu hướng tăng và xu hướng giảm.

Khi xuất hiện ngày 21 EMA trên 55 EMA, và CCI đạt mức thấp, bạn có thể tham gia nhiều hơn. Khi xuất hiện ngày 21 EMA dưới 55 EMA, và CCI đạt mức cao, bạn có thể tham gia bằng không.

Phân tích lợi thế

Chiến lược này kết hợp nhiều chỉ số để đánh giá xu hướng và quá mua quá bán, có thể lọc hiệu quả các vụ phá vỡ giả. Sử dụng các điểm dừng cố định có thể đạt được tỷ lệ lợi nhuận rủi ro ổn định. Theo xu hướng giao dịch có thể đạt được tỷ lệ thắng cao hơn. Sử dụng tín hiệu quá mua quá bán của chỉ số CCI, có thể có cơ hội vào sàn tốt hơn trong giai đoạn biến động xu hướng.

Phân tích rủi ro

Chiến lược này cần được tối ưu hóa đối với các tham số thương mại, các thiết lập tham số khác nhau sẽ ảnh hưởng đến hiệu quả của chiến lược. Cài đặt dừng lỗ khá thô, không thể điều chỉnh cho các thị trường khác nhau.

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

Bạn có thể kiểm tra các thiết lập tham số của các loại giao dịch khác nhau, tối ưu hóa các tham số như chu kỳ trung bình di chuyển, chu kỳ ATR, nhân ATR. Bạn có thể xem xét thay đổi dừng lỗ thành dừng ATR hoặc trailing stop để thích ứng với biến động của thị trường. Bạn có thể kiểm tra thay đổi dừng dừng thành dừng biến động, thiết lập lợi nhuận mục tiêu dựa trên giá trị ATR.

Tóm tắt

Hệ thống điểm xoay chuyển xu hướng kết hợp các đường trung bình di chuyển, chỉ số CCI và siêu xu hướng để xác định hướng xu hướng và trường hợp bán tháo để tham gia vào khi xu hướng đảo ngược. Nó có độ ổn định và tỷ lệ thắng cao hơn, nhưng cần tối ưu hóa thêm các cơ chế đánh giá dừng lỗ, dừng và xu hướng để các tham số chiến lược có thể thích ứng với các giống và môi trường thị trường khác nhau.

Mã nguồn chiến lược
/*backtest
start: 2022-10-16 00:00:00
end: 2023-01-08 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/
// © greenmask9

//@version=4
strategy("Oath", overlay=true)

// 21 EMA
emalength = input(21, title="Short EMA")
emashort = ema(close, emalength)

// 55 EMA
emalength2 = input(55, title="Long EMA")
ema = ema(close, emalength2)

//CCI calculation and inputs
lengthcci = input(20, minval=1, title="Overbought/sold detector period")
src = input(close, title="Overbought/sold detector source")
ma = sma(src, lengthcci)
ccivalue = (src - ma) / (0.015 * dev(src, lengthcci))


//CCI plotting
ccioverbought = input(defval=100, title="Overbought level 1")
ccioverbought2 = input(defval=140, title="Overbought level 2")
ccioverbought3 = input(defval=180, title="Overbought level 3")

ccioversold = input(defval=-100, title="Oversold level 1")
ccioversold2 = input(defval=-140, title="Oversold level 2")
ccioversold3 = input(defval=-180, title="Oversold level 3")

//cciOB = (ccivalue >= ccioverbought and ccivalue < ccioverbought2)
//cciOS = (ccivalue <= ccioversold and ccivalue > ccioversold2)

//cciOB2 = (ccivalue >= ccioverbought2 and ccivalue < ccioverbought3)
//cciOS2 = (ccivalue <= ccioversold and ccivalue > ccioversold3)

//cciOB3 = (ccivalue >= ccioverbought3)
//cciOS3 = (ccivalue <= ccioversold3)

//Supertrend

length = input(title="ATR Period", type=input.integer, defval=55)
mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=5.0)
wicks = input(title="Take Wicks into Account ?", type=input.bool, defval=true)
illuminate = input(title="Illuminate Trend", type=input.bool, defval=false)

atr = mult * atr(length)

longStop = hl2 - atr
longStopPrev = nz(longStop[1], longStop)
longStop := (wicks ? low[1] : close[1]) > longStopPrev ? max(longStop, longStopPrev) : longStop

shortStop = hl2 + atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := (wicks ? high[1] : close[1]) < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop

dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and (wicks ? high : close) > shortStopPrev ? 1 : dir == 1 and (wicks ? low : close) < longStopPrev ? -1 : dir

//entries
uptrend = emashort>ema and dir == 1
upsignal = ccivalue<=ccioversold and ccivalue>ccioversold2
upsignal2 = ccivalue<=ccioversold2 and ccivalue>ccioversold3
upsignal3 = ccivalue<=ccioversold3
downtrend = emashort<ema and dir == -1
downsignal = ccivalue>=ccioverbought and ccivalue<ccioverbought2
downsignal2 = ccivalue>=ccioverbought2 and ccivalue<ccioverbought3
downsignal3 = ccivalue>=ccioverbought3

//adapts to the current bar, I need to save the bars number when the condition for buy was true, static number is spread
spread = input (0.00020, title="Spread")
upstoploss = longStop - spread
downstoploss = shortStop + spread
strategy.initial_capital = 50000
ordersize=floor(strategy.initial_capital/close)
testlong = input(title="Test longs", type=input.bool, defval=true)
testshort = input(title="Test shorts", type=input.bool, defval=true)
//new
degree = input(title="Test level 1 overbought/sold levels", type=input.bool, defval=true)
degree2 = input(title="Test level 2 overbought/sold levels", type=input.bool, defval=false)
degree3 = input(title="Test level 3 overbought/sold levels", type=input.bool, defval=false)

statictarget = input(title="Use static target", type=input.bool, defval=true)
statictargetvalue = input(title="Static target in pips", type=input.integer, defval=400)

//timetrade = input(title="Open trades only withing specified time", type=input.bool, defval=true)
//timtrade = input()

//přidat možnost TP podle ATR a sl podle ATR
buy1 = uptrend and upsignal and strategy.opentrades==0 and testlong and degree
x1 = barssince (buy1)
if (buy1)
//bodlo by zakázat atrtarget v tomto případě
    if (statictarget)
        strategy.entry("Oath1", strategy.long, ordersize)
        strategy.exit( "Oath1 Close", from_entry="Oath1" , profit=statictargetvalue,stop=upstoploss[x1])
 
buy2 = uptrend and upsignal2 and strategy.opentrades==0 and testlong and degree2
x2 = barssince (buy2)
if (buy2)
//bodlo by zakázat atrtarget v tomto případě
    if (statictarget)
        strategy.entry("Oath2", strategy.long, ordersize)
        strategy.exit( "Oath2 Close", from_entry="Oath2" , profit=statictargetvalue,stop=upstoploss[x2])
  
buy3 = uptrend and upsignal3 and strategy.opentrades==0 and testlong and degree3
x3 = barssince (buy3)
if (buy3)
//bodlo by zakázat atrtarget v tomto případě
    if (statictarget)
        strategy.entry("Oath3", strategy.long, ordersize)
        strategy.exit( "Oath3 Close", from_entry="Oath3" , profit=statictargetvalue,stop=upstoploss[x3])

sell1 = downtrend and downsignal and strategy.opentrades==0 and testshort and degree
y1 = barssince (sell1)
if (sell1)
    if (statictarget)
        strategy.entry("Oath1.s", strategy.short, ordersize)
        strategy.exit( "Oath1 Close", from_entry="Oath1.s" , profit=statictargetvalue,stop=downstoploss[y1])

sell2 = downtrend and downsignal2 and strategy.opentrades==0 and testshort and degree2
y2 = barssince (sell2)
if (sell2)
    if (statictarget)
        strategy.entry("Oath2.s", strategy.short, ordersize)
        strategy.exit( "Oath2 Close", from_entry="Oath2.s" , profit=statictargetvalue,stop=downstoploss[y2])

sell3 = downtrend and downsignal3 and strategy.opentrades==0 and testshort and degree3
y3 = barssince (sell3)
if (sell3)
    if (statictarget)
        strategy.entry("Oath3.s", strategy.short, ordersize)
        strategy.exit( "Oath3 Close", from_entry="Oath3.s" , profit=statictargetvalue,stop=downstoploss[y3])

plotshape(uptrend and upsignal and degree, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up")
plotshape(downtrend and downsignal and degree, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down")
plotshape(uptrend and upsignal2 and degree2, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up+")
plotshape(downtrend and downsignal2 and degree2, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down+")
plotshape(uptrend and upsignal3 and degree3, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up++")
plotshape(downtrend and downsignal3 and degree3, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down++")