RicardoSantos

[RS]Color Gradient Function

A simple function method to build color gradient palettes to use in scripts
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
study(title="[RS]Color Gradient Function", overlay=false)
green_ColorScope(value)=>
    value >= 10 ? #0d3d00 :
        value == 09 ? #104c00 :
        value == 08 ? #135b00 :
        value == 07 ? #176b00 :
        value == 06 ? #1a7a00 :
        value == 05 ? #1d8900 :
        value == 04 ? #219900 :
        value == 03 ? #37a319 :
        value == 02 ? #4dad32 :
        value == 01 ? #63b74c : white
red_ColorScope(value)=>
    value >= 10 ? #4c0010 :
        value == 09 ? #5b0013 :
        value == 08 ? #6b0017 :
        value == 07 ? #7a001a :
        value == 06 ? #89001d :
        value == 05 ? #990021 :
        value == 04 ? #a31937 :
        value == 03 ? #ad324d :
        value == 02 ? #b74c63 :
        value == 01 ? #c16679 : white

plot(0.0, color=green_ColorScope(10), linewidth=4)
plot(0.1, color=green_ColorScope(09), linewidth=4)
plot(0.2, color=green_ColorScope(08), linewidth=4)
plot(0.3, color=green_ColorScope(07), linewidth=4)
plot(0.4, color=green_ColorScope(06), linewidth=4)
plot(0.5, color=green_ColorScope(05), linewidth=4)
plot(0.6, color=green_ColorScope(04), linewidth=4)
plot(0.7, color=green_ColorScope(03), linewidth=4)
plot(0.8, color=green_ColorScope(02), linewidth=4)
plot(0.9, color=green_ColorScope(01), linewidth=4)
plot(1.0, color=red_ColorScope(01), linewidth=4)
plot(1.1, color=red_ColorScope(02), linewidth=4)
plot(1.2, color=red_ColorScope(03), linewidth=4)
plot(1.3, color=red_ColorScope(04), linewidth=4)
plot(1.4, color=red_ColorScope(05), linewidth=4)
plot(1.5, color=red_ColorScope(06), linewidth=4)
plot(1.6, color=red_ColorScope(07), linewidth=4)
plot(1.7, color=red_ColorScope(08), linewidth=4)
plot(1.8, color=red_ColorScope(09), linewidth=4)
plot(1.9, color=red_ColorScope(10), linewidth=4)