
평균선과 슈퍼 트렌드를 결합한 일일 다공간 동적 균형 전략은 Pine ScriptTM 5를 기반으로 작성된 양적 거래 전략이다. 이 전략은 MACD 지표와 슈퍼 트렌드 지표를 사용하여 시장의 트렌딩적 기회를 포착하고, 동적 다공간 전환과 손해 차단을 통해 위험을 제어한다.
이 전략의 핵심은 MACD 지표와 슈퍼 트렌드 지표를 결합하여 시장의 트렌드 방향을 판단하는 것입니다. 구체적으로:
동적인 다중 포지션 전환을 통해, 이 전략은 시장의 변화에 적응할 수 있고, 트렌디스틱한 기회를 잡을 수 있다. 동시에, 고정 시간 평점 포지션의 설계는 위험을 통제하는데도 도움이 된다.
평균선과 슈퍼 트렌드를 결합한 일일 다공간 동적 균형 전략은 트렌드 추적과 동적 판단에 기반한 거래 전략이다. 슈퍼 트렌드 지표와 MACD 지표를 결합하여 포지션 방향을 동적으로 조정하는 전략은 시장의 변화에 적응하여 트렌드 기회를 잡을 수 있다. 동시에, 고정 시간 평소 포지션의 설계는 야간 위험을 제어하는 데 도움이 된다.
그러나, 이 전략에는 지표 실패 위험, 변수 최적화 위험, 상쇄 위험 등과 같은 몇 가지 위험과 결함이 있습니다. 이 전략을 더 개선하기 위해, 상쇄 논리를 추가하고, 변수를 최적화하고, 더 많은 신호 필터링 조건을 추가하고, 여러 시장에서 테스트하는 등이 고려 될 수 있습니다.
일반적으로, 평행선과 슈퍼 트렌드를 결합한 일일 다공간 동적 균형 전략은 트렌드 추적과 위험 제어에 대한 아이디어를 제공합니다. 실제 적용에서, 거래자는 자신의 위험 선호와 시장 특성을 결합하여 전략을 적절히 조정하고 최적화하여 신중하게 사용해야합니다. 수량 거래 전략은 거래 아이디어를 제공 할 수 있지만 시장은 급변합니다. 어떤 전략도 수익을 보장 할 수 없습니다. 투자자는 전략의 원리와 위험을 이해하고, 위치를 합리적으로 제어하고, 엄격하게 중지하고, 매 순간 경각심을 유지해야 시장에서 중장기 생존 할 수 있습니다.
/*backtest
start: 2023-03-05 00:00:00
end: 2024-03-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © smj31071995
//@version=5
strategy("EQ - INTRA - Samsuga supertrend prod", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_every_tick = false)
atrPeriod = input.int(7, "ATR Length", minval = 1)
factor = input.float(1.0, "Factor", minval = 0.01, step = 0.01)
st_tf = "3"
macd_tf="30"
[supertrend, direction] =request.security(symbol = syminfo.tickerid, timeframe = st_tf,expression = ta.supertrend(factor, atrPeriod),lookahead=barmerge.lookahead_on)
supertrend := barstate.isfirst ? na : supertrend
upTrend = plot(direction <= 0 ? supertrend : na, "Up Trend", color = color.green, style = plot.style_linebr)
downTrend = plot(direction <= 0 ? na : supertrend, "Down Trend", color = color.red, style = plot.style_linebr)
bodyMiddle = plot(barstate.isfirst ? na : (open + close) / 2, "Body Middle",display = display.none)
longcondition = direction[1] > direction
shortCondition = direction[1] < direction
macdp1 = 2
macdp2=8
macdp3=4
[macdLine, signalLine, histLine] =request.security(symbol = syminfo.tickerid, timeframe = macd_tf,expression = ta.macd(close,macdp1,macdp2,macdp3),lookahead=barmerge.lookahead_on)
// log.info(str.tostring(syminfo.tickerid)+str.tostring(histLine[0]))
timezone_input = input("Asia/Kolkata", title="Timezone")
// log.info(timezone_input)
if(hour==15 and minute==15)
strategy.close_all(comment = "DAY EXIT",alert_message = "X-D")
else if(hour==9 and minute==30)
if(longcondition or histLine[1]>0)
strategy.entry(id= "Long", direction=strategy.long, comment = "DL",alert_message = "L")
else if(shortCondition or histLine[1]<0)
strategy.entry(id= "Short", direction=strategy.short, comment = "DS",alert_message = "S")
else
if(longcondition)
strategy.close("Short",comment = "X-S", alert_message = "X-S")
if(histLine[1]>0)
strategy.entry(id= "Long", direction=strategy.long, comment = "L",alert_message = "L")
else if(shortCondition)
strategy.close("Long",comment = "X-L",alert_message = "X-L")
if(histLine[1]<0)
strategy.entry(id= "Short", direction=strategy.short, comment = "S",alert_message = "S")
// plot(macdLine, title = "MACD", color = #2962FF)
// plot(signalLine, title = "Signal", color = #FF6D00)
// 8, 21, 5
// 8,13,9
// 12,26,9
// 1--> 3, 17, 5
// 3, 10, 16
// log.info(str.tostring(syminfo.tickerid)+str.tostring(histLine[0]))
// /////////----------------METHOD 1-----------------////////////////
// if(longcondition)
// if(strategy.opentrades>0)
// strategy.close("Long","Prev Exit", immediately = true)
// if( histLine[0] > 0.1)
// strategy.entry(id= "Long", direction=strategy.long, comment = "update long")
// else if(shortCondition and strategy.openprofit<=0.1)
// strategy.close("Long",comment = "Close",immediately = true)
// /////////----------------METHOD 2-----------------////////////////
// if(longcondition)
// if(histLine[0] > 0)
// strategy.entry(id= "Long", direction=strategy.long, comment = "update long" )
// strategy.exit("Long", loss = close*0.2)
// else if(shortCondition )
// strategy.close("Long",comment = "Close",immediately = true)
// /////////----------------METHOD 3-----------------////////////////