PINE LIBRARY
업데이트됨 Utils

Library "Utils"
Utility functions. Mathematics, colors, and auxiliary algorithms.
setTheme(vc, theme)
Set theme for levels (predefined colors).
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels.
theme: (int) Theme (predefined colors).
0 = 'User defined'
1 = 'Spectrum Blue-Green-Red'
2 = 'Monokai'
3 = 'Green'
4 = 'Purple'
5 = 'Blue'
6 = 'Red'
Returns: (void)
setTheme(vc, colorLevel_Lv1, colorLevel_Lv1_Lv2, colorLevel_Lv2_Lv3, colorLevel_Lv3_Lv4, colorLevel_Lv4_Lv5, colorLevel_Lv5)
Set theme for levels (customized colors).
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
colorLevel_Lv1: (color) Color associeted with value when below Level 1.
colorLevel_Lv1_Lv2: (color) Color associeted with value when between Level 1 and 2.
colorLevel_Lv2_Lv3: (color) Color associeted with value when between Level 2 and 3.
colorLevel_Lv3_Lv4: (color) Color associeted with value when between Level 3 and 4.
colorLevel_Lv4_Lv5: (color) Color associeted with value when between Level 4 and 5.
colorLevel_Lv5: (color) Color associeted with value when above Level 5.
Returns: (void)
setCurrentColorValue(vc)
Set color to a current value, taking into account the previous value and its levels
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
Returns: (void)
setCurrentColorValue(vc, gradient)
Set color to a current value, taking into account the previous value.
Parameters:
vc: (valueColor) Object to associate a color with a value, taking into account the previous value
gradient
Returns: (void)
setCustomLevels(vc, level1, level2, level3, level4, level5)
Set boundaries for custom levels.
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
level1: (float) Boundary for level 1
level2: (float) Boundary for level 2
level3: (float) Boundary for level 3
level4: (float) Boundary for level 4
level5: (float) Boundary for level 5
Returns: (void)
getPeriodicColor(originalColor, density)
Returns a periodic color. Useful for creating dotted lines for example.
Parameters:
originalColor: (color) Original color.
density: (float) Density of color. Expression used in modulo to obtain the integer remainder.
If the remainder equals zero, the color appears, otherwise it remains hidden.
Returns: (color) Periodic color.
dinamicZone(source, sampleLength, pcntAbove, pcntBelow)
Get Dynamic Zones
Parameters:
source: (float) Source
sampleLength: (int) Sample Length
pcntAbove: (float) Calculates the top of the dynamic zone, considering that the maximum values are above x% of the sample
pcntBelow: (float) Calculates the bottom of the dynamic zone, considering that the minimum values are below x% of the sample
Returns: [float, float, float] A tuple with 3 series of values: (1) Upper Line of Dynamic Zone;
(2) Lower Line of Dynamic Zone; (3) Center of Dynamic Zone (x = 50%)
valueColorSpectrum
# Object to associate a color with a value, taking into account the previous value and its levels.
Fields:
currentValue
previousValue
level1
level2
level3
level4
level5
currentColorValue
colorLevel_Lv1
colorLevel_Lv1_Lv2
colorLevel_Lv2_Lv3
colorLevel_Lv3_Lv4
colorLevel_Lv4_Lv5
colorLevel_Lv5
theme
valueColor
# Object to associate a color with a value, taking into account the previous value
Fields:
currentValue
previousValue
currentColorValue
colorUp
colorDown
Utility functions. Mathematics, colors, and auxiliary algorithms.
setTheme(vc, theme)
Set theme for levels (predefined colors).
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels.
theme: (int) Theme (predefined colors).
0 = 'User defined'
1 = 'Spectrum Blue-Green-Red'
2 = 'Monokai'
3 = 'Green'
4 = 'Purple'
5 = 'Blue'
6 = 'Red'
Returns: (void)
setTheme(vc, colorLevel_Lv1, colorLevel_Lv1_Lv2, colorLevel_Lv2_Lv3, colorLevel_Lv3_Lv4, colorLevel_Lv4_Lv5, colorLevel_Lv5)
Set theme for levels (customized colors).
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
colorLevel_Lv1: (color) Color associeted with value when below Level 1.
colorLevel_Lv1_Lv2: (color) Color associeted with value when between Level 1 and 2.
colorLevel_Lv2_Lv3: (color) Color associeted with value when between Level 2 and 3.
colorLevel_Lv3_Lv4: (color) Color associeted with value when between Level 3 and 4.
colorLevel_Lv4_Lv5: (color) Color associeted with value when between Level 4 and 5.
colorLevel_Lv5: (color) Color associeted with value when above Level 5.
Returns: (void)
setCurrentColorValue(vc)
Set color to a current value, taking into account the previous value and its levels
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
Returns: (void)
setCurrentColorValue(vc, gradient)
Set color to a current value, taking into account the previous value.
Parameters:
vc: (valueColor) Object to associate a color with a value, taking into account the previous value
gradient
Returns: (void)
setCustomLevels(vc, level1, level2, level3, level4, level5)
Set boundaries for custom levels.
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
level1: (float) Boundary for level 1
level2: (float) Boundary for level 2
level3: (float) Boundary for level 3
level4: (float) Boundary for level 4
level5: (float) Boundary for level 5
Returns: (void)
getPeriodicColor(originalColor, density)
Returns a periodic color. Useful for creating dotted lines for example.
Parameters:
originalColor: (color) Original color.
density: (float) Density of color. Expression used in modulo to obtain the integer remainder.
If the remainder equals zero, the color appears, otherwise it remains hidden.
Returns: (color) Periodic color.
dinamicZone(source, sampleLength, pcntAbove, pcntBelow)
Get Dynamic Zones
Parameters:
source: (float) Source
sampleLength: (int) Sample Length
pcntAbove: (float) Calculates the top of the dynamic zone, considering that the maximum values are above x% of the sample
pcntBelow: (float) Calculates the bottom of the dynamic zone, considering that the minimum values are below x% of the sample
Returns: [float, float, float] A tuple with 3 series of values: (1) Upper Line of Dynamic Zone;
(2) Lower Line of Dynamic Zone; (3) Center of Dynamic Zone (x = 50%)
valueColorSpectrum
# Object to associate a color with a value, taking into account the previous value and its levels.
Fields:
currentValue
previousValue
level1
level2
level3
level4
level5
currentColorValue
colorLevel_Lv1
colorLevel_Lv1_Lv2
colorLevel_Lv2_Lv3
colorLevel_Lv3_Lv4
colorLevel_Lv4_Lv5
colorLevel_Lv5
theme
valueColor
# Object to associate a color with a value, taking into account the previous value
Fields:
currentValue
previousValue
currentColorValue
colorUp
colorDown
릴리즈 노트
v2 Added example source code릴리즈 노트
v3Updated:
setTheme(vc, colorLevel_Lv1, colorLevel_Lv1_Lv2, colorLevel_Lv2_Lv3, colorLevel_Lv3_Lv4, colorLevel_Lv4_Lv5, colorLevel_Lv5)
Set theme for levels (customized colors).
#### Usage
___
```
#region Theme for Histogram above 0
var string GRP_THEME_HISTOGRAM_ABOVE = 'Theme for Histogram above 0'
var colorHistogramUp_1 = input(color.new(#0064bb, 0), "", inline="2", group=GRP_THEME_HISTOGRAM_ABOVE)
var colorHistogramUp_2 = input(color.new(#007ce9, 0), "", inline="2", group=GRP_THEME_HISTOGRAM_ABOVE)
var colorHistogramUp_3 = input(color.new(#1893ff, 0), "", inline="2", group=GRP_THEME_HISTOGRAM_ABOVE)
var colorHistogramUp_4 = input(color.new(#46a9ff, 0), "", inline="2", group=GRP_THEME_HISTOGRAM_ABOVE)
var colorHistogramUp_5 = input(color.new(#75beff, 0), "", inline="2", group=GRP_THEME_HISTOGRAM_ABOVE)
var colorHistogramUp_6 = input(color.new(#91c9fa, 0), "", inline="2", group=GRP_THEME_HISTOGRAM_ABOVE)
// #endregion
vcHistogram = UTIL.valueColorSpectrum.new()
vcHistogram.currentValue := histogram
vcHistogram.previousValue := histogram[1]
UTIL.setCustomLevels(vcHistogram, 5, 10, 15, 20, 25)
UTIL.setTheme(vcHistogram, colorHistogramUp_1, colorHistogramUp_2, colorHistogramUp_3, colorHistogramUp_4, colorHistogramUp_5, colorHistogramUp_6)
```
___
Parameters:
vc: (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
colorLevel_Lv1: (color) Color associeted with value when below Level 1.
colorLevel_Lv1_Lv2: (color) Color associeted with value when between Level 1 and 2.
colorLevel_Lv2_Lv3: (color) Color associeted with value when between Level 2 and 3.
colorLevel_Lv3_Lv4: (color) Color associeted with value when between Level 3 and 4.
colorLevel_Lv4_Lv5: (color) Color associeted with value when between Level 4 and 5.
colorLevel_Lv5: (color) Color associeted with value when above Level 5.
Returns: (void)
릴리즈 노트
v4Added:
round(value)
Round a value between .999 and -.999. Function used in Fisher Transform.
Parameters:
value: (float) Value to be rounded.
Returns: (float) Value rounded.
릴리즈 노트
v7Extra (overloaded) method to use gradient with custom levels.
릴리즈 노트
v8- New themes added.
- The themes were reorganized by value ranges, in order to facilitate the choice, and future implementations:
10 to 15 → Spectrum Blue-Green-Red
20 to 21 → Monokai
30 to 31 → Spectrum White-Green-Red
40 to 41 → Green-Purple
50 to 51 → Blue-Red
60 to 61 → Blue-Yellow
70 to 71 → Green-Red
80 to 81 → Green
90 to 91 → Purple
100 to 107 → Blue
120 to 123 → Blue-Aqua
130 to 133 → Blue-Green
140 to 153 → Red
160 to 161 → Red-Yellow
170 to 171 → Red-White
180 to 185 → White-Black
릴리즈 노트
v10: Added themes 134, 135 (green-blue, blue-green), 162, 163 (yellow-red, red-yellow)파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
To contribute to my work:
⚡Bitcoin Lightning: forwardocean64@walletofsatoshi.com
🟠Bitcoin: bc1qv0j28wjsg6l8fdkphkmgfz4f55xpph893q0pdh
🔵PayPal: paypal.com/donate/?hosted_button_id=D9KRKY5HMSL9S
⚡Bitcoin Lightning: forwardocean64@walletofsatoshi.com
🟠Bitcoin: bc1qv0j28wjsg6l8fdkphkmgfz4f55xpph893q0pdh
🔵PayPal: paypal.com/donate/?hosted_button_id=D9KRKY5HMSL9S
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
To contribute to my work:
⚡Bitcoin Lightning: forwardocean64@walletofsatoshi.com
🟠Bitcoin: bc1qv0j28wjsg6l8fdkphkmgfz4f55xpph893q0pdh
🔵PayPal: paypal.com/donate/?hosted_button_id=D9KRKY5HMSL9S
⚡Bitcoin Lightning: forwardocean64@walletofsatoshi.com
🟠Bitcoin: bc1qv0j28wjsg6l8fdkphkmgfz4f55xpph893q0pdh
🔵PayPal: paypal.com/donate/?hosted_button_id=D9KRKY5HMSL9S
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.