
Chiến lược động lực tương đối để đánh giá sức mạnh của một cổ phiếu so với thị trường lớn bằng cách so sánh động lực của cổ phiếu với chỉ số, mua khi động lực của một cổ phiếu cao hơn thị trường lớn và bán khi động lực của một cổ phiếu thấp hơn thị trường lớn để nắm bắt đỉnh cao của cổ phiếu.
Chiến lược này chủ yếu đánh giá sức mạnh của các cổ phiếu so với thị trường lớn, theo logic cụ thể:
Với logic như vậy, chúng ta có thể mua cổ phiếu trong thời kỳ tăng trưởng mạnh mẽ và bán nó khi động lực tăng trưởng của nó giảm đi, khóa lợi nhuận dư thừa trong thời kỳ tăng trưởng cao nhất của nó.
Chiến lược động lượng tương đối có những lợi thế chính như sau:
Chiến lược tương đối năng động cũng có một số rủi ro:
Những rủi ro này có thể được kiểm soát bằng các phương pháp như dừng lỗ và điều chỉnh các tham số thích hợp.
Chiến lược động lượng tương đối có thể được tối ưu hóa theo các khía cạnh sau:
Chiến lược động lượng tương đối có thể thu được lợi nhuận vượt trội bằng cách nắm bắt đỉnh cao tăng trưởng của một cổ phiếu tương đối lớn. Chiến lược này có lợi thế về logic mua bán đơn giản và rõ ràng, dễ vận hành, có thể đạt được hiệu quả tốt hơn thông qua tối ưu hóa tham số và kiểm soát rủi ro.
/*backtest
start: 2024-01-21 00:00:00
end: 2024-01-28 00:00:00
period: 15m
basePeriod: 5m
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/
// © HeWhoMustNotBeNamed
//@version=4
strategy("Relative Returns Strategy", overlay=false, initial_capital = 100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, pyramiding = 1, commission_value = 0.01, calc_on_order_fills = true)
index_ticker=input("BTC_USDT:swap")
Loopback = input(40, step=20)
useStopAndIndexReturns = input(true)
useStopAndIndexReturnsMa = input(true)
useDifference = not useStopAndIndexReturns
MAType = input(title="Moving Average Type", defval="sma", options=["ema", "sma", "hma", "rma", "vwma", "wma"])
MALength = input(10, minval=10,step=10)
i_startTime = input(defval = timestamp("01 Jan 2010 00:00 +0000"), title = "Backtest Start Time", type = input.time)
i_endTime = input(defval = timestamp("01 Jan 2099 00:00 +0000"), title = "Backtest End Time", type = input.time)
inDateRange = true
f_secureSecurity(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_on)
f_getMovingAverage(source, MAType, length)=>
ma = sma(source, length)
if(MAType == "ema")
ma := ema(source,length)
if(MAType == "hma")
ma := hma(source,length)
if(MAType == "rma")
ma := rma(source,length)
if(MAType == "vwma")
ma := vwma(source,length)
if(MAType == "wma")
ma := wma(source,length)
ma
index = f_secureSecurity(index_ticker, '1D', close, 0)
stock_return = (close - close[Loopback])*100/close
index_return = (index - index[Loopback])*100/index
stock_return_ma = f_getMovingAverage(stock_return, MAType, MALength)
index_return_ma = f_getMovingAverage(index_return, MAType, MALength)
relativeReturns = stock_return - index_return
relativeReturns_ma = f_getMovingAverage(relativeReturns, MAType, MALength)
plot(useStopAndIndexReturns ? useStopAndIndexReturnsMa ? stock_return_ma : stock_return : na, title="StockReturn", color=color.green, linewidth=1)
plot(useStopAndIndexReturns ? useStopAndIndexReturnsMa ? index_return_ma : index_return : na, title="IndexReturn", color=color.red, linewidth=1)
plot(useDifference?relativeReturns:na, title="Relative-Returns", color=color.blue, linewidth=1)
plot(useDifference?relativeReturns_ma:na, title="MA", color=color.red, linewidth=1)
buyCondition = (useStopAndIndexReturns ? useStopAndIndexReturnsMa ? stock_return_ma > index_return_ma : stock_return > index_return : relativeReturns > relativeReturns_ma)
closeBuyCondition = (useStopAndIndexReturns ? useStopAndIndexReturnsMa ? stock_return_ma < index_return_ma : stock_return < index_return : relativeReturns < relativeReturns_ma)
strategy.entry("Buy", strategy.long, when=buyCondition and inDateRange, oca_name="oca")
strategy.close("Buy", when=closeBuyCondition)