RicardoSantos

[RS]Color Gradient Function

A simple function method to build color gradient palettes to use in scripts

Skript med en öppen källkod

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Vill du använda det här skriptet i ett diagram?
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)