Chiến lược đột phá biến động khối lượng mua/bán động


Ngày tạo: 2023-12-26 11:15:31 sửa đổi lần cuối: 2023-12-26 11:15:31
sao chép: 0 Số nhấp chuột: 634
1
tập trung vào
1623
Người theo dõi

Chiến lược đột phá biến động khối lượng mua/bán động

Tổng quan

Chiến lược này sử dụng phán đoán không gian bằng cách mua và bán khối lượng theo chu kỳ thời gian tùy chỉnh, kết hợp với đường viền VWAP, lọc và theo dõi xu hướng có xác suất cao. Đồng thời giới thiệu cơ chế dừng lỗ động, có thể kiểm soát hiệu quả rủi ro đơn phương.

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

  1. Tính toán chỉ số mua bán trong khoảng thời gian tùy chỉnh
  • BV: Số lượng mua, số lượng được tạo ra thông qua mua thấp
  • SV: Số lượng bán ra, số lượng được tạo ra từ việc bán ra điểm cao nhất
  1. Xử lý số lượng mua bán
  • Sử dụng 20 chu kỳ EMA để làm mịn
  • Phân tích tích cực của khối lượng mua bán sau khi xử lý
  1. Xác định định hướng của chỉ số
  • Chỉ số lớn hơn 0 là tăng, nhỏ hơn 0 là giảm
  1. VWAP, Brin và Phán quyết Phản Lệ
  • Giá trên VWAP và chỉ số cho thấy nhiều tín hiệu
  • Giá thấp hơn VWAP và chỉ số giảm xuống là tín hiệu giảm giá
  1. Động lực dừng dừng
  • % Stop Loss theo ATR thiết lập hàng ngày

Lợi thế chiến lược

  1. Số lượng mua bán có thể phản ánh động lực thực sự của thị trường, nắm bắt năng lượng tiềm ẩn của xu hướng
  2. Đường tròn VWAP để xác định hướng xu hướng chu kỳ lớn, băng Brin để xác định tín hiệu đột phá
  3. Động thái ATR thiết lập dừng lỗ, có thể tối đa khóa lợi nhuận, tránh quá mức

Rủi ro chiến lược

  1. Dữ liệu mua bán có một số sai sót, có thể dẫn đến sai lầm
  2. Một chỉ số duy nhất có thể tạo ra tín hiệu sai lệch
  3. Thiết lập không chính xác của Parameter Brinh sẽ làm giảm đột phá hiệu quả

Hướng tối ưu hóa chiến lược

  1. Các chỉ số mua bán theo chu kỳ thời gian được tối ưu hóa
  2. Chuẩn bị các chỉ số phụ trợ như tăng khối lượng giao dịch
  3. Hoạt động điều chỉnh Brinh Parameter để cải thiện hiệu quả đột phá

Tóm tắt

Chiến lược này tận dụng đầy đủ khả năng dự đoán số lượng mua và bán, hỗ trợ tạo ra tín hiệu xác suất cao với VWAP và Brin, kiểm soát rủi ro hiệu quả thông qua dừng dừng động động, là một chiến lược giao dịch định lượng hiệu quả và ổn định. Với các tham số và quy tắc được tối ưu hóa liên tục, hiệu quả dự kiến sẽ rõ ràng hơn.

Mã nguồn chiến lược
/*backtest
start: 2022-12-19 00:00:00
end: 2023-12-25 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/
// © original author ceyhun
//@ exlux99 update

//@version=5
strategy('Buying Selling Volume Strategy', format=format.volume, precision=0, overlay=false)

weekly_vwap = request.security(syminfo.tickerid, "W", ta.vwap(hlc3))

vi = false
customTimeframe = input.timeframe("60", group="Entry Settings")

allow_long = input.bool(true, group="Entry Settings")
allow_short = input.bool(false, group="Entry Settings")

xVolume = request.security(syminfo.tickerid, customTimeframe, volume)
xHigh = request.security(syminfo.tickerid, customTimeframe, high)
xLow = request.security(syminfo.tickerid, customTimeframe, low)
xClose = request.security(syminfo.tickerid, customTimeframe, close)

BV = xHigh == xLow ? 0 : xVolume * (xClose - xLow) / (xHigh - xLow)
SV = xHigh == xLow ? 0 : xVolume * (xHigh - xClose) / (xHigh - xLow)

vol = xVolume > 0 ? xVolume : 1
TP = BV + SV
BPV = BV / TP * vol
SPV = SV / TP * vol
TPV = BPV + SPV

tavol20 = request.security(syminfo.tickerid, customTimeframe, ta.ema(vol, 20))
tabv20= request.security(syminfo.tickerid, customTimeframe, ta.ema(BV, 20))
tasv20= request.security(syminfo.tickerid, customTimeframe, ta.ema(SV, 20))
VN = vol / tavol20
BPN = BV / tabv20 * VN * 100
SPN = SV / tasv20 * VN * 100
TPN = BPN + SPN

xbvp = request.security(syminfo.tickerid, customTimeframe,-math.abs(BPV))
xbpn = request.security(syminfo.tickerid, customTimeframe,-math.abs(BPN))
xspv = request.security(syminfo.tickerid, customTimeframe,-math.abs(SPV))
xspn = request.security(syminfo.tickerid, customTimeframe,-math.abs(SPN))

BPc1 = BPV > SPV ? BPV : xbvp
BPc2 = BPN > SPN ? BPN : xbpn
SPc1 = SPV > BPV ? SPV : xspv
SPc2 = SPN > BPN ? SPN : xspn
BPcon = vi ? BPc2 : BPc1
SPcon = vi ? SPc2 : SPc1


minus = BPcon + SPcon
plot(minus, color = BPcon > SPcon  ? color.green : color.red , style=plot.style_columns) 

length = input.int(20, minval=1, group="Volatility Settings")
src = minus//input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev", group="Volatility Settings")
xtasma = request.security(syminfo.tickerid, customTimeframe, ta.sma(src, length))
xstdev = request.security(syminfo.tickerid, customTimeframe, ta.stdev(src, length))
basis = xtasma
dev = mult * xstdev
upper = basis + dev
lower = basis - dev
plot(basis, "Basis", color=#FF6D00, offset = 0)
p1 = plot(upper, "Upper", color=#2962FF, offset = 0)
p2 = plot(lower, "Lower", color=#2962FF, offset = 0)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))

// Original a
longOriginal = minus > upper and BPcon > SPcon and close > weekly_vwap
shortOriginal = minus > upper and BPcon < SPcon and close< weekly_vwap



high_daily = request.security(syminfo.tickerid, "D", high)
low_daily  = request.security(syminfo.tickerid, "D", low)
close_daily = request.security(syminfo.tickerid, "D", close)

true_range = math.max(high_daily - low_daily, math.abs(high_daily - close_daily[1]), math.abs(low_daily - close_daily[1]))
atr_range = ta.sma(true_range*100/request.security(syminfo.tickerid, "D", close), 14)

ProfitTarget_Percent_long = input.float(100.0, title='TP Multiplier for Long entries ', step=0.5, step=0.5, group='Dynamic Risk Management')
Profit_Ticks_long = close + (close * (atr_range * ProfitTarget_Percent_long))/100
LossTarget_Percent_long = input.float(1.0, title='SL Multiplier for Long entries', step=0.5, group='Dynamic Risk Management')
Loss_Ticks_long = close - (close * (atr_range * LossTarget_Percent_long ))/100

ProfitTarget_Percent_short = input.float(100.0, title='TP Multiplier for Short entries ', step=0.5, step=0.5, group='Dynamic Risk Management')
Profit_Ticks_short = close - (close * (atr_range*ProfitTarget_Percent_short))/100
LossTarget_Percent_short = input.float(5.0, title='SL Multiplier for Short entries', step=0.5, group='Dynamic Risk Management')
Loss_Ticks_short = close + (close * (atr_range*LossTarget_Percent_short))/100



var longOpened_original = false
var int timeOfBuyLong = na
var float tpLong_long_original = na
var float slLong_long_original = na
long_entryx = longOriginal

longEntry_original = long_entryx and not longOpened_original 


if longEntry_original
    longOpened_original := true
    tpLong_long_original := Profit_Ticks_long
    slLong_long_original := Loss_Ticks_long
    timeOfBuyLong := time
    //lowest_low_var_sl := lowest_low

     
tpLong_trigger = longOpened_original[1] and ((close > tpLong_long_original) or (high > tpLong_long_original)) //or high > lowest_low_var_tp
slLong_Trigger = longOpened_original[1] and ((close < slLong_long_original) or (low < slLong_long_original)) //or low < lowest_low_var_sl

longExitSignal_original =   shortOriginal or tpLong_trigger or slLong_Trigger 


if(longExitSignal_original)
    longOpened_original := false
    tpLong_long_original := na
    slLong_long_original := na


if(allow_long)
    strategy.entry("long", strategy.long, when=longOriginal) 
    strategy.close("long", when= longExitSignal_original) //or shortNew

if(allow_short)
    strategy.entry("short", strategy.short, when=shortOriginal ) 
    strategy.close("short", when= longOriginal) //or shortNew