以下の 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` の組み合わせで縦方向のグラデーションを作成します。最初の2つの引数で指定されるプロットやhlinesは、グラデーションのマスキングとして機能し、グラデーションの表示範囲を決定します。
ここでは、2つの垂直グラデーションで古いMACDに新しい外観を与える方法をご紹介します - 1つは2つの移動平均の間の領域を塗りつぶすためのもので、もう1つは通常ヒストグラムとして表現されるものに対してのグラデーションです:
//@version=5 indicator("MACD") [macd, signal, hist] = ta.macd(close, 12, 26, 9) // ヒストグラム 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) // 移動平均 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ベースの樹木のラインに別のグラデーションをかけて、Pineの森を作成しています:
//@version=5 indicator("Gradient Fill: Night in the Pine forest") // 空 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) // 森 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)
以下は、PineCodersがコミュニティスクリプトで公開した例です:
LucF氏による Delta Volume Channels インジケーター
Fikira氏による RSI – colour fill インジケーター
JohnMuchow氏による Webby’s RSI インジケーター
Pineスクリプト™ の新機能については、ユーザーマニュアルのリリースノートをご覧ください。PineCoders は、Telegramの Squawk Box、Twitterアカウント、TradingViewの “Pine Script™ Q&A” の公開チャットでも最新情報を配信しています。
ご要望を数多く頂いたこの機能がお役に立てば幸いです。引き続き改善の為のフィードバックやご提案をお寄せください。私たちは皆様のためにTradingViewを構築していますので、ユーザーの皆様からの声をお待ちしております。