슈퍼 트렌드 전략

supertrend
생성 날짜: 2022-04-27 18:21:50 마지막으로 수정됨: 2025-07-18 12:50:59
복사: 928 클릭수: 46642
11
집중하다
607
수행원

플랫폼 사용자의 요청에 따라 FMZ는 TradingView의 Pine 언어 라이브러리와의 호환성을 위해 노력하고 있으며 이제 안정적인 버전을 출시했습니다.

  • 구문은 v5 버전과 완벽하게 호환됩니다.
  • 모든 지표가 완벽하게 구현되었습니다.
  • 수학 라이브러리가 완전히 구현되었습니다.
  • 문자열 라이브러리가 완전히 구현되었습니다.
  • 배열 라이브러리가 완전히 구현되었습니다.
  • 입력 매개변수는 인터페이스에서 자동으로 인식됩니다.
  • 요청.헤이키나시에 대한 보안 지원
  • 전략 라이브러리 구현(손절매/이익 실현/추적 이익 실현/조건부 주문 등 지원)
  • plot/plotchar/plotshape/plotcandle/alert/alertcondition 등과 호환됩니다.

언어 기능에 대한 전체 지원은 지속적인 노력입니다. 이 공개 버전은 사용자 테스트를 용이하게 하기 위해 사전에 릴리스됩니다.

앞으로 FMZ는 TradingView의 Pine 언어에 대한 함수 라이브러리 지원을 계속 늘리고 개선할 것입니다. 필요한 사항이 있으면 이 전략에 대한 메시지를 남길 수 있습니다.

참고: 정의되지 않은 변수가 나타나면 이 속성이 아직 지원되지 않는다는 의미입니다. 관련 호출을 삭제하거나 작업 주문을 보내 기술 직원에게 연락하여 해결할 수 있습니다.

슈퍼 트렌드 전략

전략 소스 코드
/*backtest
start: 2017-08-17 08:00:00
end: 2025-07-16 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

strategy("supertrend", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 50)

[supertrend, direction] = ta.supertrend(input(5, "factor"), input.int(10, "atrPeriod"))

plot(direction < 0 ? supertrend : na, "Up direction", color = color.green, style=plot.style_linebr)
plot(direction > 0 ? supertrend : na, "Down direction", color = color.red, style=plot.style_linebr)

if direction < 0
    if supertrend > supertrend[2]
        strategy.entry("entry long", strategy.long)
    else if strategy.position_size < 0
        strategy.close_all()
else if direction > 0
    if supertrend < supertrend[3]
        strategy.entry("entry short", strategy.short)
    else if strategy.position_size > 0
        strategy.close_all()