Chiến lược này kết hợp EMA và chỉ số khối lượng giao dịch tích lũy để đánh giá xu hướng thị trường dựa trên sự giao thoa của cả hai, tạo ra tín hiệu mua và bán. Đây là một chiến lược theo dõi xu hướng điển hình, theo dõi hướng thị trường ở cấp độ dài hơn.
Tính trung bình 50 ngày EMA, và 100 ngày tích lũy giao dịch. Khi EMA từ dưới lên vượt qua tích lũy giao dịch, nó tạo ra tín hiệu mua nhiều hơn; khi EMA từ trên xuống xuống vượt qua tích lũy giao dịch, nó tạo ra tín hiệu bán.
Trong quá trình giữ vị trí, thiết lập dừng cố định và dừng exiting Chiến lược. Hết lỗ được thiết lập dưới 8% giá vào; dừng được thiết lập trên 8% giá vào và bán một phần vị trí khi giá chạm điểm dừng.
Chiến lược này kết hợp với chỉ số xu hướng EMA và chỉ số dòng tiền để tích lũy khối lượng giao dịch, tận dụng đầy đủ thông tin về giá cả và khối lượng giao dịch, có thể xác định hiệu quả xu hướng đường dài. Chiến lược dừng lỗ cố định trực tiếp hiệu quả, có lợi để khóa một phần lợi nhuận và kiểm soát rủi ro.
Có thể tự do điều chỉnh tham số chu kỳ EMA để phù hợp với các giống khác nhau. Có thể thực hiện nhiều giao dịch ngắn hạn, thực hiện giao dịch tuyến tính. Dữ liệu phản hồi cho thấy chiến lược hoạt động tốt trong tình trạng xu hướng.
Chiến lược này phụ thuộc quá nhiều vào chỉ số đường trung bình, dễ gây ra tín hiệu nhầm lẫn trong các trường hợp rung động trong khu vực. Hạn chế dừng cố định cũng có thể gây ra sự ra đi quá sớm hoặc dừng quá lớn. Chỉ xem xét thông tin về giá cả và khối lượng giao dịch mà không xem xét các yếu tố khác.
Bạn có thể mở rộng tham số đường trung bình để giảm tín hiệu sai. Bạn cũng có thể đưa ra các chỉ số hỗ trợ phán đoán như tỷ lệ dao động, RSI. Tối ưu hóa các cơ chế dừng lỗ, chẳng hạn như đưa ra các phương pháp theo dõi dừng lỗ, dừng động.
Kiểm tra tối ưu hóa các tham số EMA để tìm tham số tối ưu nhất.
Tham gia các chỉ số kỹ thuật khác để tạo ra chiến lược bao gồm các chỉ số.
Sử dụng học máy để dự đoán xu hướng giá và cải thiện hiệu quả của EMA.
Tối ưu hóa chiến lược dừng lỗ, kết hợp với các cơ chế như theo dõi dừng lỗ, dừng động.
Giới thiệu mô-đun quản lý tài chính, điều chỉnh vị thế động.
Điều chỉnh tham số cho đặc điểm giống, tạo ra danh mục chiến lược.
Chiến lược này tích hợp các chỉ số EMA và khối lượng giao dịch để đánh giá xu hướng đường dài trung bình. Tuy nhiên, sự phụ thuộc quá nhiều vào đường trung bình và các điểm dừng cố định cũng có vấn đề. Thêm nhiều chỉ số để đánh giá và tối ưu hóa chiến lược dừng lỗ có thể làm tăng sự ổn định của chiến lược và lợi nhuận.
/*backtest
start: 2023-08-20 00:00:00
end: 2023-09-19 00:00:00
period: 2h
basePeriod: 15m
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/
// © mohanee
//@version=4
strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=10000)
emaLength= input(50, title="EMA Length", minval=1, maxval=200)
cumulativePeriod = input(100, title="cumulative volume Period", minval=1, maxval=200)
riskCapital = input(title="Risk % of capital", defval=10, minval=1)
stopLoss=input(8,title="Stop Loss",minval=1)
takePartialProfits=input(false, title="take partial profits (percentage same as stop loss)")
tradeDirection=input(title="Trade Direction", defval="LONG", options=["LONG", "SHORT"])
avgPrice = (high + low + close) / 3
avgPriceVolume = avgPrice * volume
cumulPriceVolume = sum(avgPriceVolume, cumulativePeriod)
cumulVolume = sum(volume, cumulativePeriod)
vwapValue = cumulPriceVolume / cumulVolume
emaVal=ema(close, emaLength)
plot(emaVal, title="EMA", color=color.green, transp=25)
plot(vwapValue, title="Cumulate Volumne / VWAP", color=color.orange, linewidth=2, transp=25)
bgcolor(emaVal>vwapValue?color.blue:color.purple)
//Entry--
//Echeck how many units can be purchased based on risk manage ment and stop loss
qty1 = (strategy.equity * riskCapital / 100 ) / (close*stopLoss/100)
//check if cash is sufficient to buy qty1 , if capital not available use the available capital only
qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1
strategy.entry(id="LE",comment="LE", long=true, qty=qty1, when=crossover(emaVal, vwapValue) and (tradeDirection=="LONG") ) //emaVal>vwapValue and crossover(close , emaVal)
//stoploss
stopLossVal= strategy.position_size>=1 ? (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00
//draw initil stop loss
plot(strategy.position_size>=1 ? stopLossVal : na, color = color.purple , style=plot.style_linebr, linewidth = 2, title = "stop loss")
//partial exits
takeProfit= strategy.position_size>=1 ? (strategy.position_avg_price * (1+(stopLoss*0.01) )) : ( close[1] * 2 )
if(takePartialProfits==true)
strategy.close(id="LE", comment="Partial"+tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and close>takeProfit and crossunder(close, emaVal) ) //close<close[1] and close[1]<close[2] and close[2]<close[3])
strategy.close(id="LE" , comment="LE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when=crossunder(emaVal, vwapValue) and (tradeDirection=="LONG") )
strategy.close(id="LE" , comment="SL Exit Loss="+tostring(close-strategy.position_avg_price, "###.##"), when= close < stopLossVal and (tradeDirection=="LONG") )
//for short you dont have to wait crossodown of ema, falling is speed , so just check if close crossing down vwapVal
strategy.entry(id="SE",comment="SE", long=false, qty=qty1, when=(close<vwapValue and close<open and close[1] < vwapValue and close[1]<open[1] and close<close[1]) and emaVal>=vwapValue and (tradeDirection=="SHORT") ) //emaVal>vwapValue and crossover(close , emaVal)
//stoploss
stopLossValUpside= abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ? (strategy.position_avg_price * (1+(stopLoss*0.01) )) : 0.00
//draw initil stop loss
plot(abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ? stopLossValUpside : na, color = color.purple , style=plot.style_linebr, linewidth = 2, title = "stop loss")
//partial exits
shortTakeProfit= abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ? (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00
if(takePartialProfits==true)
strategy.close(id="SE", comment="Partial" , qty=strategy.position_size/3 , when = (tradeDirection=="SHORT" ) and close<shortTakeProfit ) //close<takeProfit and (emaVal - close)>8 )
//strategy.close(id="SE" , comment="SE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when=crossover(emaVal, vwapValue) and (tradeDirection=="SHORT") )
strategy.close(id="SE" , comment="SE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open ) or (crossover(emaVal,vwapValue)) ) and (tradeDirection=="SHORT") )
strategy.close(id="SE" , comment="SL Exit Loss="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and close > stopLossValUpside and (tradeDirection=="SHORT" ) )