Pine Script™ 에서 버티컬 그래디언트를 쓸 수 있습니다!

Oct 5, 2022

fill() 펑크션에 대한 다음과 같은 새로운 오버로드는 버티컬 그래디언트를 만들 수 있습니다:

fill(plot1, plot2, top_value, bottom_value, top_color, bottom_color)

fill(hline1, hline2,  top_value, bottom_value, top_color, bottom_color)

새 오버로드의 모든 파라미터에 대한 아규먼트로 시리즈를 써서`top_value` 와 `bottom_value` 사이 공간에 `top_color` 부터 `bottom_color` 까지의 버티컬 그래디언트를 만들게 됩니다. 처음 두 아규먼트에서 ID가 사용된
plots 또는 hlines 은 그래디언트에 대한 마스크 역할을 하여 그래디언트의 어느 부분이 보이게 될지를 결정합니다.

여기에서 두 개의 버티컬 그래디언트로 기존 MACD에 새로운 모습을 부여하는 방법을 확인하십시오. 하나는 두 이동 평균 사이의 공간을 채우고 다른 하나는 일반적으로 히스토그램으로 표시되는 것입니다.

//@version=5
indicator("MACD")
[macd, signal, hist] = ta.macd(close, 12, 26, 9)

// Histogram
float  maxHist  = ta.highest(hist, 100)
float  minHist  = ta.lowest(hist,  100)
bool   histBull = hist > 0
color  topHistColor = histBull ? color.new(color.green, 90) : color.red
color  botHistColor = histBull ? color.green : color.new(color.red, 90)
float  topHistValue = histBull ? maxHist : 0
float  botHistValue = histBull ? 0 : minHist
histPlot   = plot(hist, "Histogram", color(na))
centerPlot = plot(0,    "Middle",    color(na))
fill(histPlot, centerPlot, topHistValue, botHistValue, topHistColor, botHistColor)

// Averages
float  maxLine  = ta.highest(math.max(macd, signal), 100)
float  minLine  = ta.lowest(math.min(macd, signal), 100)
bool   lineBull = macd > signal
color  topLineColor = lineBull ? color.new(color.lime, 90) : color.fuchsia
color  botLineColor = lineBull ? color.lime : color.new(color.fuchsia, 90)
float  topLineValue = lineBull ? maxLine : maxLine
float  botLineValue = lineBull ? minLine : minLine
macdPlot   = plot(macd,   "MACD",   color.gray,   1)
signalPlot = plot(signal, "Signal", color.silver, 1)
fill(macdPlot, signalPlot, topLineValue, botLineValue, topLineColor, botLineColor)

다음 보기에서는 배경에 대해 하나의 그라디언트를 사용하고  RSI-기반 트리 라인에 대해 다른 그래디언트를 사용하여 소나무 숲을 만듭니다.

//@version=5
indicator("Gradient Fill: Night in the Pine forest")

// Sky
skyTopColor = input.color(color.rgb(144, 191, 249, 1))
skyBotColor = input.color(color.rgb(251, 192, 45, 1))
skyPlot     = plot(100, color = skyTopColor)
groundPlot  = plot(0, color = color.black)
fill(skyPlot, groundPlot, 100, 0, skyTopColor, skyBotColor)

// Trees
crownsVal = ta.rsi(close, 20)
treesPlot = plot(crownsVal, color = color.rgb(6, 126, 116))
fill(treesPlot, groundPlot, crownsVal, 0, color.rgb(6, 126, 116), color.black)

당사 파인 코더즈가 커뮤니티 스크립트에 퍼블리쉬한 몇 개의 보기가 다음에 나와 있습니다

Delta Volume Channels 인디케이터 by LucF

RSI – colour fill 인디케이터 by Fikira

Webby’s RSI 인디케이터 by JohnMuchow

새로운 Pine Script™ 피처 알림을 받고, 유저 매뉴얼의 릴리즈 노트를 지켜보시기 바랍니다. PineCoders 어카운트 또한 텔리그램의 Squawk Box, 트위터 어카운트 그리고
트레이딩뷰 퍼블릿 챗의 Pine Script™ Q&A로부터 업데이트를 방송합니다.

많은 요청을 받은 이 기능이 유용하기를 바랍니다. 개선을 위한 피드백과 제안을 계속 보내주십시오. 우리는 여러분을 위해 TradingView를 만들고 있으며 항상 여러분의 의견을 듣고 싶습니다.

Look first Then leap

트레이딩뷰는 여러분을 위해 만들어졌으므로 트레이딩뷰의 멋진 기능을 최대한 활용하세요
차트 시작