
동력 가격 트렌드 추적 전략은 가격의 트렌드를 식별하기 위해 여러 가지 동력 지표를 사용하며, 트렌드 초기 단계에서 포지션을 구축하고, 스톱 스톱 손실을 설정하여 수익을 고정하여 가격 트렌드를 추적합니다.
동력 가격 트렌드 추적 전략은 주로 다음과 같은 기술 지표를 사용합니다.
ROC 지표: 이 지표는 특정 기간 동안의 가격 변화 속도의 비율을 계산하여 가격 움직임을 판단합니다. ROC이 긍정되면 가격이 상승하고 있으며 ROC이 부정되면 가격이 떨어지고 있음을 나타냅니다. 전략은 ROC 지표를 통해 가격 경향 방향을 판단합니다.
다공 에너지 지표: 이 지표는 다공 힘과 공수 힘의 대립 관계를 나타냅니다. 다공 에너지>0은 다공 힘이 공수 힘보다 크다는 것을 의미하며, 가격이 상승합니다. 반대로 가격은 떨어집니다. 이 지표를 사용하여 다공 힘 비교를 판단하고 가격 방향을 예측합니다.
이탈 지표: 이 지표는 거래량과 가격의 이탈 상황을 계산하여 트렌드 반전을 판단한다. 전략은 이탈 신호를 입시 시점으로 사용합니다.
Donchian channel: 이 지표는 가격의 최고 가격과 최저 가격으로 채널을 구성합니다. 채널의 경계는 지원 및 저항 지점으로 사용할 수 있습니다. 전략은 채널을 사용하여 트렌드 방향을 판단합니다.
이동 평균: 이 지표는 가격의 지지를 받거나 상승하거나 하락하는 흔들림을 제거하여 주요 트렌드 방향을 보여줍니다. 전략은 전체 가격 움직임을 판단하는 데 사용됩니다.
전략은 위의 여러 지표에 따라 가격 트렌드 및 반전 시기를 판단하고, 트렌드 초기 단계에서 지표 신호에 따라 상위 또는 공백 포지션을 설정합니다. 그리고는 스톱 스톱 손실 지점에 따라 적시에 평정 포지션을 고정하여 가격 트렌드를 포착합니다.
이 전략은 다음과 같은 장점을 가지고 있습니다.
다양한 지표를 적용하여 추세를 판단하여 잘못된 판단의 가능성을 줄여줍니다.
이 지표는 트렌드 반전점을 정확하게 잡기 위해 사용된다.
채널과 이동 평균을 결합하여 큰 경향의 방향을 판단한다.
정지 지점을 설정하여 정지 시기를 정지하고 철회 확장을 방지합니다.
매매는 변수에 따라 조정될 수 있으며, 다른 주기 및 품종의 거래에 적용된다.
전략 논리는 명확하고 이해하기 쉽고, 후기 최적화를 용이하게 합니다.
이 전략에는 위험도 있습니다.
다중 지표 조합 판단은 잘못된 신호의 확률을 증가시키고, 파라미터 최적화 지표 무게를 조정할 필요가 있다.
스톱포인트를 너무 작게 설정하면 스톱포드의 확률이 증가할 수 있고, 너무 크게 설정하면 회수 폭이 확대될 수 있다. 합리적인 스톱포인트를 결정하는 데에는 종합적인 고려가 필요하다.
다양한 시장 주기 파라미터는 조정할 필요가 있으며, 맹목적인 적용은 시장 환경에 적응하지 못하는 결과를 초래할 수 있다.
다단계 동방향 거래를 지원하기 위해 충분한 자금이 필요합니다. 그렇지 않으면 excess returns를 얻는 것이 어렵습니다.
프로그램 거래에는 재검토된 적합성 위험이 있으며, 실디 효과에는 약간의 불확실성이 있다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
지표 파라미터를 최적화하여 다양한 주기 및 품종의 파라미터의 최적의 조합을 찾습니다.
기계 학습 알고리즘을 추가하여 최적의 변수를 자동으로 찾습니다.
시장 상황에 따라 스톱포드를 조정하는 적응 스톱포드 메커니즘을 추가하십시오.
높은 주파수와 기본 지표를 결합하여 전략의 알파를 향상시킵니다.
자동 테스트 프레임워크를 개발하고, 변수 모음을 조정하고, 거래 효과를 검증한다.
리스크 관리 모듈을 도입하여 포지션 규모를 제어하고 철수를 줄입니다.
시뮬레이션 거래와 실물 검증 연결을 추가하여 전략의 안정성을 향상시킵니다.
이 전략은 여러 가지 동적 지표를 사용하여 가격 추세를 판단하고 수익을 고정하기 위해 스톱 스톱을 설정합니다. 이 전략은 가격 추세를 효과적으로 포착 할 수 있으며 강한 안정성을 가지고 있습니다. 매개 변수를 조정하고 구조를 최적화하고 위험을 제어함으로써 이 전략은 효과를 더욱 높이고 거래 위험을 줄일 수 있습니다. 이 전략은 거래량을위한 신뢰할 수 있고 쉽게 작동하는 트렌드 추적 프로그램을 제공합니다.
/*backtest
start: 2023-11-05 00:00:00
end: 2023-11-09 00:00:00
period: 1m
basePeriod: 1m
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/
// © mbagheri746
//@version=4
strategy("Bagheri IG Ether v2", overlay=true, margin_long=100, margin_short=100)
TP = input(3000, minval = 1 , title ="Take Profit")
SL = input(2200, minval = 1 , title ="Stop Loss")
//_________________ RoC Definition _________________
rocLength = input(title="ROC Length", type=input.integer, minval=1, defval=186)
smoothingLength = input(title="Smoothing Length", type=input.integer, minval=1, defval=50)
src = input(title="Source", type=input.source, defval=close)
ma = ema(src, smoothingLength)
mom = change(ma, rocLength)
sroc = nz(ma[rocLength]) == 0
? 100
: mom == 0
? 0
: 100 * mom / ma[rocLength]
//srocColor = sroc >= 0 ? #0ebb23 : color.red
//plot(sroc, title="SROC", linewidth=2, color=srocColor, transp=0)
//hline(0, title="Zero Level", linestyle=hline.style_dotted, color=#989898)
//_________________ Donchian Channel _________________
length1 = input(53, minval=1, title="Upper Channel")
length2 = input(53, minval=1, title="Lower Channel")
offset_bar = input(91,minval=0, title ="Offset Bars")
upper = highest(length1)
lower = lowest(length2)
basis = avg(upper, lower)
DC_UP_Band = upper[offset_bar]
DC_LW_Band = lower[offset_bar]
l = plot(DC_LW_Band, style=plot.style_line, linewidth=1, color=color.red)
u = plot(DC_UP_Band, style=plot.style_line, linewidth=1, color=color.aqua)
fill(l,u,color = color.new(color.aqua,transp = 90))
//_________________ Bears Power _________________
wmaBP_period = input(65,minval=1,title="BearsP WMA Period")
line_wma = ema(close, wmaBP_period)
BP = low - line_wma
//_________________ Balance of Power _________________
ES_BoP=input(15, title="BoP Exponential Smoothing")
BOP=(close - open) / (high - low)
SBOP = rma(BOP, ES_BoP)
//_________________ Alligator _________________
//_________________ CCI _________________
//_________________ Moving Average _________________
sma_period = input(74, minval = 1 , title = "SMA Period")
sma_shift = input(37, minval = 1 , title = "SMA Shift")
sma_primary = sma(close,sma_period)
SMA_sh = sma_primary[sma_shift]
plot(SMA_sh, style=plot.style_line, linewidth=2, color=color.yellow)
//_________________ Long Entry Conditions _________________//
MA_Lcnd = SMA_sh > low and SMA_sh < high
ROC_Lcnd = sroc < 0
DC_Lcnd = open < DC_LW_Band
BP_Lcnd = BP[1] < BP[0] and BP[1] < BP[2]
BOP_Lcnd = SBOP[1] < SBOP[0]
//_________________ Short Entry Conditions _________________//
MA_Scnd = SMA_sh > low and SMA_sh < high
ROC_Scnd = sroc > 0
DC_Scnd = open > DC_UP_Band
BP_Scnd = BP[1] > BP[0] and BP[1] > BP[2]
BOP_Scnd = SBOP[1] > SBOP[0]
//_________________ OPEN POSITION __________________//
if strategy.position_size == 0
strategy.entry(id = "BUY", long = true , when = MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd)
strategy.entry(id = "SELL", long = false , when = MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd)
//_________________ CLOSE POSITION __________________//
strategy.exit(id = "CLOSE BUY", from_entry = "BUY", profit = TP , loss = SL)
strategy.exit(id = "CLOSE SELL", from_entry = "SELL" , profit = TP , loss = SL)
//_________________ TP and SL Plot __________________//
currentPL= strategy.openprofit
pos_price = strategy.position_avg_price
open_pos = strategy.position_size
TP_line = (strategy.position_size > 0) ? (pos_price + TP/100) : strategy.position_size < 0 ? (pos_price - TP/100) : 0.0
SL_line = (strategy.position_size > 0) ? (pos_price - SL/100) : strategy.position_size < 0 ? (pos_price + SL/100) : 0.0
// hline(TP_line, title = "Take Profit", color = color.green , linestyle = hline.style_dotted, editable = false)
// hline(SL_line, title = "Stop Loss", color = color.red , linestyle = hline.style_dotted, editable = false)
Tline = plot(TP_line != 0.0 ? TP_line : na , title="Take Profit", color=color.green, trackprice = true, show_last = 1)
Sline = plot(SL_line != 0.0 ? SL_line : na, title="Stop Loss", color=color.red, trackprice = true, show_last = 1)
Pline = plot(pos_price != 0.0 ? pos_price : na, title="Stop Loss", color=color.gray, trackprice = true, show_last = 1)
fill(Tline , Pline, color = color.new(color.green,transp = 90))
fill(Sline , Pline, color = color.new(color.red,transp = 90))
//_________________ Alert __________________//
//alertcondition(condition = , title = "Position Alerts", message = "Bagheri IG Ether\n Symbol: {{ticker}}\n Type: {{strategy.order.id}}")
//_________________ Label __________________//
inMyPrice = input(title="My Price", type=input.float, defval=0)
inLabelStyle = input(title="Label Style", options=["Upper Right", "Lower Right"], defval="Lower Right")
posColor = color.new(color.green, 25)
negColor = color.new(color.red, 25)
dftColor = color.new(color.aqua, 25)
posPnL = (strategy.position_size != 0) ? (close * 100 / strategy.position_avg_price - 100) : 0.0
posDir = (strategy.position_size > 0) ? "long" : strategy.position_size < 0 ? "short" : "flat"
posCol = (strategy.openprofit > 0) ? posColor : (strategy.openprofit < 0) ? negColor : dftColor
myPnL = (inMyPrice != 0) ? (close * 100 / inMyPrice - 100) : 0.0
var label lb = na
label.delete(lb)
lb := label.new(bar_index, close,
color=posCol,
style=inLabelStyle=="Lower Right"?label.style_label_upper_left:label.style_label_lower_left,
text=
"╔═══════╗" +"\n" +
"Pos: " +posDir +"\n" +
"Pos Price: "+tostring(strategy.position_avg_price) +"\n" +
"Pos PnL: " +tostring(posPnL, "0.00") + "%" +"\n" +
"Profit: " +tostring(strategy.openprofit, "0.00") + "$" +"\n" +
"TP: " +tostring(TP_line, "0.00") +"\n" +
"SL: " +tostring(SL_line, "0.00") +"\n" +
"╚═══════╝")