signalLib_customLibrary "signalLib_custom"
f_signal(low, high, depth, deviation, backstep)
Parameters:
low (float)
high (float)
depth (int)
deviation (int)
backstep (int)
指标和策略
publicRocketScience21This returns a Rocket Science Instantaneous Trendline from a price source.
An example of a good call:
import privatepizza111/publicSourceInput/1 as srcIn
import privatepizza111/publicRocketScience21/1 as rocketSci21
//@variable
array src = array.new_float(13, array.get(srcIn.priceStream(13, hlc3), 0))
//@variable
array twentyOne = array.new_float(21, array.get(rocketSci21.instant(array.get(src, 0)), 0))
publicSourceInputReturns object/pointed array of price data. An example of a good call.
import privatepizza111/publicSourceInput/1 as srcIn
array src = array.new_float(13, array.get(srcIn.priceStream(13, hlc3), 0))
berlinLibrary "berlin"
f_signalLib(lowSeries, highSeries, depth, deviation, backstep)
Parameters:
lowSeries (float)
highSeries (float)
depth (int)
deviation (int)
backstep (int)
CapitalManagementLibrary "CapitalManagement"
TODO: Manage the capital
order_volume(percent_risk, order_entry_price, stop_loss_price)
: Function to calculate order volume according to give risk percent_risk
Parameters:
percent_risk (float)
order_entry_price (float)
stop_loss_price (float)
calculate_takeprofit_price(entry_price, stop_loss_price, risk_reward)
: Function to calculate take profit price according to given risk:reward ratio
Parameters:
entry_price (float)
stop_loss_price (float)
risk_reward (float)
Returns: Return take profit value according to given risk:reward ratio
fontilabLibrary "fontilab"
Provides function's indicators for pivot - trend - resistance.
getHighLowFromNbCandles(isLong, nbCandles)
to get last high/low (handle multiple rsiOver in a row)
Parameters:
isLong (bool)
nbCandles (int)
getElIntArrayFromEnd(arrayWanted, nbLast)
Get the last element of an int array.
Parameters:
arrayWanted (array)
nbLast (int)
getElFloatArrayFromEnd(arrayWanted, nbLast)
Get the last element of an float array.
Parameters:
arrayWanted (array)
nbLast (int)
getElBoolArrayFromEnd(arrayWanted, nbLast)
Get the last element of a bool array.
Parameters:
arrayWanted (array)
nbLast (int)
dema(src, length)
Double Exponential Average.
Parameters:
src (float)
length (simple int)
tema(src, len)
Tripple exponential moving average.
Parameters:
src (float)
len (simple int)
zlSma(src, len)
calculate Zero Lag SMA.
Parameters:
src (float)
len (simple int)
zlDema(src, len)
Zero-lag Dema.
Parameters:
src (float)
len (simple int)
zlTema(src, len)
Zero-lag Tema.
Parameters:
src (float)
len (simple int)
mcginley(src, len)
McGinley Dynamic
Parameters:
src (float)
len (simple int)
multiMa(source, length, type)
Select between multiple ma type.
Parameters:
source (float)
length (simple int)
type (string)
getSlope(source)
Get source slope.
Parameters:
source (float)
getMZL(src, lengthFast, lengthSlow)
Parameters:
src (float)
lengthFast (simple int)
lengthSlow (simple int)
getRSI(source, rsiLength, maType, maLength)
get RSI.
Parameters:
source (float)
rsiLength (simple int)
maType (string)
maLength (simple int)
getMACD(source, fastLength, slowLength, signalLength, maType)
get MACD.
Parameters:
source (float)
fastLength (simple int)
slowLength (simple int)
signalLength (simple int)
maType (string)
demaSupertrend(lenAtr, lenMas, mult, highP, lowP, closeP)
to get Dema supertrend.
Parameters:
lenAtr (simple int)
lenMas (simple int)
mult (float)
highP (float)
lowP (float)
closeP (float)
getTrendBands(src, delta)
get trend bands.
Parameters:
src (float)
delta (float)
getInterTrend(src, upB, lowB, pLast, tDirUp, pDirStrike, isPFound, isHighP, nStrike, rPerOffset, depth)
get trend brand from pivot/highs lows interpretation.
Parameters:
src (float)
upB (float)
lowB (float)
pLast (float)
tDirUp (bool)
pDirStrike (int)
isPFound (bool)
isHighP (bool)
nStrike (int)
rPerOffset (float)
depth (int)
pivots(src, length, isHigh)
Detecting pivot points (and returning price + bar index.
Parameters:
src (float) : The chart we analyse.
length (float)
isHigh (bool) : lookging for high if true, low otherwise.
Returns: The bar index and the price of the pivot.
calcDevThreshold(tresholdMultiplier, closePrice)
Calculate deviation threshold for identifying major swings.
Parameters:
tresholdMultiplier (float) : Usefull to equilibrate the calculate.
closePrice (float) : Close price of the chart wanted.
Returns: The deviation threshold.
calcDev(basePrice, price)
Custom function for calculating price deviation for validating large moves.
Parameters:
basePrice (float) : The reference price.
price (float) : The price tested.
Returns: The deviation.
pivotFoundWithLines(dev, isHigh, index, price, dev_threshold, isHighLast, pLast, iLast, lineLast)
Detecting pivots that meet our deviation criteria.
Parameters:
dev (float) : The deviation wanted.
isHigh (bool) : The type of pivot tested (high or low).
index (int) : The Index of the pivot tested.
price (float) : The chart price wanted.
dev_threshold (float) : The deviation treshold.
isHighLast (bool) : The type of last pivot.
pLast (float) : The pivot price last.
iLast (int) : Index of the last pivot.
lineLast (line) : The lst line.
Returns: The Line and bool is pivot High.
getDeviationPivots(thresholdMultiplier, depth, lineLast, isHighLast, iLast, pLast, deleteLines, closePrice, highPrice, lowPrice)
Get pivot that meet our deviation criteria.
Parameters:
thresholdMultiplier (float) : The treshold multiplier.
depth (float) : The depth to calculate pivot.
lineLast (line) : The last line.
isHighLast (bool) : The type of last pivot
iLast (int) : Index of the last pivot.
pLast (float) : The pivot price last.
deleteLines (bool) : If the line are draw or not.
closePrice (float) : The chart close price.
highPrice (float) : The chart high price.
lowPrice (float) : The chart low price.
Returns: All pivot the informations.
isTrendContinuation(isTrendUp, arrayBounds, lastPrice, precision)
Check if last price is between bounds array.
Parameters:
isTrendUp (bool) : Is actual trend up.
arrayBounds (array) : The trend array.
lastPrice (float) : The pivot Price that just be found.
precision (float) : The percent we add to actual bounds to validate a move.
Returns: na if price is between bounds, true if continuation, false if not.
getTrendPivots(trendBarIndexes, trendPrices, trendPricesIsHigh, interBarIndexes, interPrices, interPricesIsHigh, isTrendHesitate, isTrendUp, trendPrecision, pLast, iLast, isHighLast)
Function to update array and trend related to pivot trend interpretation.
Parameters:
trendBarIndexes (array) : The array trend bar index.
trendPrices (array) : The array trend price.
trendPricesIsHigh (array) : The array trend is high.
interBarIndexes (array) : The array inter bar index.
interPrices (array) : The array inter price.
interPricesIsHigh (array) : The array inter ishigh.
isTrendHesitate (bool) : The actual status of is trend hesitate.
isTrendUp (bool) : The actual status of is trend up.
trendPrecision (float) : The var precision to add in "iscontinuation" function.
pLast (float) : The last pivot price.
iLast (int) : The last pivot bar index.
isHighLast (bool) : The last pivot "isHigh".
Returns: trend & inter arrays, is trend hesitate, is trend up.
drawBoundLines(startIndex, startPrice, endIndex, endPrice, breakingPivotIndex, breakingPivotPrice, isTrendUp, breakingLineColor)
Draw bounds and breaking line of the trend.
Parameters:
startIndex (int) : Index of the first bound line.
startPrice (float) : Price of first bound line.
endIndex (int) : Index of second bound line.
endPrice (float) : price of second bound line.
breakingPivotIndex (int) : The breaking line index.
breakingPivotPrice (float) : The breaking line price.
isTrendUp (bool) : The actual status of the trend.
breakingLineColor (color)
Returns: The lines bounds and breaking line.
getResistances(resPrices, resBarIndexes, resWeights, resNbLows, resNbHighs, maxResis, rangePercentResis, pLast, iLast, isHighLast)
Function to update array and related to resistance interpretation.
Parameters:
resPrices (array) : Array that save resis prices.
resBarIndexes (array) : Array that save resis bar index.
resWeights (array) : Array that save resis weight (how much time a pivot got into a resis).
resNbLows (array) : Array that save nb low pivot in resis.
resNbHighs (array) : Array that save nb high pivot in resis.
maxResis (int) : Max number of resis in resis arrays.
rangePercentResis (float) : Percentage vertical range to be taken when finding res.
pLast (float) : The last pivot price.
iLast (int) : The last pivot bar index.
isHighLast (bool) : The last pivot "isHigh".
Returns: trend & inter arrays, is trend hesitate, is trend up.
getTopRes(nbShowRes, minTopWeight, resWeights, resPrices, resBarIndexes)
Get top weighted resistance from multiple res found.
Parameters:
nbShowRes (int) : Nb res we want to return .
minTopWeight (int) : Minimum res weight we want to return.
resWeights (array) : Res weight array.
resPrices (array) : Res prices array.
resBarIndexes (array) : Res bar index array.
@return The top arrays.
drawResLines(resPrices, resBarIndexes)
Draw resistance lines for resistance indicator.
Parameters:
resPrices (array) : Array of res prices.
resBarIndexes (array)
plotDivergences(osc, lbR, plFound, phFound, plFoundPot, phFoundPot, rangeLower, rangeUpper)
Plot divergences.
Parameters:
osc (float)
lbR (int)
plFound (bool)
phFound (bool)
plFoundPot (bool)
phFoundPot (bool)
rangeLower (int)
rangeUpper (int)
getOscPivots(osc, lbL, lbR)
Used to get pivots and potential pivots.
Parameters:
osc (float)
lbL (int)
lbR (int)
Armin_ICT_Trade_Bot_LibraryLibrary "Armin_ICT_Trade_Bot_Library"
TODO: add library description here
GetDateTime(unixTime)
Parameters:
unixTime (float)
ma_function(source, atrlength)
Parameters:
source (float)
atrlength (simple int)
ATR(length)
Parameters:
length (simple int)
dmarcLevelParserLibrary "dmarcLevelParser"
Provides a parsing library that indicator authors can use in order to parse dmarcLevels.
parseLevels(s)
Parses the string content and returns the `dmarcLevels` found within.
Parameters:
s (string) : The string to parse.
Returns: The parsed dmarc levels.
zoneRange
Fields:
high (series float)
low (series float)
wtdLevels
Fields:
lvnLines (array)
lvnZones (array)
supplyLines (array)
supplyZones (array)
vses (array)
vahs (array)
vals (array)
pocs (array)
miscZones (array)
miscLines (array)
fbos (array)
fbds (array)
majorLevels (array)
mansupLines (array)
mansupmajLines (array)
mansupZones (array)
mansupmajZones (array)
manresLines (array)
manresmajLines (array)
manresZones (array)
manresmajZones (array)
capital_managementLibrary "capital_management"
TODO: add library description here
Volume_calculation(precent_risk, order_entry_price, stop_loss_price)
TODO: Volume calculation function by placing orders with fiven % risk
Parameters:
precent_risk (float)
order_entry_price (float)
stop_loss_price (float)
Returns: stop_loss_price: Price that place stop loss order
PaddingThe Padding library is a comprehensive and flexible toolkit designed to extend time series data within TradingView, making it an indispensable resource for advanced signal processing tasks such as FFT, filtering, convolution, and wavelet analysis. At its core, the library addresses the common challenge of edge effects by "padding" your data—that is, by appending additional data points beyond the natural boundaries of your original dataset. This extension not only mitigates the distortions that can occur at the endpoints but also helps to maintain the integrity of various transformations and calculations performed on the series. The library accomplishes this while preserving the ordering of your data, ensuring that the most recent point always resides at index 0.
Central to the functionality of this library are two key enumerations: Direction and PaddingType. The Direction enum determines where the padding will be applied. You can choose to extend the data in the forward direction (ahead of the current values), in the backward direction (behind the current values), or in both directions simultaneously. The PaddingType enum defines the specific method used for extending the data. The library supports several methods—including symmetric, reflect, periodic, antisymmetric, antireflect, smooth, constant, and zero padding—each of which has been implemented to suit different analytical scenarios. For instance, symmetric padding mirrors the original data across its boundaries, while reflect padding continues the trend by reflecting around endpoint values. Periodic padding repeats the data, and antisymmetric padding mirrors the data with alternating signs to counterbalance it. The antireflect and smooth methods take into account the derivatives of your data, thereby extending the series in a way that preserves or smoothly continues these derivative values. Constant and zero padding simply extend the series using fixed endpoint values or zeros. Together, these enums allow you to fine-tune how your data is extended, ensuring that the padding method aligns with the specific requirements of your analysis.
The library is designed to work with both single variable inputs and array inputs. When using array-based methods—particularly with the antireflect and smooth padding types—please note that the implementation intentionally discards the last data point as a result of the delta computation process. This behavior is an important consideration when integrating the library into your TradingView studies, as it affects the overall data length of the padded series. Despite this, the library’s structure and documentation make it straightforward to incorporate into your existing scripts. You simply provide your data source, define the length of your data window, and select the desired padding type and direction, along with any optional parameters to control the extent of the padding (using both_period, forward_period, or backward_period).
In practical application, the Padding library enables you to extend historical data beyond its original range in a controlled and predictable manner. This is particularly useful when preparing datasets for further signal processing, as it helps to reduce artifacts that can otherwise compromise the results of your analytical routines. Whether you are an experienced Pine Script developer or a trader exploring advanced data analysis techniques, this library offers a robust solution that enhances the reliability and accuracy of your studies by ensuring your algorithms operate on a more complete and well-prepared dataset.
Library "Padding"
A comprehensive library for padding time series data with various methods. Supports both single variable and array inputs, with flexible padding directions and periods. Designed for signal processing applications including FFT, filtering, convolution, and wavelets. All methods maintain data ordering with most recent point at index 0.
symmetric(source, series_length, direction, both_period, forward_period, backward_period)
Applies symmetric padding by mirroring the input data across boundaries
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with symmetric padding applied
method symmetric(source, direction, both_period, forward_period, backward_period)
Applies symmetric padding to an array by mirroring the data across boundaries
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with symmetric padding applied
reflect(source, series_length, direction, both_period, forward_period, backward_period)
Applies reflect padding by continuing trends through reflection around endpoint values
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with reflect padding applied
method reflect(source, direction, both_period, forward_period, backward_period)
Applies reflect padding to an array by continuing trends through reflection around endpoint values
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with reflect padding applied
periodic(source, series_length, direction, both_period, forward_period, backward_period)
Applies periodic padding by repeating the input data
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with periodic padding applied
method periodic(source, direction, both_period, forward_period, backward_period)
Applies periodic padding to an array by repeating the data
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with periodic padding applied
antisymmetric(source, series_length, direction, both_period, forward_period, backward_period)
Applies antisymmetric padding by mirroring data and alternating signs
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with antisymmetric padding applied
method antisymmetric(source, direction, both_period, forward_period, backward_period)
Applies antisymmetric padding to an array by mirroring data and alternating signs
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with antisymmetric padding applied
antireflect(source, series_length, direction, both_period, forward_period, backward_period)
Applies antireflect padding by reflecting around endpoints while preserving derivatives
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with antireflect padding applied
method antireflect(source, direction, both_period, forward_period, backward_period)
Applies antireflect padding to an array by reflecting around endpoints while preserving derivatives
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with antireflect padding applied. Note: Last data point is lost when using array input
smooth(source, series_length, direction, both_period, forward_period, backward_period)
Applies smooth padding by extending with constant derivatives from endpoints
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with smooth padding applied
method smooth(source, direction, both_period, forward_period, backward_period)
Applies smooth padding to an array by extending with constant derivatives from endpoints
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with smooth padding applied. Note: Last data point is lost when using array input
constant(source, series_length, direction, both_period, forward_period, backward_period)
Applies constant padding by extending endpoint values
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with constant padding applied
method constant(source, direction, both_period, forward_period, backward_period)
Applies constant padding to an array by extending endpoint values
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with constant padding applied
zero(source, series_length, direction, both_period, forward_period, backward_period)
Applies zero padding by extending with zeros
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with zero padding applied
method zero(source, direction, both_period, forward_period, backward_period)
Applies zero padding to an array by extending with zeros
Namespace types: array
Parameters:
source (array) : Array of values to pad
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with zero padding applied
pad_data(source, series_length, padding_type, direction, both_period, forward_period, backward_period)
Generic padding function that applies specified padding type to input data
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
padding_type (series PaddingType) : Type of padding to apply (see PaddingType enum)
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with specified padding applied
method pad_data(source, padding_type, direction, both_period, forward_period, backward_period)
Generic padding function that applies specified padding type to array input
Namespace types: array
Parameters:
source (array) : Array of values to pad
padding_type (series PaddingType) : Type of padding to apply (see PaddingType enum)
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to array length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to array length if not specified
Returns: Array ordered with most recent point at index 0, containing original data with specified padding applied. Note: Last data point is lost when using antireflect or smooth padding types
make_padded_data(source, series_length, padding_type, direction, both_period, forward_period, backward_period)
Creates a window-based padded data series that updates with each new value. WARNING: Function must be called on every bar for consistency. Do not use in scopes where it may not execute on every bar.
Parameters:
source (float) : Input value to pad from
series_length (int) : Length of the data window
padding_type (series PaddingType) : Type of padding to apply (see PaddingType enum)
direction (series Direction) : Direction to apply padding
both_period (int) : Optional - periods to pad in both directions. Overrides forward_period and backward_period if specified
forward_period (int) : Optional - periods to pad forward. Defaults to series_length if not specified
backward_period (int) : Optional - periods to pad backward. Defaults to series_length if not specified
Returns: Array ordered with most recent point at index 0, containing windowed data with specified padding applied
UtilityLibraryLibrary "UtilityLibrary"
A collection of custom utility functions used in my scripts.
milliseconds_per_bar()
Gets the number of milliseconds per bar.
Returns: (int) The number of milliseconds per bar.
realtime()
Checks if the current bar is the actual realtime bar.
Returns: (bool) `true` when the current bar is the actual realtime bar, `false` otherwise.
replay()
Checks if the current bar is the last replay bar.
Returns: (bool) `true` when the current bar is the last replay bar, `false` otherwise.
bar_elapsed()
Checks how much of the current bar has elapsed.
Returns: (float) Between 0 and 1.
even(number)
Checks if a number is even.
Parameters:
number (float) : (float) The number to evaluate.
Returns: (bool) `true` when the number is even, `false` when the number is odd.
sign(number)
Gets the sign of a float.
Parameters:
number (float) : (float) The number to evaluate.
Returns: (int) 1 or -1, unlike math.sign() which returns 0 if the number is 0.
atan2(y, x)
Derives an angle in radians from the XY coordinate.
Parameters:
y (float) : (float) Y coordinate.
x (float) : (float) X coordinate.
Returns: (float) Between -π and π.
clamp(number, min, max)
Ensures a value is between the `min` and `max` thresholds.
Parameters:
number (float) : (float) The number to clamp.
min (float) : (float) The minimum threshold (0 by default).
max (float) : (float) The maximum threshold (1 by default).
Returns: (float) Between `min` and `max`.
remove_gamma(value)
Removes gamma from normalized sRGB channel values.
Parameters:
value (float) : (float) The normalized channel value .
Returns: (float) Channel value with gamma removed.
add_gama(value)
Adds gamma into normalized linear RGB channel values.
Parameters:
value (float) : (float) The normalized channel value .
Returns: (float) Channel value with gamma added.
rgb_to_xyz(Color)
Extracts XYZ-D65 channels from sRGB colors.
Parameters:
Color (color) : (color) The sRGB color to process.
Returns: (float tuple)
xyz_to_rgb(x, y, z)
Converts XYZ-D65 channels to sRGB channels.
Parameters:
x (float) : (float) The X channel value.
y (float) : (float) The Y channel value.
z (float) : (float) The Z channel value.
Returns: (int tuple)
rgb_to_oklab(Color)
Extracts OKLAB-D65 channels from sRGB colors.
Parameters:
Color (color) : (color) The sRGB color to process.
Returns: (float tuple)
oklab_to_rgb(l, a, b)
Converts OKLAB-D65 channels to sRGB channels.
Parameters:
l (float) : (float) The L channel value.
a (float) : (float) The A channel value.
b (float) : (float) The B channel value.
Returns: (int tuple)
rgb_to_oklch(Color)
Extracts OKLCH channels from sRGB colors.
Parameters:
Color (color) : (color) The sRGB color to process.
Returns: (float tuple)
oklch_to_rgb(l, c, h)
Converts OKLCH channels to sRGB channels.
Parameters:
l (float) : (float) The L channel value.
c (float) : (float) The C channel value.
h (float) : (float) The H channel value.
Returns: (float tuple)
hues(l1, h1, l2, h2, dist)
Ensures the hue angles are set correctly for linearly interpolating OKLCH.
Parameters:
l1 (float) : (float) The first L channel value.
h1 (float) : (float) The first H channel value.
l2 (float) : (float) The second L channel value.
h2 (float) : (float) The second H channel value.
dist (string) : (string) The preferred angular distance to use. Options: `min` or `max` (`min` by default).
Returns: (float tuple)
lerp(a, b, t)
Linearly interpolates between two values.
Parameters:
a (float) : (float) The starting point (first value).
b (float) : (float) The ending point (second value).
t (float) : (float) The interpolation factor .
Returns: (float) Between `a` and `b`.
smoothstep(t, precise)
A non-linear (smooth) interpolation between 0 and 1.
Parameters:
t (float) : (float) The interpolation factor .
precise (bool) : (bool) Sets if the calc should be precise or efficient (`true` by default).
Returns: (float) Between 0 and 1.
ease(t, n, v, x1, y1, x2, y2)
A customizable non-linear interpolation between 0 and 1.
Parameters:
t (float) : (float) The interpolation factor .
n (float) : (float) The degree of ease (1 by default).
v (string) : (string) The easing variant type: `in-out`, `in`, or `out` (`in-out` by default).
x1 (float) : (float) Optional X coordinate of starting point (0 by default).
y1 (float) : (float) Optional Y coordinate of starting point (0 by default).
x2 (float) : (float) Optional X coordinate of ending point (1 by default).
y2 (float) : (float) Optional Y coordinate of ending point (1 by default).
Returns: (float) Between 0 and 1.
mix(color1, color2, blend, space, dist)
Linearly interpolates between two colors.
Parameters:
color1 (color) : (color) The first color.
color2 (color) : (color) The second color.
blend (float) : (float) The interpolation factor .
space (string) : (string) The color space to use for interpolating. Options: `rgb`, `oklab`, and `oklch` (`rgb` by default).
dist (string) : (string) The anglular distance to use for the hue change when the color space is set to `oklch`. Options: `min` and `max` (`min` by default).
Returns: (color) Blend of `color1` and `color2`.
VolumeProfileLibrary "VolumeProfile"
Analyzes volume and price and calculates a volume profile, in particular the Point Of Control and Value Area values.
new(rowSizeInTicks, valueAreaCoverage, startTime)
Constructor method that creates a new Volume Profile
Parameters:
rowSizeInTicks (float) : Internal row size (aka resolution) of the volume profile. Useful for most futures contracts would be '1 / syminfo.mintick'. Default '4'.
valueAreaCoverage (int) : Percentage of total volume that is considered the Value Area. Default '70'
startTime (int) : Start time (unix timestamp in milliseconds) of the Volume Profile. Default 'time'.
Returns: VolumeProfile object
method calculatePOC(vp)
Calculates current Point Of Control of the VP
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
Returns: void
method calculateVA(vp)
Calculates current Value Area High and Low of the VP
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
Returns: void
method update(vp, h, l, v, t)
Processes new chart data and sorts volume into rows. Then calls calculatePOC() and calculateVA() to update the VP. Parameters are usually the output of request.security_lower_tf.
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
h (array) : Array of highs
l (array) : Array of lows
v (array) : Array of volumes
t (array) : Array of candle times
Returns: void
method setSessionHigh(vp, h)
Sets the high of the session the VP is tracking
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
h (float)
Returns: void
method setSessionLow(vp, l)
Sets the low of the session the VP is tracking
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
l (float)
Returns: void
method getPOC(vp)
Gets the current Point Of Control
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
Returns: Point Of Control (float)
method getVAH(vp)
Gets the current Value Area High
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
Returns: Value Area High (float)
method getVAL(vp)
Gets the current Value Area Low
Namespace types: VolumeProfile
Parameters:
vp (VolumeProfile)
Returns: Value Area Low (float)
VolumeProfile
Fields:
rowSizeInTicks (series float)
valueAreaCoverage (series int)
startTime (series int)
valueAreaHigh (series float)
pointOfControl (series float)
valueAreaLow (series float)
sessionHigh (series float)
sessionLow (series float)
volumeByRow (map)
totalVolume (series float)
pocRow (series float)
pocVol (series float)
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.
KalmanfilterLibrary "Kalmanfilter"
A sophisticated Kalman Filter implementation for financial time series analysis
@author Rocky-Studio
@version 1.0
initialize(initial_value, process_noise, measurement_noise)
Initializes Kalman Filter parameters
Parameters:
initial_value (float) : (float) The initial state estimate
process_noise (float) : (float) The process noise coefficient (Q)
measurement_noise (float) : (float) The measurement noise coefficient (R)
Returns: A tuple containing
update(prev_state, prev_covariance, measurement, process_noise, measurement_noise)
Update Kalman Filter state
Parameters:
prev_state (float)
prev_covariance (float)
measurement (float)
process_noise (float)
measurement_noise (float)
calculate_measurement_noise(price_series, length)
Adaptive measurement noise calculation
Parameters:
price_series (array)
length (int)
calculate_measurement_noise_simple(price_series)
Parameters:
price_series (array)
update_trading(prev_state, prev_velocity, prev_covariance, measurement, volatility_window)
Enhanced trading update with velocity
Parameters:
prev_state (float)
prev_velocity (float)
prev_covariance (float)
measurement (float)
volatility_window (int)
model4_update(prev_mean, prev_speed, prev_covariance, price, process_noise, measurement_noise)
Kalman Filter Model 4 implementation (Benhamou 2018)
Parameters:
prev_mean (float)
prev_speed (float)
prev_covariance (array)
price (float)
process_noise (array)
measurement_noise (float)
model4_initialize(initial_price)
Initialize Model 4 parameters
Parameters:
initial_price (float)
model4_default_process_noise()
Create default process noise matrix for Model 4
model4_calculate_measurement_noise(price_series, length)
Adaptive measurement noise calculation for Model 4
Parameters:
price_series (array)
length (int)
BybitPerpsArrayLibrary "BybitPerpsArray"
f_getSymbolsForGroup(groupName)
Parameters:
groupName (string)
Contains all of the BYBIT Perp charts- use function to call them in groups
pslibs_revisedLibrary "pslibs_revised"
f_calculate_divergence_on_close(close, mom, rsi, start_lookback, max_lookback, rsiThresholdBuy, rsiThresholdSell, minAngleDiff, run_flag)
Parameters:
close (float)
mom (float)
rsi (float)
start_lookback (int)
max_lookback (int)
rsiThresholdBuy (float)
rsiThresholdSell (float)
minAngleDiff (float)
run_flag (bool)
f_calculate_divergence_on_low(low, mom, rsi, start_lookback, max_lookback, rsiThresholdBuy, rsiThresholdSell, minAngleDiff, run_flag)
Parameters:
low (float)
mom (float)
rsi (float)
start_lookback (int)
max_lookback (int)
rsiThresholdBuy (float)
rsiThresholdSell (float)
minAngleDiff (float)
run_flag (bool)
f_calculate_reversal(close, low, high, macdFastPeriod, macdSlowPeriod, macdSignalPeriod, stochPeriod, prcKPeriod, stochOS, stochOB, run_flag)
Parameters:
close (float)
low (float)
high (float)
macdFastPeriod (simple int)
macdSlowPeriod (simple int)
macdSignalPeriod (simple int)
stochPeriod (int)
prcKPeriod (int)
stochOS (int)
stochOB (int)
run_flag (bool)
is_within_first_30_minutes()
is_last_60_minutes()
is_last_30_minutes()
func_yestday_was_postive_trend()
Geo. Geo.
This library provides a comprehensive set of geometric functions based on 2 simple types for point and line manipulation, point array calculations, some vector operations (Borrowed from @ricardosantos ), angle calculations, and basic polygon analysis. It offers tools for creating, transforming, and analyzing geometric shapes and their relationships.
View the source code for detailed documentation on each function and type.
═════════════════════════════════════════════════════════════════════════
█ OVERVIEW
This library enhances TradingView's Pine Script with robust geometric capabilities. It introduces the Point and Line types, along with a suite of functions for various geometric operations. These functionalities empower you to perform advanced calculations, manipulations, and analyses involving points, lines, vectors, angles, and polygons directly within your Pine scripts. The example is at the bottom of the script. ( Commented out )
█ CONCEPTS
This library revolves around two fundamental types:
• Point: Represents a point in 2D space with x and y coordinates, along with optional 'a' (angle) and 'v' (value) fields for versatile use. Crucially, for plotting, utilize the `.to_chart_point()` method to convert Points into plottable chart.point objects.
• Line: Defined by a starting Point and a slope , enabling calculations like getting y for a given x, or finding intersection points.
█ FEATURES
• Point Manipulation: Perform operations like addition, subtraction, scaling, rotation, normalization, calculating distances, dot products, cross products, midpoints, and more with Point objects.
• Line Operations: Create lines, determine their slope, calculate y from x (and vice versa), and find the intersection points of two lines.
• Vector Operations: Perform vector addition, subtraction, multiplication, division, negation, perpendicular vector calculation, floor, fractional part, sine, absolute value, modulus, sign, round, scaling, rescaling, rotation, and ceiling operations.
• Angle Calculations: Compute angles between points in degrees or radians, including signed, unsigned, and 360-degree angles.
• Polygon Analysis: Calculate the area, perimeter, and centroid of polygons. Check if a point is inside a given polygon and determine the convex hull perimeter.
• Chart Plotting: Conveniently convert Point objects to chart.point objects for plotting lines and points on the chart. The library also includes functions for plotting lines between individual and series of points.
• Utility Functions: Includes helper functions such as square root, square, cosine, sine, tangent, arc cosine, arc sine, arc tangent, atan2, absolute distance, golden ratio tolerance check, fractional part, and safe index/check for chart plotting boundaries.
█ HOW TO USE
1 — Include the library in your script using:
import kaigouthro/geo/1
2 — Create Point and Line objects:
p1 = geo.Point(bar_index, close)
p2 = geo.Point(bar_index , open)
myLine = geo.Line(p1, geo.slope(p1, p2))
// maybe use that line to detect a crossing for an alert ... hmmm
3 — Utilize the provided functions:
distance = geo.distance(p1, p2)
intersection = geo.intersection(line1, line2)
4 — For plotting labels, lines, convert Point to chart.point :
label.new(p1.to_chart_point(), " Hi ")
line.new(p1.to_chart_point(),p2.to_chart_point())
█ NOTES
This description provides a concise overview. Consult the library's source code for in-depth documentation, including detailed descriptions, parameter types, and return values for each function and method. The source code is structured with comprehensive comments using the `//@` format for seamless integration with TradingView's auto-documentation features.
█ Possibilities..
Library "geo"
This library provides a comprehensive set of geometric functions and types, including point and line manipulation, vector operations, angle calculations, and polygon analysis. It offers tools for creating, transforming, and analyzing geometric shapes and their relationships.
sqrt(value)
Square root function
Parameters:
value (float) : (float) - The number to take the square root of
Returns: (float) - The square root of the input value
sqr(x)
Square function
Parameters:
x (float) : (float) - The number to square
Returns: (float) - The square of the input value
cos(v)
Cosine function
Parameters:
v (float) : (series float) - The value to find the cosine of
Returns: (series float) - The cosine of the input value
sin(v)
Sine function
Parameters:
v (float) : (series float) - The value to find the sine of
Returns: (series float) - The sine of the input value
tan(v)
Tangent function
Parameters:
v (float) : (series float) - The value to find the tangent of
Returns: (series float) - The tangent of the input value
acos(v)
Arc cosine function
Parameters:
v (float) : (series float) - The value to find the arc cosine of
Returns: (series float) - The arc cosine of the input value
asin(v)
Arc sine function
Parameters:
v (float) : (series float) - The value to find the arc sine of
Returns: (series float) - The arc sine of the input value
atan(v)
Arc tangent function
Parameters:
v (float) : (series float) - The value to find the arc tangent of
Returns: (series float) - The arc tangent of the input value
atan2(dy, dx)
atan2 function
Parameters:
dy (float) : (float) - The y-coordinate
dx (float) : (float) - The x-coordinate
Returns: (float) - The angle in radians
gap(_value1, __value2)
Absolute distance between any two float values
Parameters:
_value1 (float) : First value
__value2 (float)
Returns: Absolute Positive Distance
phi_tol(a, b, tolerance)
Check if the ratio is within the tolerance of the golden ratio
Parameters:
a (float) : (float) The first number
b (float) : (float) The second number
tolerance (float) : (float) The tolerance percennt as 1 = 1 percent
Returns: (bool) True if the ratio is within the tolerance, false otherwise
frac(x)
frad Fractional
Parameters:
x (float) : (float) - The number to convert to fractional
Returns: (float) - The number converted to fractional
safeindex(x, limit)
limiting int to hold the value within the chart range
Parameters:
x (float) : (float) - The number to limit
limit (int)
Returns: (int) - The number limited to the chart range
safecheck(x, limit)
limiting int check if within the chartplottable range
Parameters:
x (float) : (float) - The number to limit
limit (int)
Returns: (int) - The number limited to the chart range
interpolate(a, b, t)
interpolate between two values
Parameters:
a (float) : (float) - The first value
b (float) : (float) - The second value
t (float) : (float) - The interpolation factor (0 to 1)
Returns: (float) - The interpolated value
gcd(_numerator, _denominator)
Greatest common divisor of two integers
Parameters:
_numerator (int)
_denominator (int)
Returns: (int) The greatest common divisor
method set_x(self, value)
Set the x value of the point, and pass point for chaining
Namespace types: Point
Parameters:
self (Point) : (Point) The point to modify
value (float) : (float) The new x-coordinate
method set_y(self, value)
Set the y value of the point, and pass point for chaining
Namespace types: Point
Parameters:
self (Point) : (Point) The point to modify
value (float) : (float) The new y-coordinate
method get_x(self)
Get the x value of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point to get the x-coordinate from
Returns: (float) The x-coordinate
method get_y(self)
Get the y value of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point to get the y-coordinate from
Returns: (float) The y-coordinate
method vmin(self)
Lowest element of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point
Returns: (float) The lowest value between x and y
method vmax(self)
Highest element of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point
Returns: (float) The highest value between x and y
method add(p1, p2)
Addition
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (Point) - the add of the two points
method sub(p1, p2)
Subtraction
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (Point) - the sub of the two points
method mul(p, scalar)
Multiplication by scalar
Namespace types: Point
Parameters:
p (Point) : (Point) - The point
scalar (float) : (float) - The scalar to multiply by
Returns: (Point) - the multiplied point of the point and the scalar
method div(p, scalar)
Division by scalar
Namespace types: Point
Parameters:
p (Point) : (Point) - The point
scalar (float) : (float) - The scalar to divide by
Returns: (Point) - the divided point of the point and the scalar
method rotate(p, angle)
Rotate a point around the origin by an angle (in degrees)
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to rotate
angle (float) : (float) - The angle to rotate by in degrees
Returns: (Point) - the rotated point
method length(p)
Length of the vector from origin to the point
Namespace types: Point
Parameters:
p (Point) : (Point) - The point
Returns: (float) - the length of the point
method length_squared(p)
Length squared of the vector
Namespace types: Point
Parameters:
p (Point) : (Point) The point
Returns: (float) The squared length of the point
method normalize(p)
Normalize the point to a unit vector
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to normalize
Returns: (Point) - the normalized point
method dot(p1, p2)
Dot product
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the dot of the two points
method cross(p1, p2)
Cross product result (in 2D, this is a scalar)
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the cross of the two points
method distance(p1, p2)
Distance between two points
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the distance of the two points
method Point(x, y, a, v)
Point Create Convenience
Namespace types: series float, simple float, input float, const float
Parameters:
x (float)
y (float)
a (float)
v (float)
Returns: (Point) new point
method angle(p1, p2)
Angle between two points in degrees
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the angle of the first point and the second point
method angle_between(p, pivot, other)
Angle between two points in degrees from a pivot point
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to calculate the angle from
pivot (Point) : (Point) - The pivot point
other (Point) : (Point) - The other point
Returns: (float) - the angle between the two points
method translate(p, from_origin, to_origin)
Translate a point from one origin to another
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to translate
from_origin (Point) : (Point) - The origin to translate from
to_origin (Point) : (Point) - The origin to translate to
Returns: (Point) - the translated point
method midpoint(p1, p2)
Midpoint of two points
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (Point) - The midpoint of the two points
method rotate_around(p, angle, pivot)
Rotate a point around a pivot point by an angle (in degrees)
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to rotate
angle (float) : (float) - The angle to rotate by in degrees
pivot (Point) : (Point) - The pivot point to rotate around
Returns: (Point) - the rotated point
method multiply(_a, _b)
Multiply vector _a with _b
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The result of the multiplication
method divide(_a, _b)
Divide vector _a by _b
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The result of the division
method negate(_a)
Negative of vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to negate
Returns: (Point) The negated point
method perp(_a)
Perpendicular Vector of _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The perpendicular point
method vfloor(_a)
Compute the floor of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The floor of the point
method fractional(_a)
Compute the fractional part of the elements from vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The fractional part of the point
method vsin(_a)
Compute the sine of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The sine of the point
lcm(a, b)
Least common multiple of two integers
Parameters:
a (int) : (int) The first integer
b (int) : (int) The second integer
Returns: (int) The least common multiple
method vabs(_a)
Compute the absolute of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The absolute of the point
method vmod(_a, _b)
Compute the mod of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
_b (float) : (float) The mod
Returns: (Point) The mod of the point
method vsign(_a)
Compute the sign of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The sign of the point
method vround(_a)
Compute the round of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The round of the point
method normalize_y(p, height)
normalizes the y value of a point to an input height
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to normalize
height (float) : (float) - The height to normalize to
Returns: (Point) - the normalized point
centroid(points)
Calculate the centroid of multiple points
Parameters:
points (array) : (array) The array of points
Returns: (Point) The centroid point
random_point(_height, _width, _origin, _centered)
Random Point in a given height and width
Parameters:
_height (float) : (float) The height of the area to generate the point in
_width (float) : (float) The width of the area to generate the point in
_origin (Point) : (Point) The origin of the area to generate the point in (default: na, will create a Point(0, 0))
_centered (bool) : (bool) Center the origin point in the area, otherwise, positive h/w (default: false)
Returns: (Point) The random point in the given area
random_point_array(_origin, _height, _width, _centered, _count)
Random Point Array in a given height and width
Parameters:
_origin (Point) : (Point) The origin of the area to generate the array (default: na, will create a Point(0, 0))
_height (float) : (float) The height of the area to generate the array
_width (float) : (float) The width of the area to generate the array
_centered (bool) : (bool) Center the origin point in the area, otherwise, positive h/w (default: false)
_count (int) : (int) The number of points to generate (default: 50)
Returns: (array) The random point array in the given area
method sort_points(points, by_x)
Sorts an array of points by x or y coordinate
Namespace types: array
Parameters:
points (array) : (array) The array of points to sort
by_x (bool) : (bool) Whether to sort by x-coordinate (true) or y-coordinate (false)
Returns: (array) The sorted array of points
method equals(_a, _b)
Compares two points for equality
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (bool) True if the points are equal, false otherwise
method max(origin, _a, _b)
Maximum of two points from origin, using dot product
Namespace types: Point
Parameters:
origin (Point)
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The maximum point
method min(origin, _a, _b)
Minimum of two points from origin, using dot product
Namespace types: Point
Parameters:
origin (Point)
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The minimum point
method avg_x(points)
Average x of point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The average x-coordinate
method avg_y(points)
Average y of point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The average y-coordinate
method range_x(points)
Range of x values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The range of x-coordinates
method range_y(points)
Range of y values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The range of y-coordinates
method max_x(points)
max of x values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The max of x-coordinates
method min_y(points)
min of x values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The min of x-coordinates
method scale(_a, _scalar)
Scale a point by a scalar
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to scale
_scalar (float) : (float) The scalar value
Returns: (Point) The scaled point
method rescale(_a, _length)
Rescale a point to a new magnitude
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to rescale
_length (float) : (float) The new magnitude
Returns: (Point) The rescaled point
method rotate_rad(_a, _radians)
Rotate a point by an angle in radians
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to rotate
_radians (float) : (float) The angle in radians
Returns: (Point) The rotated point
method rotate_degree(_a, _degree)
Rotate a point by an angle in degrees
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to rotate
_degree (float) : (float) The angle in degrees
Returns: (Point) The rotated point
method vceil(_a, _digits)
Ceil a point to a certain number of digits
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to ceil
_digits (int) : (int) The number of digits to ceil to
Returns: (Point) The ceiled point
method vpow(_a, _exponent)
Raise both point elements to a power
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
_exponent (float) : (float) The exponent
Returns: (Point) The point with elements raised to the power
method perpendicular_distance(_a, _b, _c)
Distance from point _a to line between _b and _c
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
_b (Point) : (Point) The start point of the line
_c (Point) : (Point) The end point of the line
Returns: (float) The perpendicular distance
method project(_a, _axis)
Project a point onto another
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to project
_axis (Point) : (Point) The point to project onto
Returns: (Point) The projected point
method projectN(_a, _axis)
Project a point onto a point of unit length
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to project
_axis (Point) : (Point) The unit length point to project onto
Returns: (Point) The projected point
method reflect(_a, _axis)
Reflect a point on another
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to reflect
_axis (Point) : (Point) The point to reflect on
Returns: (Point) The reflected point
method reflectN(_a, _axis)
Reflect a point to an arbitrary axis
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to reflect
_axis (Point) : (Point) The axis to reflect to
Returns: (Point) The reflected point
method angle_rad(_a)
Angle in radians of a point
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (float) The angle in radians
method angle_unsigned(_a, _b)
Unsigned degree angle between 0 and +180 by given two points
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (float) The unsigned angle in degrees
method angle_signed(_a, _b)
Signed degree angle between -180 and +180 by given two points
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (float) The signed angle in degrees
method angle_360(_a, _b)
Degree angle between 0 and 360 by given two points
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (float) The angle in degrees (0-360)
method clamp(_a, _vmin, _vmax)
Restricts a point between a min and max value
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to restrict
_vmin (Point) : (Point) The minimum point
_vmax (Point) : (Point) The maximum point
Returns: (Point) The restricted point
method lerp(_a, _b, _rate_of_move)
Linearly interpolates between points a and b by _rate_of_move
Namespace types: Point
Parameters:
_a (Point) : (Point) The starting point
_b (Point) : (Point) The ending point
_rate_of_move (float) : (float) The rate of movement (0-1)
Returns: (Point) The interpolated point
method slope(p1, p2)
Slope of a line between two points
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - The slope of the line
method gety(self, x)
Get y-coordinate of a point on the line given its x-coordinate
Namespace types: Line
Parameters:
self (Line) : (Line) - The line
x (float) : (float) - The x-coordinate
Returns: (float) - The y-coordinate
method getx(self, y)
Get x-coordinate of a point on the line given its y-coordinate
Namespace types: Line
Parameters:
self (Line) : (Line) - The line
y (float) : (float) - The y-coordinate
Returns: (float) - The x-coordinate
method intersection(self, other)
Intersection point of two lines
Namespace types: Line
Parameters:
self (Line) : (Line) - The first line
other (Line) : (Line) - The second line
Returns: (Point) - The intersection point
method calculate_arc_point(self, b, p3)
Calculate a point on the arc defined by three points
Namespace types: Point
Parameters:
self (Point) : (Point) The starting point of the arc
b (Point) : (Point) The middle point of the arc
p3 (Point) : (Point) The end point of the arc
Returns: (Point) A point on the arc
approximate_center(point1, point2, point3)
Approximate the center of a spiral using three points
Parameters:
point1 (Point) : (Point) The first point
point2 (Point) : (Point) The second point
point3 (Point) : (Point) The third point
Returns: (Point) The approximate center point
createEdge(center, radius, angle)
Get coordinate from center by radius and angle
Parameters:
center (Point) : (Point) - The center point
radius (float) : (float) - The radius of the circle
angle (float) : (float) - The angle in degrees
Returns: (Point) - The coordinate on the circle
getGrowthFactor(p1, p2, p3)
Get growth factor of spiral point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
p3 (Point) : (Point) - The third point
Returns: (float) - The growth factor
method to_chart_point(point)
Convert Point to chart.point using chart.point.from_index(safeindex(point.x), point.y)
Namespace types: Point
Parameters:
point (Point) : (Point) - The point to convert
Returns: (chart.point) - The chart.point representation of the input point
method plotline(p1, p2, col, width)
Draw a line from p1 to p2
Namespace types: Point
Parameters:
p1 (Point) : (Point) First point
p2 (Point) : (Point) Second point
col (color)
width (int)
Returns: (line) Line object
method drawlines(points, col, ignore_boundary)
Draw lines between points in an array
Namespace types: array
Parameters:
points (array) : (array) The array of points
col (color) : (color) The color of the lines
ignore_boundary (bool) : (bool) The color of the lines
method to_chart_points(points)
Draw an array of points as chart points on the chart with line.new(chartpoint1, chartpoint2, color=linecolor)
Namespace types: array
Parameters:
points (array) : (array) - The points to draw
Returns: (array) The array of chart points
polygon_area(points)
Calculate the area of a polygon defined by an array of points
Parameters:
points (array) : (array) The array of points representing the polygon vertices
Returns: (float) The area of the polygon
polygon_perimeter(points)
Calculate the perimeter of a polygon
Parameters:
points (array) : (array) Array of points defining the polygon
Returns: (float) Perimeter of the polygon
is_point_in_polygon(point, _polygon)
Check if a point is inside a polygon
Parameters:
point (Point) : (Point) The point to check
_polygon (array)
Returns: (bool) True if the point is inside the polygon, false otherwise
method perimeter(points)
Calculates the convex hull perimeter of a set of points
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (array) The array of points forming the convex hull perimeter
Point
A Point, can be used for vector, floating calcs, etc. Use the cp method for plots
Fields:
x (series float) : (float) The x-coordinate
y (series float) : (float) The y-coordinate
a (series float) : (float) An Angle storage spot
v (series float) : (float) A Value
Line
Line
Fields:
point (Point) : (Point) The starting point of the line
slope (series float) : (float) The slope of the line
GOMTRY.
lib_statemachine_modifiedLibrary "lib_statemachine_modified"
Modified to fix bugs and create getState and priorState methods.
method step(this, before, after, condition)
Namespace types: StateMachine
Parameters:
this (StateMachine)
before (int) : (int): Current state before transition
after (int) : (int): State to transition to
condition (bool) : (bool): Condition to trigger the transition
Returns: (bool): True if the state changed, else False
method step(this, after, condition)
Namespace types: StateMachine
Parameters:
this (StateMachine)
after (int) : (int): State to transition to
condition (bool) : (bool): Condition to trigger the transition
Returns: (bool): True if the state changed, else False
method currentState(this)
Namespace types: StateMachine
Parameters:
this (StateMachine)
method previousState(this)
Namespace types: StateMachine
Parameters:
this (StateMachine)
method changed(this, within_bars)
Namespace types: StateMachine
Parameters:
this (StateMachine)
within_bars (int) : (int): Number of bars to look back for a state change
Returns: (bool): True if a state change occurred within the timeframe, else False
method reset(this, condition, min_occurrences)
Namespace types: StateMachine
Parameters:
this (StateMachine)
condition (bool) : (bool): Condition to trigger the reset
min_occurrences (int) : (int): Minimum number of times the condition must be true to reset
Returns: (bool): True if the state was reset, else False
StateMachine
Fields:
state (series int)
neutral (series int)
enabled (series bool)
reset_counter (series int)
prior_state (series int)
last_change_bar (series int)
KwakPineHelperLibrary "KwakPineHelper"
TODO: add library description here
fun(x)
TODO: add function description here
Parameters:
x (float) : TODO: add parameter x description here
Returns: TODO: add what function returns
all_opentrades_size()
get all opentrades size
Returns: (float) size
recent_opentrade_profit()
get recent opentrade profit
Returns: (float) profit
all_opentrades_profit()
get all opentrades profit
Returns: (float) profit
recent_closedtrade_profit()
get recent closedtrade profit
Returns: (float) profit
recent_opentrade_max_runup()
get recent opentrade max runup
Returns: (float) runup
recent_closedtrade_max_runup()
get recent closedtrade max runup
Returns: (float) runup
recent_opentrade_max_drawdown()
get recent opentrade maxdrawdown
Returns: (float) mdd
recent_closedtrade_max_drawdown()
get recent closedtrade maxdrawdown
Returns: (float) mdd
max_open_trades_drawdown()
get max open trades drawdown
Returns: (float) mdd
recent_opentrade_commission()
get recent opentrade commission
Returns: (float) commission
recent_closedtrade_commission()
get recent closedtrade commission
Returns: (float) commission
qty_by_percent_of_equity(percent)
get qty by percent of equtiy
Parameters:
percent (float) : (series float) percent that you want to set
Returns: (float) quantity
qty_by_percent_of_position_size(percent)
get size by percent of position size
Parameters:
percent (float) : (series float) percent that you want to set
Returns: (float) size
is_day_change()
get bool change of day
Returns: (bool) day is change or not
is_in_trade(numberOfBars)
get bool using number of bars
Parameters:
numberOfBars (int)
Returns: (bool) allowedToTrade
api_msg_system(chat_id, message)
Parameters:
chat_id (string)
message (string)
is_first_day()
Check if today is the first day
Returns: (bool) true if today is the first day, false otherwise
is_last_day()
Check if today is the last day
Returns: (bool) true if today is the last day, false otherwise
is_entry()
Check if trade is open
Returns: (bool) true if trade is open, false otherwise
is_close()
Check if trade is closed
Returns: (bool) true if trade is closed, false otherwise
is_win()
Check if trade is win
Returns: (bool) true if trade is win, false otherwise
is_loss()
Check if trade is loss
Returns: (bool) true if trade is loss, false otherwise
permutation█ OVERVIEW
This library provides functions for generating permutations of string or float arrays, using an iterative approach where pine has no recursion. It supports allowing/limiting duplicate elements and handles large result sets by segmenting them into manageable chunks within custom Data types. The most combinations will vary, but the highest is around 250,000 unique combinations. depending on input array values and output length. it will return nothing if the input count is too low.
█ CONCEPTS
This library addresses two key challenges in Pine Script:
• Recursion Depth Limits: Pine has limitations on recursion depth. This library uses an iterative, stack-based algorithm to generate permutations, avoiding recursive function calls that could exceed these limits.
• Array Size Limits: Pine arrays have size restrictions. This library manages large permutation sets by dividing them into smaller segments stored within a custom Data or DataFloat type, using maps for efficient access.
█ HOW TO USE
1 — Include the Library: Add this library to your script using:
import kaigouthro/permutation/1 as permute
2 — Call the generatePermutations Function:
stringPermutations = permute.generatePermutations(array.from("a", "b", "c"), 2, 1)
floatPermutations = permute.generatePermutations(array.from(1.0, 2.0, 3.0), 2, 1)
• set : The input array of strings or floats.
• size : The desired length of each permutation.
• maxDuplicates (optional): The maximum allowed repetitions of an element within a single permutation. Defaults to 1.
3 — Access the Results: The function returns a Data (for strings) or DataFloat (for floats) object. These objects contain:
• data : An array indicating which segments are present (useful for iterating).
• segments : A map where keys represent segment indices and values are the actual permutation data within that segment.
Example: Accessing Permutations
for in stringPermutations.segments
for in currentSegment.segments
// Access individual permutations within the segment.
permutation = segmennt.data
for item in permutation
// Use the permutation elements...
█ TYPES
• PermutationState / PermutationStateFloat : Internal types used by the iterative algorithm to track the state of permutation generation.
• Data / DataFloat : Custom types to store and manage the generated permutations in segments.
█ NOTES
* The library prioritizes handling potentially large permutation sets. 250,000 i about the highest achievable.
* The segmentation logic ensures that results are accessible even when the total number of permutations exceeds Pine's array size limits.
----
Library "permutation"
This library provides functions for generating permutations of user input arrays containing either strings or floats. It uses an iterative, stack-based approach to handle potentially large sets and avoid recursion limitation. The library supports limiting the number of duplicate elements allowed in each permutation. Results are stored in a custom Data or DataFloat type that uses maps to segment large permutation sets into manageable chunks, addressing Pine Script's array size limitations.
generatePermutations(set, size, maxDuplicates)
> Generates permutations of a given size from a set of strings or floats.
Parameters:
set (array) : (array or array) The set of strings or floats to generate permutations from.
size (int) : (int) The size of the permutations to generate.
maxDuplicates (int) : (int) The maximum number of times an element can be repeated in a permutation.
Returns: (Data or DataFloat) A Data object for strings or a DataFloat object for floats, containing the generated permutations.
stringPermutations = generatePermutations(array.from("a", "b", "c"), 2, 1)
floatPermutations = generatePermutations(array.from(1.0, 2.0, 3.0), 2, 1)
generatePermutations(set, size, maxDuplicates)
Parameters:
set (array)
size (int)
maxDuplicates (int)
PermutationState
PermutationState
Fields:
data (array) : (array) The current permutation being built.
index (series int) : (int) The current index being considered in the set.
depth (series int) : (int) The current depth of the permutation (number of elements).
counts (map) : (map) Map to track the count of each element in the current permutation (for duplicates).
PermutationStateFloat
PermutationStateFloat
Fields:
data (array) : (array) The current permutation being built.
index (series int) : (int) The current index being considered in the set.
depth (series int) : (int) The current depth of the permutation (number of elements).
counts (map) : (map) Map to track the count of each element in the current permutation (for duplicates).
Data
Data
Fields:
data (array) : (array) Array to indicate which segments are present.
segments (map) : (map) Map to store permutation segments. Each segment contains a subset of the generated permutations.
DataFloat
DataFloat
Fields:
data (array) : (array) Array to indicate which segments are present.
segments (map) : (map) Map to store permutation segments. Each segment contains a subset of the generated permutations.
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.
metaconnectorLibrary "metaconnector"
metaconnector
buy_market_order(License_ID, symbol, lot)
Places a buy market order
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to buy
Returns: String syntax for the buy market order
sell_market_order(License_ID, symbol, lot)
Places a sell market order
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to sell
Returns: String syntax for the sell market order
buy_limit_order(License_ID, symbol, lot, price)
Places a buy limit order
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to buy
price (float) : Limit price for the order
Returns: String syntax for the buy limit order
sell_limit_order(License_ID, symbol, lot, price)
Places a sell limit order
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to sell
price (float) : Limit price for the order
Returns: String syntax for the sell limit order
stoploss_for_buy_order(License_ID, symbol, lot, stoploss_price)
Places a stop-loss order for a buy position
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to buy
stoploss_price (float)
Returns: String syntax for the buy stop-loss order
stoploss_for_sell_order(License_ID, symbol, lot, stoploss_price)
Places a stop-loss order for a sell position
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to sell
stoploss_price (float)
Returns: String syntax for the sell stop-loss order
takeprofit_for_buy_order(License_ID, symbol, lot, target_price)
Places a take-profit order for a buy position
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to buy
target_price (float)
Returns: String syntax for the buy take-profit order
takeprofit_for_sell_order(License_ID, symbol, lot, target_price)
Places a take-profit order for a sell position
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to sell
target_price (float)
Returns: String syntax for the sell take-profit order
buy_stop_order(License_ID, symbol, lot, price)
Places a buy stop order above the current market price
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to buy
price (float) : Stop order price
Returns: String syntax for the buy stop order
sell_stop_order(License_ID, symbol, lot, price)
Places a sell stop order below the current market price
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to sell
price (float) : Stop order price
Returns: String syntax for the sell stop order
close_all_positions(License_ID, symbol)
Closes all positions for a specific symbol
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
Returns: String syntax for closing all positions
close_buy_positions(License_ID, symbol)
Closes all buy positions for a specific symbol
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
Returns: String syntax for closing all buy positions
close_sell_positions(License_ID, symbol)
Closes all sell positions for a specific symbol
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
Returns: String syntax for closing all sell positions
close_partial_buy_position(License_ID, symbol, lot)
Closes a partial buy position for a specific symbol
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to close
Returns: String syntax for closing a partial buy position
close_partial_sell_position(License_ID, symbol, lot)
Closes a partial sell position for a specific symbol
Parameters:
License_ID (string) : Unique license ID of the user
symbol (string) : Trading symbol
lot (int) : Number of lots to close
Returns: String syntax for closing a partial sell position