Punchline_LibLibrary "Punchline_Lib"
roundSmart(float) Truncates decimal points of a float value based on the amount of digits before the decimal point
Parameters:
float : _value any number
Returns: float
tostring_smart(float) converts a float to a string, intelligently cutting off decimal points
Parameters:
float : _value any number
Returns: string
Indicators and strategies
FunctionNNLayerLibrary "FunctionNNLayer"
Generalized Neural Network Layer method.
function(inputs, weights, n_nodes, activation_function, bias, alpha, scale) Generalized Layer.
Parameters:
inputs : float array, input values.
weights : float array, weight values.
n_nodes : int, number of nodes in layer.
activation_function : string, default='sigmoid', name of the activation function used.
bias : float, default=1.0, bias to pass into activation function.
alpha : float, default=na, if required to pass into activation function.
scale : float, default=na, if required to pass into activation function.
Returns: float
FunctionNNPerceptronLibrary "FunctionNNPerceptron"
Perceptron Function for Neural networks.
function(inputs, weights, bias, activation_function, alpha, scale) generalized perceptron node for Neural Networks.
Parameters:
inputs : float array, the inputs of the perceptron.
weights : float array, the weights for inputs.
bias : float, default=1.0, the default bias of the perceptron.
activation_function : string, default='sigmoid', activation function applied to the output.
alpha : float, default=na, if required for activation.
scale : float, default=na, if required for activation.
@outputs float
MLActivationFunctionsLibrary "MLActivationFunctions"
Activation functions for Neural networks.
binary_step(value) Basic threshold output classifier to activate/deactivate neuron.
Parameters:
value : float, value to process.
Returns: float
linear(value) Input is the same as output.
Parameters:
value : float, value to process.
Returns: float
sigmoid(value) Sigmoid or logistic function.
Parameters:
value : float, value to process.
Returns: float
sigmoid_derivative(value) Derivative of sigmoid function.
Parameters:
value : float, value to process.
Returns: float
tanh(value) Hyperbolic tangent function.
Parameters:
value : float, value to process.
Returns: float
tanh_derivative(value) Hyperbolic tangent function derivative.
Parameters:
value : float, value to process.
Returns: float
relu(value) Rectified linear unit (RELU) function.
Parameters:
value : float, value to process.
Returns: float
relu_derivative(value) RELU function derivative.
Parameters:
value : float, value to process.
Returns: float
leaky_relu(value) Leaky RELU function.
Parameters:
value : float, value to process.
Returns: float
leaky_relu_derivative(value) Leaky RELU function derivative.
Parameters:
value : float, value to process.
Returns: float
relu6(value) RELU-6 function.
Parameters:
value : float, value to process.
Returns: float
softmax(value) Softmax function.
Parameters:
value : float array, values to process.
Returns: float
softplus(value) Softplus function.
Parameters:
value : float, value to process.
Returns: float
softsign(value) Softsign function.
Parameters:
value : float, value to process.
Returns: float
elu(value, alpha) Exponential Linear Unit (ELU) function.
Parameters:
value : float, value to process.
alpha : float, default=1.0, predefined constant, controls the value to which an ELU saturates for negative net inputs. .
Returns: float
selu(value, alpha, scale) Scaled Exponential Linear Unit (SELU) function.
Parameters:
value : float, value to process.
alpha : float, default=1.67326324, predefined constant, controls the value to which an SELU saturates for negative net inputs. .
scale : float, default=1.05070098, predefined constant.
Returns: float
exponential(value) Pointer to math.exp() function.
Parameters:
value : float, value to process.
Returns: float
function(name, value, alpha, scale) Activation function.
Parameters:
name : string, name of activation function.
value : float, value to process.
alpha : float, default=na, if required.
scale : float, default=na, if required.
Returns: float
derivative(name, value, alpha, scale) Derivative Activation function.
Parameters:
name : string, name of activation function.
value : float, value to process.
alpha : float, default=na, if required.
scale : float, default=na, if required.
Returns: float
MLLossFunctionsLibrary "MLLossFunctions"
Methods for Loss functions.
mse(expects, predicts) Mean Squared Error (MSE) " MSE = 1/N * sum ((y - y')^2) ".
Parameters:
expects : float array, expected values.
predicts : float array, prediction values.
Returns: float
binary_cross_entropy(expects, predicts) Binary Cross-Entropy Loss (log).
Parameters:
expects : float array, expected values.
predicts : float array, prediction values.
Returns: float
Debug_Window_LibraryLibrary "Debug_Window_Library"
Provides a framework for logging debug information to a window on the chart.
consoleWrite(txt, maxLines) Adds a line of text to the debug window. The text is rolled off the bottom of the window as it fills up.
Parameters:
txt : - this is the text to be appended to the window
maxLines : - this is the size of the window in lines.
Returns: nothing
The example above shows the close value for the last 10 bars.
Here's the code.
//@version=5
indicator("Debug Library test Script", overlay=true)
import sp2432/Debug_Window_Library/1 as dbg
// add some text to the debug window
dbg .consoleWrite( str .tostring(close), 10)
PointsLibrary "Points"
Provides functions for simplifying operations with collections of x+y coordinates. Where x is typically a bar index or time (millisecond) value.
new(size) Creates two arrays. One for X (int ) and another for Y (float ).
Parameters:
size : The initial size of the arrays.
size(xA, yA) Checks the size of the arrays and if they're equal returns the size.
Parameters:
xA : The X array.
yA : The Y array.
get(xA, yA, index) Gets the X and Y values of the arrays at the index.
Parameters:
xA : The X array.
yA : The Y array.
index : The index.
Returns:
set(xA, yA, index, x, y) Sets the X and Y values of the arrays at the index.
Parameters:
xA : The X array.
yA : The Y array.
index : The index.
x : The x value.
y : The y value.
Returns:
push(xA, yA, x, y) Adds X and Y values to the end of the arrays (as the last element).
Parameters:
xA : The X array.
yA : The Y array.
x : The x value.
y : The y value.
Returns:
unshift(xA, yA, x, y) Adds X and Y values to the beginning of the arrays (as the first element).
Parameters:
xA : The X array.
yA : The Y array.
x : The x value.
y : The y value.
Returns:
insert(xA, yA, index, x, y) Inserts X and Y values to the arrays at the index.
Parameters:
xA : The X array.
yA : The Y array.
index : The index to insert at.
x : The x value.
y : The y value.
Returns:
pop(xA, yA) Removes the last element from the arrays and returns their value.
Parameters:
xA : The X array.
yA : The Y array.
Returns:
shift(xA, yA) Removes the first element from the arrays and returns their value.
Parameters:
xA : The X array.
yA : The Y array.
Returns:
remove(xA, yA) Removes the element from the arrays at the index and returns their value.
Parameters:
xA : The X array.
yA : The Y array.
Returns:
first(xA, yA) Gets the X and Y values of the first element.
Parameters:
xA : The X array.
yA : The Y array.
Returns:
last(xA, yA) Gets the X and Y values of the last element.
Parameters:
xA : The X array.
yA : The Y array.
Returns:
allIndexesBetween(xA, lo, hi, start, ordered) Gets the indexes that have values at or above the low value and below the high value.
Parameters:
xA : The X array.
lo : The inclusive low value.
hi : The excluded hi value.
start : The optional index to start the backwards search.
ordered : If true, the search ends when the first value is found that is less than the low.
lastIndexBetween(xA, lo, hi, start, ordered) Gets the first found from the end that has a value at or above the low value and below the high value.
Parameters:
xA : The X array.
lo : The inclusive low value.
hi : The excluded hi value.
start : The optional index to start the backwards search.
ordered : If true, the search ends when the first value is found that is less than the low.
lastIndexBelow(xA, hi, start) Gets the first found from the end that has a value below the high value.
Parameters:
xA : The X array.
hi : The excluded hi value.
start : The optional index to start the backwards search.
eHarmonicpatternsLibrary "eHarmonicpatterns"
Library provides an alternative method to scan harmonic patterns. This is helpful in reducing iterations
scan_xab(bcdRatio, err_min, err_max, patternArray) Checks if bcd ratio is in range of any harmonic pattern
Parameters:
bcdRatio : AB/XA ratio
err_min : minimum error threshold
err_max : maximum error threshold
patternArray : Array containing pattern check flags. Checks are made only if flags are true. Upon check flgs are overwritten.
scan_abc_axc(abcRatio, axcRatio, err_min, err_max, patternArray) Checks if abc or axc ratio is in range of any harmonic pattern
Parameters:
abcRatio : BC/AB ratio
axcRatio : XC/AX ratio
err_min : minimum error threshold
err_max : maximum error threshold
patternArray : Array containing pattern check flags. Checks are made only if flags are true. Upon check flgs are overwritten.
scan_bcd(bcdRatio, err_min, err_max, patternArray) Checks if bcd ratio is in range of any harmonic pattern
Parameters:
bcdRatio : CD/BC ratio
err_min : minimum error threshold
err_max : maximum error threshold
patternArray : Array containing pattern check flags. Checks are made only if flags are true. Upon check flgs are overwritten.
scan_xad_xcd(xadRatio, xcdRatio, err_min, err_max, patternArray) Checks if xad or xcd ratio is in range of any harmonic pattern
Parameters:
xadRatio : AD/XA ratio
xcdRatio : CD/XC ratio
err_min : minimum error threshold
err_max : maximum error threshold
patternArray : Array containing pattern check flags. Checks are made only if flags are true. Upon check flgs are overwritten.
isHarmonicPattern(x, a, c, c, d, flags, errorPercent) Checks for harmonic patterns
Parameters:
x : X coordinate value
a : A coordinate value
c : B coordinate value
c : C coordinate value
d : D coordinate value
flags : flags to check patterns. Send empty array to enable all
errorPercent : Error threshold
Returns: Array of boolean values which says whether valid pattern exist and array of corresponding pattern names
isHarmonicProjection(x, a, c, c, flags, errorPercent) Checks for harmonic pattern projection
Parameters:
x : X coordinate value
a : A coordinate value
c : B coordinate value
c : C coordinate value
flags : flags to check patterns. Send empty array to enable all
errorPercent : Error threshold
Returns: Array of boolean values which says whether valid pattern exist and array of corresponding pattern names
OteHmacSha256Library "OteHmacSha256"
Library to use HMAC SHA-256 by OgahTerkenal
hmac_sha256(string) HMAC SHA-256
Parameters:
string : msg String to be hashed
Returns: Return a hashed string in hex format and an array of 8 32 bits integer
Library to use HMAC SHA-256 for authenticating alert message going out from TradingView.
It has limitation on allowed characters (because PineScript cannot access the underlying bits of each ASCII) from ASCII 32 to 126 only.
Usage Example section at the end of the source code pretty much tell everything about this library.
General example as how to import to your PineScript code is not included (please refer to the PineScript manual).
StocksDeveloper_AutoTraderWebLibrary "StocksDeveloper_AutoTraderWeb"
AutoTrader Web trading API functions implementation for Trading View.
preparePlaceOrderJson(account, symbol, group, variety) Prepare a place order json
Parameters:
account : Pseudo or group account number
symbol : AutoTrader Web's stock/derivative symbol
group : Set it to true to use group account (Default: false)
variety : Variety (Default: REGULAR)
Returns: A json message for the given order data
preparePlaceOrderAlertUsingOrderJson(orderJsonArray) Prepare a place order alert message using order json array
Parameters:
orderJsonArray : Order json can contain one or more orders
Returns: A complete alert message to place orders
preparePlaceOrderAlertMessage(account, symbol, group, variety, validity) Prepare a place order alert json message
Parameters:
account : Pseudo or group account number
symbol : AutoTrader Web's stock/derivative symbol
group : Set it to true to use group account (Default: false)
variety : Variety (Default: REGULAR)
validity : Validity (Default: DAY)
Returns: A complete alert message to place orders
Woodwind VaultLibrary "WoodwindVault"
Woodwind Vault provides reusable functions to support Thange Woodwind Playbook execution.
getHighestHighAndLowestLow(period) determines the highest-high and lowest-low for the specified time interval.
Parameters:
period : int, the time interval for finding the highest-high and lowest-low.
Returns: float, the highest-high and lowest-low of the candles in the specified period.
findEquilibrium() projects a one glance view of the entire resistance net faced by the price. It does so by computing different equilibrium points for the price.
Returns: longTermEquilibriumB float, the midpoint of highest-high and lowest-low of the candles in last longTermPeriod.
getGlance(fast, slow) glances over the 2 equilibrium points from moving averages and establishes whether its bullish or bearish.
Parameters:
fast : float, the fast moving point.
slow : float, the slow moving point.
Returns: string, it is "bullish" if fast moving point is over the slow moving point o/w returns "bearish".
positionRelativeToLevel(point, level) determines first point's position w.r.t a specified level.
Parameters:
point : float, the first point (typically a fast moving average).
level : float, the second point acting as a level (typically a slow moving average).
Returns: string, the above/below/at position w.r.t level.
positionRelativeToRange(point, fromLevel, toLevel) determines first point's position w.r.t a range (typically a resistance band).
Parameters:
point : float, the first point.
fromLevel : float, the from-range which is typically a fast moving line.
toLevel : float, the to-range which is typically a slow moving line.
Returns: string, the above/below/within range.
Thange VaultLibrary "ThangeVault"
Thange Vault is a collection of utility functions required by the Thange Woodwind Playbook.
debug(msg) Print debug information
Parameters:
msg : message to be logged on console
Returns: nothing
tickFormat() Create a string template to restrict stop-loss, take-profit level precision to ticks.
Returns: A string format template
hashmapsA simple hashmap implementation for pinescript.
It gets your string array and transforms it into a hashmap.
Before using it you need to initialize your array with the size you need for your specific case since the size is not dynamic.
To use it, first you need to import it the following way:
> import marspumpkin/hashmaps/1
Then, initialize your array with the size needed for your specific case:
> hashmap = array.new_string(10000)
After that you can call:
> hashmaps.put() and hashmaps.get()
Passing in the array(hashmap), key and value.
I hope this helps you in your pinescript journey.
psonPineScript Object Notation
A workaround not having objects in pinescript.
This is a Json-look-alike interpreter.
Format: "attr=value:attr1=value1:attr2=value2".
You can add new attributes, get the value in those attributes, set new values to existing attributes and check if an attribute exists.
DivergenceLibrary "Divergence"
Calculates a divergence between 2 series
bullish(_src, _low, depth) Calculates bullish divergence
Parameters:
_src : Main series
_low : Comparison series (`low` is used if no argument is supplied)
depth : Fractal Depth (`2` is used if no argument is supplied)
Returns: 2 boolean values for regular and hidden divergence
bearish(_src, _high, depth) Calculates bearish divergence
Parameters:
_src : Main series
_high : Comparison series (`high` is used if no argument is supplied)
depth : Fractal Depth (`2` is used if no argument is supplied)
Returns: 2 boolean values for regular and hidden divergence
I created this library to plug and play divergences in any code.
You can create a divergence indicator from any series you like.
Fractals are used to pinpoint the edge of the series. The higher the depth, the slower the divergence updates get.
My Plain Stochastic Divergence uses the same calculation. Watch it in action.
CRCIndicators - Common IndicatorsLibrary "CRCIndicators"
price_from_to()
price_change_from_to()
roi()
roi_from_to()
The Divergent LibraryLibrary "TheDivergentLibrary"
The Divergent Library is only useful when combined with the Pro version of The Divergent - Advanced divergence indicator . This is because the Basic (free) version of The Divergent does not expose the "Divergence Signal" value.
Usage instructions:
1. Create a new chart
2. Add The Divergent (Pro) indicator to your chart
3. Create a new strategy, import this library, add a "source" input, link it to "The Divergent: Divergence Signal", and use the library to decode the divergence signals from The Divergent (You can find example strategy code published in our profile)
4. Act on the divergences signalled by The Divergent
---
isRegularBullishEnabled(context) Returns a boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
isHiddenBullishEnabled(context) Returns a boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
isRegularBearishEnabled(context) Returns a boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
isHiddenBearishEnabled(context) Returns a boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
getPivotDetectionSource(context) Returns the 'Pivot Detection Source' setting of The Divergent. The returned value can be either "Oscillator" or "Price".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Oscillator" or "Price".
getPivotDetectionMode(context) Returns the 'Pivot Detection Mode' setting of The Divergent. The returned value can be either "Bodies" or "Wicks".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Bodies" or "Wicks".
isLinked(context) Returns a boolean value indicating the link status to The Divergent indicator.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating the link status to The Divergent indicator.
init(firstBarSignal, displayLinkStatus, debug) Initialises The Divergent Library's context with the signal produced by The Divergent on the first bar. The value returned from this function is called the "context of The Divergent Library". Some of the other functions of this library requires you to pass in this context.
Parameters:
firstBarSignal : The signal from The Divergent indicator on the first bar.
displayLinkStatus : A boolean value indicating whether the Link Status window should be displayed in the bottom left corner of the chart. Defaults to true.
debug : A boolean value indicating whether the Link Status window should display debug information. Defaults to false.
Returns: A bool array containing the context of The Divergent Library.
processSignal(signal) Processes a signal from The Divergent and returns a 5-tuple with the decoded signal: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd]. `divergenceType` can be one of the following values: na → No divergence was detected, 1 → Regular Bullish, 2 → Regular Bullish early, 3 → Hidden Bullish, 4 → Hidden Bullish early, 5 → Regular Bearish, 6 → Regular Bearish early, 7 → Hidden Bearish, 8 → Hidden Bearish early.
Parameters:
signal : The signal from The Divergent indicator.
Returns: A 5-tuple with the following values: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd].
Dictionary/Object LibraryThis Library is aimed to mitigate the limitation of Pinescript having only one structured data type which is only arrays.
It lacks data types like Dictionaries(in Python) or Object (in JS) that are standard for other languages. Tuples do exist, but it hardly solves any problem.
Working only with Arrays could be overwhelming if your codebase is large. I looked for alternatives to arrays but couldn't find any library.
So I coded it myself and it's been working good for me. So I wanted to share it with you all.
What does it do:
==================
If you are familiar with Python or Javascript, this library tries to immimate Object/Dictonary like structure with Key Value Pairs.
For Example:
object= {name:"John Doe", age: 28 , org: "PineCoders"}
And then it also tries to immitate the Array of Objects (I call it Stack)
like this:
stack= Array({name:"John Doe", age: 28 , org: "PineCoders"},
{name:"Adam Smith", age: 32 , org: "PineCoders"},
{name:"Paragjyoti Deka", age: 25 , org: "PineCoders"})
So there are basically two ideas: Objects and Stacks.
But it looks whole different in Pinescript for obvious reasons.
Limitation:
The major limitation I couldn't overcome was that, for all of the values: both input and return values for properties will be of string type.
This is due to the limiation of Pinecsript that there is no way to return a value on a if-else statement dynamically with different data types.
And as the input data type must be explicitly defined when exporting the library functions, only string inputs are allowed.
Now that doesn't mean you won't be able to use integer, float or boolens, you just need to pass the string value for it using str.tostring() method.
And the output for the getter functions will be in strings as well. But I have added some type conversion methods that you could use from this library itself.
From String to Float, String To Integer and String to Boolean: these three methods are included in this library.
So basically the whole library is based on a manipulatiion of Array of strings under the hood.
///////////////
Usage
///////////////
Import the library using this statement:
import paragjyoti2012/STR_Dict_Lib/4 as DictLib
Objects
First define an object using this method:
for eample:
object1= DictLib.init("name=John,age=26,org=")
This is similar to
object1= {name:"John",age:"26", org:""} in JS or Python
Just like we did here in for "org", you can set initital value to "". But remember to pass string values, even for a numerical properties, like here in "age".
You can use "age="+str.tostring(age). If you find it tedious, you can always add properties later on using .set() method.
So it could also be initiated like this
object= DictLib.init("name=John")
and later on
DictLib.set(object1,"age", str.toString(age))
DictLib.set(object1,"org", "PineCoders")
The getter function looks like this
age= DictLib.get(object1,"age")
name=DictLib.get(object1,"name")
The first argument for all methods .get, .set, and .remove is the pointer (name of the object).
///////////////////////////
Array Of Objects (Stacks)
///////////////////////////
As I mentioned earlier, I call the array of objects as Stack.
Here's how to initialize a Stack.
stack= DictLib.initStack(object1)
The .initStack() method takes an object pointer as argument. It simply converts the array into a string and pushes it into the newly created stack.
Rest of all the methods for Stacks, takes the stack pointer as it's first arument.
For example:
DictLib.pushStack(stack,object2)
The second argument here is the object pointer. It adds the object to it's stack. Although it might feel like a two dimentional array, it's actually an one dimentional array with string values.
Under the hood, it looks like this
////////////////////
Methods
////////////////////
For Objects
-------------------
init() : Initializes the object.
params: (string) e.g
returns: The object ( )
example:
object1=DictLib.init("name=John,age=26,org=")
...................
get() : Returns the value for given property
params: (string object_pointer, string property)
returns: string
example:
age= DictLib.get(object1,"age")
.......................
set() : Adds a new property or updates an existing property
params: (string object_pointer, string property, string value)
returns: void
example:
DictLib.set(object1,"age", str.tostring(29))
........................
remove() : Removes a property from the object
params : (string object_pointer, string property)
returns: void
example:
DictLib.set(object1,"org")
........................
For Array Of Objects (Stacks)
-------------------------------
initStack() : Initializes the stack.
params: (string object_pointer) e.g
returns: The Stack
example:
stack= DictLib.initStack(object1)
...................
pushToStack() : Adds an object at at last index of the stack
params: (string stack_pointer, string object_pointer)
returns: void
example:
DictLib.pushToStack(stack,object2)
.......................
popFromStack() : Removes the last object from the stack
params: (string stack_pointer)
returns: void
example:
DictLib.popFromStack(stack)
.......................
insertToStack() : Adds an object at at the given index of the stack
params: (string stack_pointer, string object_pointer, int index)
returns: void
example:
DictLib.insertToStack(stack,object3,1)
.......................
removeFromStack() : Removes the object from the given index of the stack
params: (string stack_pointer, int index)
returns: void
example:
DictLib.removeFromStack(stack,2)
.......................
getElement () : Returns the value for given property from an object in the stack (index must be given)
params: (string stack_pointer, int index, string property)
returns: string
example:
ageFromObject1= DictLib.getElement(stack,0,"age")
.......................
setElement() : Updates an existing property of an object in the stack (index must be given)
params: (string stack_pointer, int index, string property, string value)
returns: void
example:
DictLib.setElement(stack,0,"age", str.tostring(32))
........................
includesElement() : Checks if any object exists in the stack with the given property-value pair
params : (string stack_pointer, string property, string value)
returns : Boolean
example:
doesExist= DictLib.includesElement(stack,"org","PineCoders")
........................
searchStack() : Search for a property-value pair in the stack and returns it's index
params: (stringp stack_pointer, string property, string value)
returns: int (-1 if doesn't exist)
example:
index= DictLib.searchElement(stack,"org","PineCoders")
///////////////////////
Type Conversion Methods
///////////////////////
strToFloat() : Converts String value to Float
params: (string value)
returns: float
example:
floatVal= DictLib.strToFloat("57.96")
.............................
strToInt() : Converts String value to Integer
params: (string value)
returns: int
example:
intVal= DictLib.strToFloat("45")
.............................
strToBool() : Converts String value to Boolean
params: (string value)
returns: boolean
example:
boolVal= DictLib.strToBool("true")
.............................
Points to remember
...............
1. Always pass string values as arguments.
2. The return values will be of type string, so convert them before to avoid typecasting conflict.
3. Horses can't vomit.
More Informations
====================
Yes, You can store this objects and stacks for persisting through the iterations of a script across successive bars.
You just need to set the variable using "var" keyword. Remember this objects and stacks are just arrays,
so any methods and properties an array have it pinescript, would be applicable for objects and stacks.
It can also be used in security functions without any issues for MTF Analysis.
If you have any suggestions or feedback, please comment on the thread, I would surely be happy to help.
Signal_transcoder_libraryLibrary "Signal_transcoder_library"
This is my 2nd iteration for sending Signals via Plots. (first one was the 8bit Version)
Now a cleaner approach (thanks for the hints @lonesometheblue)
_16bit_encode()
Input a 16 bool Array
Outputs a Float for transmitting via Plot
_16bit_decode()
Input a Float from plot via input-mapping
Outputs a Array of 16 bools
Future Ideas:
Transmitting 2-4 Ints (-127 to 127) and Bools
InterpolationLibrary "Interpolation"
Functions for interpolating values. Can be useful in signal processing or applied as a sigmoid function.
linear(k, delta, offset, unbound) Returns the linear adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the line the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
quadIn(k, delta, offset, unbound) Returns the quadratic (easing-in) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
quadOut(k, delta, offset, unbound) Returns the quadratic (easing-out) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
quadInOut(k, delta, offset, unbound) Returns the quadratic (easing-in-out) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
cubicIn(k, delta, offset, unbound) Returns the cubic (easing-in) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
cubicOut(k, delta, offset, unbound) Returns the cubic (easing-out) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
cubicInOut(k, delta, offset, unbound) Returns the cubic (easing-in-out) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
expoIn(k, delta, offset, unbound) Returns the exponential (easing-in) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
expoOut(k, delta, offset, unbound) Returns the exponential (easing-out) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
expoInOut(k, delta, offset, unbound) Returns the exponential (easing-in-out) adjusted value.
Parameters:
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
using(fn, k, delta, offset, unbound) Returns the adjusted value by function name.
Parameters:
fn : The name of the function. Allowed values: linear, quadIn, quadOut, quadInOut, cubicIn, cubicOut, cubicInOut, expoIn, expoOut, expoInOut.
k : A number (float) from 0 to 1 representing where the on the curve the value is.
delta : The amount the value should change as k reaches 1.
offset : The start value.
unbound : When true, k values less than 0 or greater than 1 are still calculated. When false (default), k values less than 0 will return the offset value and values greater than 1 will return (offset + delta).
FunctionPeakDetectionLibrary "FunctionPeakDetection"
Method used for peak detection, similar to MATLAB peakdet method
function(sample_x, sample_y, delta) Method for detecting peaks.
Parameters:
sample_x : float array, sample with indices.
sample_y : float array, sample with data.
delta : float, positive threshold value for detecting a peak.
Returns: tuple with found max/min peak indices.
CRC.lib Log FunctionsLibrary "CRCLog"
default_params() Returns default high/low intercept/slope parameter values for Bitcoin that can be adjusted and used to calculate new Regression Log lines
log_regression() Returns set of (fib) spaced lines representing log regression (default values attempt fitted to INDEX:BTCUSD genesis-2021)