Les nouveaux overloads suivants de la fonction fill() permettent de créer des gradients verticaux :
fill(plot1, plot2, top_value, bottom_value, top_color, bottom_color) fill(hline1, hline2, top_value, bottom_value, top_color, bottom_color)
Tous les paramètres des nouveaux overloads acceptent des arguments de série. Ils créent un gradient vertical entre la `top_color` et la `bottom_color` dans l’espace entre la `top_value` et la `bottom_value`. Les tracés ou hlines dont les ID sont utilisés dans les deux premiers arguments agissent comme un masque sur le gradient, déterminant quelle partie du gradient est visible.
Voyez ici comment nous donnons à l’ancien MACD un nouveau look avec deux gradients verticaux, un pour remplir l’espace entre les deux moyennes mobiles, et un autre pour ce qui est habituellement représenté comme un histogramme :
//@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)
Dans notre prochain exemple, nous créons une forêt de Pine en utilisant un gradient pour l’arrière-plan et un autre pour la ligne d’arbres basée sur le 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)
Voici quelques autres exemples publiés par certains de nos PineCoders dans Scripts communautaires:
Indicateur Delta Volume Channels par LucF
Indicateur RSI – colour fill par Fikira
Indicateur Webby’s RSI par JohnMuchow
Pour rester informé/e des nouvelles fonctionnalités de Pine Script™, gardez un œil sur les notes de publication du manuel d’utilisation. Le compte PineCoders diffuse également des mises à jour depuis sa Squawk Box sur Telegram, son compte Twitter et depuis le chat public Pine Script™ Q&A sur TradingView.
Nous espérons que vous trouverez utile cette fonctionnalité très demandée. Continuez à nous envoyer vos commentaires et suggestions d’amélioration. Nous construisons TradingView pour vous, et nous sommes toujours ravis d’avoir de vos nouvelles.