waves█ OVERVIEW
This library intended for use in Bar Replay provides functions to generate various wave forms (sine, cosine, triangle, square) based on time and customizable parameters. Useful for testing and in creating oscillators, indicators, or visual effects.
█ FUNCTIONS
• getSineWave()
• getCosineWave()
• getTriangleWave()
• getSquareWave()
█ USAGE EXAMPLE
//@version=6
indicator("Wave Example")
import kaigouthro/waves/1
plot(waves.getSineWave(cyclesPerMinute=15))
█ NOTES
* barsPerSecond defaults to 10. Adjust this if not using 10x in Bar Replay.
* Phase shift is in degrees.
---
Library "waves"
getSineWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, phaseShift)
`getSineWave`
> Calculates a sine wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the sine wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the sine wave. Default is 0.0.
phaseShift (float) : (float) The phase shift of the sine wave in radians. Default is 0.0.
Returns: (float) The calculated sine wave value.
getCosineWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, phaseShift)
`getCosineWave`
> Calculates a cosine wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the cosine wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the cosine wave. Default is 0.0.
phaseShift (float) : (float) The phase shift of the cosine wave in radians. Default is 0.0.
Returns: (float) The calculated cosine wave value.
getTriangleWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, phaseShift)
`getTriangleWave`
> Calculates a triangle wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the triangle wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the triangle wave. Default is 0.0.
phaseShift (float) : (float) The phase shift of the triangle wave in radians. Default is 0.0.
Returns: (float) The calculated triangle wave value.
getSquareWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, dutyCycle, phaseShift)
`getSquareWave`
> Calculates a square wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the square wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the square wave. Default is 0.0.
dutyCycle (float) : (float) The duty cycle of the square wave (0.0 to 1.0). Default is 0.5 (50% duty cycle).
phaseShift (float) : (float) The phase shift of the square wave in radians. Default is 0.0.
Returns: (float) The calculated square wave value.
Generator
random_values█ OVERVIEW
This library provides helper functions for generating random values of various types, including numbers, letters, words, booleans, and arrays. It simplifies the creation of random data within Pine Script™ for testing, simulations, or other applications.
█ HOW TO USE
Import the library into your script:
import kaigouthro/random_values/1 as rv
Then, use the functions provided:
// Get a random integer between 5 and 15
int randInt = rv.intVal(5, 15)
// Generate a random word with 8 characters
string randWord = rv.word(8)
// Create a boolean array with 5 elements
array randBoolArray = rv.boolArray(5)
// And other options! See below for details.
█ FEATURES
• num(float min, float max) : Returns a random float between *min* and *max*. (Internal helper function, not exported).
• letter() : Returns a random lowercase letter (a-z).
• word(int size = 0) : Returns a random word. *size* specifies the length (default: random length between 3 and 10).
• words(int size = 20) : Returns a string of random words separated by spaces, where *size* specifies the number of words.
• boolVal() : Returns a random boolean (true or false).
• floatVal(float min = 0, float max = 100, int precision = 2) : Returns a random float with specified *min*, *max*, and *precision*.
• intVal(int min = 1, int max = 100) : Returns a random integer between *min* and *max*.
• stringArray(int size = 0) : Returns an array of random words. *size* specifies the array length (default: random between 3 and 10).
• floatArray(int size = 0, float min = 0, float max = 100, int precision = 2) : Returns an array of random floats with specified parameters. *size* determines the array length.
• intArray(int size = 0, int min = 1, int max = 100) : Returns an array of random integers with specified parameters. *size* determines the array length.
• boolArray(int size = 0) : Returns an array of random booleans. *size* specifies the array length (default: random between 3 and 10).
█ NOTES
* This library uses the `kaigouthro/into/2` library for type conversions. Make sure it's available.
* Default values are provided for most function parameters, offering flexibility in usage.
█ LICENSE
This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
```
**Changes and Rationale:**
* **OVERVIEW:** Clearly states the library's purpose.
* **HOW TO USE:** Provides essential import and usage instructions with Pine Script™ examples.
* **FEATURES:** Details each function with its parameters, types, and descriptions. Emphasizes *size*, *min*, *max*, and *precision* as common input parameters using italics. Uses custom bulleted lists.
* **NOTES:** Includes important information about dependencies and defaults.
* **LICENSE:** Directly links to the license URL using the proper ` ` tag.
* **Formatting:** Uses full block and em space for section titles, consistent bolding, and improved spacing for readability. Removes unnecessary blank lines.
This format improves clarity, making the library documentation easy to understand for TradingView users. Remember to test the rendering on TradingView to catch any formatting issues.
Library "random_values"
A library containing Random value generating helper functions.
letter()
Random letter generator.
Returns: (string) A random lowercase letter.
word(size)
Random word generator.
Parameters:
size (int) : (int) The desired length of the word. If 0 or not provided, a random length between 3 and 10 is used.
Returns: (string) A random word.
words(size)
Random words generator.
Parameters:
size (int) : (int) The number of words to generate. If 0 or not provided, a random number between 3 and 10 is used.
Returns: (string) A string of random words separated by spaces.
boolVal()
Random boolean generator.
Returns: (bool) A random boolean value (true or false).
floatVal(min, max, precision)
Random float number generator.
Parameters:
min (float) : (float) The minimum float value. Defaults to 0.
max (float) : (float) The maximum float value. Defaults to 100.
precision (int) : (int) The number of decimal places. Defaults to 2.
Returns: (float) A random float number.
intVal(min, max)
Random integer number generator.
Parameters:
min (int) : (int) The minimum integer value. Defaults to 1.
max (int) : (int) The maximum integer value. Defaults to 100.
Returns: (int) A random integer number.
stringArray(size)
Random string array generator.
Parameters:
size (int) : (int) The desired size of the array. If 0 or not provided, a random size between 3 and 10 is used.
Returns: (array) An array of random words.
floatArray(size, min, max, precision)
Random float array generator.
Parameters:
size (int) : (int) The desired size of the array. If 0 or not provided, a random size between 3 and 10 is used.
min (float) : (float) The minimum float value. Defaults to 0.
max (float) : (float) The maximum float value. Defaults to 100.
precision (int) : (int) The number of decimal places. Defaults to 2.
Returns: (array) An array of random float numbers.
intArray(size, min, max)
Random integer array generator.
Parameters:
size (int) : (int) The desired size of the array. If 0 or not provided, a random size between 3 and 10 is used.
min (int) : (int) The minimum integer value. Defaults to 1.
max (int) : (int) The maximum integer value. Defaults to 100.
Returns: (array) An array of random integer numbers.
boolArray(size)
Random boolean array generator.
Parameters:
size (int) : (int) The desired size of the array. If 0 or not provided, a random size between 3 and 10 is used.
Returns: (array) An array of random boolean values.
lib_colorLibrary "lib_color"
offset_mono(original, offset, transparency)
get offset color
Parameters:
original (simple color) : original color
offset (float) : offset for new color
transparency (float) : transparency for new color
Returns: offset color
lib_colorsLibrary "lib_colors"
offset_mono(original, offset, transparency)
get offset color
Parameters:
original (simple color) : original color
offset (float) : offset for new color
transparency (float) : transparency for new color
Returns: offset color
curveLibrary "curve"
Regression array Creator. Handy for weights, Auto Normalizes array while holding curves.
curve(_size, _power)
Curve Regression Values Tool
Parameters:
_size : (float) Number of Steps required (float works, future consideration)
_power : (float) Strength of value decrease
Returns: (float ) Array of multipliers from 1 downwards to 0.