
이 전략은 슈퍼 트렌드 지표와 MACD 지표를 결합하여 작은 트렌드를 포착하여 수익을 얻습니다. 전략은 슈퍼 트렌드 지표를 사용하여 현재 시장 추세를 판단하고, MACD 지표를 입점과 출구에 대한 보조 조건으로 사용합니다. 전략 논리는 명확하고 이해하기 쉽고 구현됩니다.
이 전략은 슈퍼 트렌드 지표와 MACD 지표를 결합하여 작은 트렌드를 포착하면서도 트렌드의 지속성을 고려하여 보다 포괄적이고 균형 잡힌 전략이다. 전략의 장점은 논리적으로 명확하고 이해하기 쉽고 구현되며, 더 긴 주기 MACD 지표를 보조 조건으로 사용하여 일부 가짜 신호를 효과적으로 필터링 할 수 있다. 그러나 전략에는 약간의 위험이 있습니다.
/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-29 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Samsuga supertrend", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
atrPeriod = input.int(7, "ATR Length", minval = 1)
factor = input.float(1.0, "Factor", minval = 0.01, step = 0.01)
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
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 = 3
macdp2=10
macdp3=6
[macdLine, signalLine, histLine] =request.security(symbol = syminfo.tickerid, timeframe = "30",expression = ta.macd(close,macdp1,macdp2,macdp3),lookahead=barmerge.lookahead_on)
// 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-----------------////////////////
// log.info(str.tostring(syminfo.tickerid)+str.tostring(histLine[0]))
if(longcondition)
if(histLine[0] > 0)
strategy.close("Short",comment = "E-S", alert_message = "E-S",disable_alert = true)
strategy.entry(id= "Long", direction=strategy.long, comment = "L",alert_message = "L")
else if(shortCondition)
if(histLine[0] < 0)
strategy.close("Long",comment = "E-L",alert_message = "E-L",disable_alert = true)
strategy.entry(id= "Short", direction=strategy.short, comment = "S",alert_message = "S")