MaterialPalette

█ OVERVIEW
This Pine Script® library provides a convenient way to access and utilize colors based on the popular Material Design color system directly within your TradingView scripts. It offers a comprehensive set of functions to retrieve specific shades of various base colors, allowing developers to create visually consistent and aesthetically pleasing indicators and strategies.
By importing this library, you gain access to functions that generate colors based on saturation, darkness level, and opacity, simplifying the process of managing color palettes in your projects.
█ FEATURES
- Provides exported functions for 18 base Material Design colors (e.g., `red()`, `blue()`, `green()`, `amber()`, etc.).
- Each color function allows selection from multiple shades based on `saturationLevel` (int) and `darkLevel` (int).
- All color functions accept an `opacity` parameter (integer, 0-100).
- Includes a `tone()` function for quick access to predefined base tones (e.g., `tone("red")`).
- Offers a consistent and organized approach to using Material Design colors in Pine Script®.
- Includes detailed `Function`, `param`, and `Returns` annotations within the code for comprehensive documentation.
█ HOW TO USE
To use this library in your own Pine Script® indicator or strategy, you first need to import it using the `import` statement.
1. Import the Library:
Add the following line at the beginning of your script. Remember to replace `mastertop_astray` with the actual TradingView username the library is published under, and `VERSION` with the specific version number of the library you wish to use (you can find this on the library's script page).
*(We use `mp` as a short alias for `MaterialPalette` for convenience)*
2. Call Exported Functions:
Once imported, you can call the exported functions using the alias (`mp.` prefix).
█ EXPORTED FUNCTIONS
This library provides two main categories of functions:
1. Color Shade Generators (`red()` to `blueGrey()`):
- Includes: 18 functions for base colors (`red()`, `pink()`, ..., `blueGrey()`).
- Purpose: Generate specific shades of the base color according to Material Design palettes.
- Parameter `saturationLevel` (int): Controls color intensity/saturation. The valid range and default value vary depending on the specific color function (typically 1-13 or 1-9). Please check the `param` annotation in the code for each function.
- Parameter `darkLevel` (int): Sets the lightness/darkness of the shade (1: Light, 2: Medium/Base, 3: Dark). Default is 2.
- Parameter `opacity` (int): Sets the color's transparency (0 = Opaque, 100 = Invisible). Default is 0.
- Returns: The calculated `color` value.
- Note: For exact default values and valid saturation ranges for each specific color function, refer to the detailed `param` annotations within the library's source code.
2. Base Tone Function (`tone()`):
- Purpose: Retrieve a single, predefined base color tone from the palette.
- Parameter `colorName` (simple string): The text name identifying the desired base color (e.g., 'red', 'blue', 'green', 'light_blue').
- Parameter `opacity` (int): Sets the color's transparency (0 = Opaque, 100 = Invisible). Default is 0.
- Returns: The corresponding base tone `color`.
- Note: Please consult the function's implementation in the source code for the complete list of valid `colorName` strings.
█ VISUALIZATION TABLE (For Demonstration)
The library's source code includes logic (within an `if barstate.islast` block) that generates a large table displaying all available color shades.
Important: This table will only appear on your chart if you add the entire library code itself directly as an indicator. This is primarily intended for demonstration, reference, and development purposes to visualize the palette. When using the library normally via the `import` statement in your own scripts, this table code is not executed or needed.
█ SUMMARY
The `MaterialPalette` library offers a structured and easy way for Pine Script® developers to incorporate Material Design colors into their TradingView scripts, enhancing visual appeal and consistency. Please refer to the detailed comments within the code for specifics on parameter ranges and available tones.
This source code is subject to the terms of the Mozilla Public License 2.0.
© mastertop_astray
Perpustakaan Pine
Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai perpustakaan sumber terbuka supaya pengaturcara Pine lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda juga boleh menggunakan perpustakaan ini secara peribadi atau dalam penerbitan sumber terbuka lain, tetapi penggunaan semula kod ini dalam penerbitan adalah tertakluk kepada Peraturan Dalaman.
Penafian
Perpustakaan Pine
Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai perpustakaan sumber terbuka supaya pengaturcara Pine lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda juga boleh menggunakan perpustakaan ini secara peribadi atau dalam penerbitan sumber terbuka lain, tetapi penggunaan semula kod ini dalam penerbitan adalah tertakluk kepada Peraturan Dalaman.