Cinnamon_Bear Indicators MA LibraryLibrary "Cinnamon_BearIndicatorsMALibrary"
This is a personal Library of the NON built-in PineScript Moving Average function used to code indicators
ma_dema(source, length)
Double Exponential Moving Average (DEMA)
Parameters:
source (simple float)
length (simple int)
Returns: A double level of smoothing helps to follow price movements more closely while still reducing noise compared to a single EMA.
ma_dsma(source, length)
Double Smoothed Moving Average (DSMA)
Parameters:
source (simple float)
length (simple int)
Returns: A double level of smoothing helps to follow price movements more closely while still reducing noise compared to a single SMA.
ma_tema(source, length)
Triple Exponential Moving Average (TEMA)
Parameters:
source (simple float)
length (simple int)
Returns: A Triple level of smoothing helps to follow price movements even more closely compared to a DEMA.
ma_vwema(source, length)
Volume-Weighted Exponential Moving Average (VWEMA)
Parameters:
source (simple float)
length (simple int)
Returns: The VWEMA weights based on volume and recent price, giving more weight to periods with higher trading volumes.
ma_hma(source, length)
Hull Moving Average (HMA)
Parameters:
source (simple float)
length (simple int)
Returns: The HMA formula combines the properties of the weighted moving average (WMA) and the exponential moving average (EMA) to achieve a smoother and more responsive curve.
ma_ehma(source, length)
Enhanced Moving Average (EHMA)
Parameters:
source (simple float)
length (simple int)
Returns: The EHMA is calculated similarly to the Hull Moving Average (HMA) but uses a different weighting factor to further improve responsiveness.
ma_trix(source, length)
Triple Exponential Moving Average (TRIX)
Parameters:
source (simple float)
length (simple int)
Returns: The TRIX is an oscillator that shows the percentage change of a triple EMA. It is designed to filter out minor price movements and display only the most significant trends. The TRIX is a momentum indicator that can help identify trends and buy or sell signals.
ma_lsma(source, length)
Linear Weighted Moving Average (LSMA)
Parameters:
source (simple float)
length (simple int)
Returns: A moving average that gives more weight to recent prices. It is calculated using a formula that assigns linear weights to prices, with the highest weight given to the most recent price and the lowest weight given to the furthest price in the series.
ma_wcma(source, length)
Weighted Cumulative Moving Average (WCMA)
Parameters:
source (simple float)
length (simple int)
Returns: A moving average that gives more weight to recent prices. Compared to a LSMA, the WCMA the weights of data increase linearly with time, so the most recent data has a greater weight compared to older data. This means that the contribution of the most recent data to the moving average is more significant.
ma_vidya(source, length)
Variable Index Dynamic Average (VIDYA)
Parameters:
source (simple float)
length (simple int)
Returns: It is an adaptive moving average that adjusts its momentum based on market volatility using the formula of Chande Momentum Oscillator (CMO) .
ma_zlma(source, length)
Zero-Lag Moving Average (ZLMA)
Parameters:
source (simple float)
length (simple int)
Returns: Its aims to minimize the lag typically associated with MA, designed to react more quickly to price changes.
ma_gma(source, length, power)
Generalized Moving Average (GMA)
Parameters:
source (simple float)
length (simple int)
power (simple int)
Returns: It is a moving average that uses a power parameter to adjust the weight of historical data. This allows the GMA to adapt to various styles of MA.
ma_tma(source, length)
Triangular Moving Average (TMA)
Parameters:
source (simple float)
length (simple int)
Returns: MA more sensitive to changes in recent data compared to the SMA, providing a moving average that better adapts to short-term price changes.
Indicators and strategies
RiskMetrics█ OVERVIEW
This library is a tool for Pine programmers that provides functions for calculating risk-adjusted performance metrics on periodic price returns. The calculations used by this library's functions closely mirror those the Broker Emulator uses to calculate strategy performance metrics (e.g., Sharpe and Sortino ratios) without depending on strategy-specific functionality.
█ CONCEPTS
Returns, risk, and volatility
The return on an investment is the relative gain or loss over a period, often expressed as a percentage. Investment returns can originate from several sources, including capital gains, dividends, and interest income. Many investors seek the highest returns possible in the quest for profit. However, prudent investing and trading entails evaluating such returns against the associated risks (i.e., the uncertainty of returns and the potential for financial losses) for a clearer perspective on overall performance and sustainability.
One way investors and analysts assess the risk of an investment is by analyzing its volatility , i.e., the statistical dispersion of historical returns. Investors often use volatility in risk estimation because it provides a quantifiable way to gauge the expected extent of fluctuation in returns. Elevated volatility implies heightened uncertainty in the market, which suggests higher expected risk. Conversely, low volatility implies relatively stable returns with relatively minimal fluctuations, thus suggesting lower expected risk. Several risk-adjusted performance metrics utilize volatility in their calculations for this reason.
Risk-free rate
The risk-free rate represents the rate of return on a hypothetical investment carrying no risk of financial loss. This theoretical rate provides a benchmark for comparing the returns on a risky investment and evaluating whether its excess returns justify the risks. If an investment's returns are at or below the theoretical risk-free rate or the risk premium is below a desired amount, it may suggest that the returns do not compensate for the extra risk, which might be a call to reassess the investment.
Since the risk-free rate is a theoretical concept, investors often utilize proxies for the rate in practice, such as Treasury bills and other government bonds. Conventionally, analysts consider such instruments "risk-free" for a domestic holder, as they are a form of government obligation with a low perceived likelihood of default.
The average yield on short-term Treasury bills, influenced by economic conditions, monetary policies, and inflation expectations, has historically hovered around 2-3% over the long term. This range also aligns with central banks' inflation targets. As such, one may interpret a value within this range as a minimum proxy for the risk-free rate, as it may correspond to the minimum rate required to maintain purchasing power over time.
The built-in Sharpe and Sortino ratios that strategies calculate and display in the Performance Summary tab use a default risk-free rate of 2%, and the metrics in this library's example code use the same default rate. Users can adjust this value to fit their analysis needs.
Risk-adjusted performance
Risk-adjusted performance metrics gauge the effectiveness of an investment by considering its returns relative to the perceived risk. They aim to provide a more well-rounded picture of performance by factoring in the level of risk taken to achieve returns. Investors can utilize such metrics to help determine whether the returns from an investment justify the risks and make informed decisions.
The two most commonly used risk-adjusted performance metrics are the Sharpe ratio and the Sortino ratio.
1. Sharpe ratio
The Sharpe ratio , developed by Nobel laureate William F. Sharpe, measures the performance of an investment compared to a theoretically risk-free asset, adjusted for the investment risk. The ratio uses the following formula:
Sharpe Ratio = (𝑅𝑎 − 𝑅𝑓) / 𝜎𝑎
Where:
• 𝑅𝑎 = Average return of the investment
• 𝑅𝑓 = Theoretical risk-free rate of return
• 𝜎𝑎 = Standard deviation of the investment's returns (volatility)
A higher Sharpe ratio indicates a more favorable risk-adjusted return, as it signifies that the investment produced higher excess returns per unit of increase in total perceived risk.
2. Sortino ratio
The Sortino ratio is a modified form of the Sharpe ratio that only considers downside volatility , i.e., the volatility of returns below the theoretical risk-free benchmark. Although it shares close similarities with the Sharpe ratio, it can produce very different values, especially when the returns do not have a symmetrical distribution, since it does not penalize upside and downside volatility equally. The ratio uses the following formula:
Sortino Ratio = (𝑅𝑎 − 𝑅𝑓) / 𝜎𝑑
Where:
• 𝑅𝑎 = Average return of the investment
• 𝑅𝑓 = Theoretical risk-free rate of return
• 𝜎𝑑 = Downside deviation (standard deviation of negative excess returns, or downside volatility)
The Sortino ratio offers an alternative perspective on an investment's return-generating efficiency since it does not consider upside volatility in its calculation. A higher Sortino ratio signifies that the investment produced higher excess returns per unit of increase in perceived downside risk.
█ CALCULATIONS
Return period detection
Calculating risk-adjusted performance metrics requires collecting returns across several periods of a given size. Analysts may use different period sizes based on the context and their preferences. However, two widely used standards are monthly or daily periods, depending on the available data and the investment's duration. The built-in ratios displayed in the Strategy Tester utilize returns from either monthly or daily periods in their calculations based on the following logic:
• Use monthly returns if the history of closed trades spans at least two months.
• Use daily returns if the trades span at least two days but less than two months.
• Do not calculate the ratios if the trade data spans fewer than two days.
This library's `detectPeriod()` function applies related logic to available chart data rather than trade data to determine which period is appropriate:
• It returns true if the chart's data spans at least two months, indicating that it's sufficient to use monthly periods.
• It returns false if the chart's data spans at least two days but not two months, suggesting the use of daily periods.
• It returns na if the length of the chart's data covers less than two days, signifying that the data is insufficient for meaningful ratio calculations.
It's important to note that programmers should only call `detectPeriod()` from a script's global scope or within the outermost scope of a function called from the global scope, as it requires the time value from the first bar to accurately measure the amount of time covered by the chart's data.
Collecting periodic returns
This library's `getPeriodicReturns()` function tracks price return data within monthly or daily periods and stores the periodic values in an array . It uses a `detectPeriod()` call as the condition to determine whether each element in the array represents the return over a monthly or daily period.
The `getPeriodicReturns()` function has two overloads. The first overload requires two arguments and outputs an array of monthly or daily returns for use in the `sharpe()` and `sortino()` methods. To calculate these returns:
1. The `percentChange` argument should be a series that represents percentage gains or losses. The values can be bar-to-bar return percentages on the chart timeframe or percentages requested from a higher timeframe.
2. The function compounds all non-na `percentChange` values within each monthly or daily period to calculate the period's total return percentage. When the `percentChange` represents returns from a higher timeframe, ensure the requested data includes gaps to avoid compounding redundant values.
3. After a period ends, the function queues the compounded return into the array , removing the oldest element from the array when its size exceeds the `maxPeriods` argument.
The resulting array represents the sequence of closed returns over up to `maxPeriods` months or days, depending on the available data.
The second overload of the function includes an additional `benchmark` parameter. Unlike the first overload, this version tracks and collects differences between the `percentChange` and the specified `benchmark` values. The resulting array represents the sequence of excess returns over up to `maxPeriods` months or days. Passing this array to the `sharpe()` and `sortino()` methods calculates generalized Information ratios , which represent the risk-adjustment performance of a sequence of returns compared to a risky benchmark instead of a risk-free rate. For consistency, ensure the non-na times of the `benchmark` values align with the times of the `percentChange` values.
Ratio methods
This library's `sharpe()` and `sortino()` methods respectively calculate the Sharpe and Sortino ratios based on an array of returns compared to a specified annual benchmark. Both methods adjust the annual benchmark based on the number of periods per year to suit the frequency of the returns:
• If the method call does not include a `periodsPerYear` argument, it uses `detectPeriod()` to determine whether the returns represent monthly or daily values based on the chart's history. If monthly, the method divides the `annualBenchmark` value by 12. If daily, it divides the value by 365.
• If the method call does specify a `periodsPerYear` argument, the argument's value supersedes the automatic calculation, facilitating custom benchmark adjustments, such as dividing by 252 when analyzing collected daily stock returns.
When the array passed to these methods represents a sequence of excess returns , such as the result from the second overload of `getPeriodicReturns()`, use an `annualBenchmark` value of 0 to avoid comparing those excess returns to a separate rate.
By default, these methods only calculate the ratios on the last available bar to minimize their resource usage. Users can override this behavior with the `forceCalc` parameter. When the value is true , the method calculates the ratio on each call if sufficient data is available, regardless of the bar index.
Look first. Then leap.
█ FUNCTIONS & METHODS
This library contains the following functions:
detectPeriod()
Determines whether the chart data has sufficient coverage to use monthly or daily returns
for risk metric calculations.
Returns: (bool) `true` if the period spans more than two months, `false` if it otherwise spans more
than two days, and `na` if the data is insufficient.
getPeriodicReturns(percentChange, maxPeriods)
(Overload 1 of 2) Tracks periodic return percentages and queues them into an array for ratio
calculations. The span of the chart's historical data determines whether the function uses
daily or monthly periods in its calculations. If the chart spans more than two months,
it uses "1M" periods. Otherwise, if the chart spans more than two days, it uses "1D"
periods. If the chart covers less than two days, it does not store changes.
Parameters:
percentChange (float) : (series float) The change percentage. The function compounds non-na values from each
chart bar within monthly or daily periods to calculate the periodic changes.
maxPeriods (simple int) : (simple int) The maximum number of periodic returns to store in the returned array.
Returns: (array) An array containing the overall percentage changes for each period, limited
to the maximum specified by `maxPeriods`.
getPeriodicReturns(percentChange, benchmark, maxPeriods)
(Overload 2 of 2) Tracks periodic excess return percentages and queues the values into an
array. The span of the chart's historical data determines whether the function uses
daily or monthly periods in its calculations. If the chart spans more than two months,
it uses "1M" periods. Otherwise, if the chart spans more than two days, it uses "1D"
periods. If the chart covers less than two days, it does not store changes.
Parameters:
percentChange (float) : (series float) The change percentage. The function compounds non-na values from each
chart bar within monthly or daily periods to calculate the periodic changes.
benchmark (float) : (series float) The benchmark percentage to compare against `percentChange` values.
The function compounds non-na values from each bar within monthly or
daily periods and subtracts the results from the compounded `percentChange` values to
calculate the excess returns. For consistency, ensure this series has a similar history
length to the `percentChange` with aligned non-na value times.
maxPeriods (simple int) : (simple int) The maximum number of periodic excess returns to store in the returned array.
Returns: (array) An array containing monthly or daily excess returns, limited
to the maximum specified by `maxPeriods`.
method sharpeRatio(returnsArray, annualBenchmark, forceCalc, periodsPerYear)
Calculates the Sharpe ratio for an array of periodic returns.
Callable as a method or a function.
Namespace types: array
Parameters:
returnsArray (array) : (array) An array of periodic return percentages, e.g., returns over monthly or
daily periods.
annualBenchmark (float) : (series float) The annual rate of return to compare against `returnsArray` values. When
`periodsPerYear` is `na`, the function divides this value by 12 to calculate a
monthly benchmark if the chart's data spans at least two months or 365 for a daily
benchmark if the data otherwise spans at least two days. If `periodsPerYear`
has a specified value, the function divides the rate by that value instead.
forceCalc (bool) : (series bool) If `true`, calculates the ratio on every call. Otherwise, ratio calculation
only occurs on the last available bar. Optional. The default is `false`.
periodsPerYear (simple int) : (simple int) If specified, divides the annual rate by this value instead of the value
determined by the time span of the chart's data.
Returns: (float) The Sharpe ratio, which estimates the excess return per unit of total volatility.
method sortinoRatio(returnsArray, annualBenchmark, forceCalc, periodsPerYear)
Calculates the Sortino ratio for an array of periodic returns.
Callable as a method or a function.
Namespace types: array
Parameters:
returnsArray (array) : (array) An array of periodic return percentages, e.g., returns over monthly or
daily periods.
annualBenchmark (float) : (series float) The annual rate of return to compare against `returnsArray` values. When
`periodsPerYear` is `na`, the function divides this value by 12 to calculate a
monthly benchmark if the chart's data spans at least two months or 365 for a daily
benchmark if the data otherwise spans at least two days. If `periodsPerYear`
has a specified value, the function divides the rate by that value instead.
forceCalc (bool) : (series bool) If `true`, calculates the ratio on every call. Otherwise, ratio calculation
only occurs on the last available bar. Optional. The default is `false`.
periodsPerYear (simple int) : (simple int) If specified, divides the annual rate by this value instead of the value
determined by the time span of the chart's data.
Returns: (float) The Sortino ratio, which estimates the excess return per unit of downside
volatility.
TimeFilterLibrary "TimeFilter"
provides utilities for dates and times
inSession(session, timezone, period)
Parameters:
session (simple string)
timezone (simple string)
period (simple string)
Returns: bool inSession Whether the current time is within the defined time session
inDateRange(startDate, endDate)
Parameters:
startDate (int)
endDate (int)
Returns: bool inRange Whether the current time is within the defined date range
isWeekDay(weekDay, timezone)
Parameters:
weekDay (int)
timezone (simple string)
Returns: bool isWeekDay Whether the provided day is the current day of the week
inWeek(useMon, useTue, useWed, useThu, useFri, useSat, useSun, timezone)
Parameters:
useMon (bool)
useTue (bool)
useWed (bool)
useThu (bool)
useFri (bool)
useSat (bool)
useSun (bool)
timezone (simple string)
Returns: bool inWeek Whether the current time is one of the defined days
filter(useRange, useSession, useWeek, inRange, inSession, inWeek)
Parameters:
useRange (bool)
useSession (bool)
useWeek (bool)
inRange (bool)
inSession (bool)
inWeek (bool)
Returns: bool filter Whether the filter matches or not
FunctionTimeFrequencyLibrary "FunctionTimeFrequency"
Functions to encode time in a normalized space (-0.5, 0.5) that corresponds to the position of the
current time in the referrence frequency of time.
The purpose of normalizing the time value in this manner is to provide a consistent and easily comparable
representation of normalized time that can be used for various calculations or comparisons without needing
to consider the specific scale of time. This function can be particularly useful when working with high-precision
timing data, as it allows you to compare and manipulate time values more flexibly than using absolute second
counts alone.
Reference:
github.com
second_of_minute(t)
Second of minute encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
minute_of_hour(t)
Minute of hour encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
hour_of_day(t)
Hour of day encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
day_of_week(t)
Day of week encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
day_of_month(t)
Day of month encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
day_of_year(t)
Day of year encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
month_of_year(t)
Month of year encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
week_of_year(t)
Week of year encoded as value between (-0.5, 0.5).
Parameters:
t (int) : Time value.
Returns: normalized time.
[ALGOA+] AutofiboLibrary "Autofibo"
fibonacci(up, down, calculate, log, color1, color2, plot)
Creates an array with fibbonaci levels and plots lines.
Parameters:
up (float)
down (float)
calculate (bool)
log (bool)
color1 (color)
color2 (color)
plot (bool)
Returns: --> var float tupple.
fibonacciExtension(up, down, direction, log, calculate, color1, plot)
Fibonacci extension.
@description up (float) Up level.
@description down (float) Down level.
@description direction (string) Options "up" or "down".
Parameters:
up (float)
down (float)
direction (string)
log (bool)
calculate (bool)
color1 (color)
plot (bool)
Returns: -> var float, var float
trendFibo(uptrend, downtrend, log_option, color1, color2, plot)
Calculates automatic fibo values based on trends, returning a tupple with most important values.
Parameters:
uptrend (bool)
downtrend (bool)
log_option (bool)
color1 (color)
color2 (color)
plot (bool)
Returns:
signalLib_yashgode9Signal Generation Library = "signalLib_yashgode9"
This library, named "signalLib_yashgode9", is designed to generate buy and sell signals based on the price action of a financial instrument. It utilizes various technical indicators and parameters to determine the market direction and provide actionable signals for traders.
Key Features:-
1.Trend Direction Identification: The library calculates the trend direction by comparing the number of bars since the highest and lowest prices within a specified depth. This allows the library to determine the overall market direction, whether it's bullish or bearish.
2.Dynamic Price Tracking: The library maintains two chart points, zee1 and zee2, which dynamically track the price levels based on the identified market direction. These points serve as reference levels for generating buy and sell signals.
3.Customizable Parameters: The library allows users to adjust several parameters, including the depth of the price analysis, the deviation threshold, and the number of bars to consider for the trend direction. This flexibility enables users to fine-tune the library's behavior to suit their trading strategies.
4.Visual Representation: The library provides a visual representation of the buy and sell signals by drawing a line between the zee1 and zee2 chart points. The line's color changes based on the identified market direction, with red indicating a bearish signal and green indicating a bullish signal.
Usage and Integration:
To use this library, you can call the "signalLib_yashgode9" function and pass in the necessary parameters, such as the lower and higher prices, the depth of the analysis, the deviation threshold, and the number of bars to consider for the trend direction. The function will return the direction of the market (1 for bullish, -1 for bearish), as well as the zee1 and zee2 chart points.You can then use these values to generate buy and sell signals in your trading strategy. For example, you could use the direction value to determine when to enter or exit a trade, and the zee1 and zee2 chart points to set stop-loss or take-profit levels.
Potential Use Cases:
This library can be particularly useful for traders who:
1.Trend-following Strategies: The library's ability to identify the market direction can be beneficial for traders who employ trend-following strategies, as it can help them identify the dominant trend and time their entries and exits accordingly.
2.Swing Trading: The dynamic price tracking provided by the zee1 and zee2 chart points can be useful for swing traders, who aim to capture medium-term price movements.
3.Automated Trading Systems: The library's functionality can be integrated into automated trading systems, allowing for the development of more sophisticated and rule-based trading strategies.
4.Educational Purposes: The library can also be used for educational purposes, as it provides a clear and concise way to demonstrate the application of technical analysis concepts in a trading context.
Important Notice:- This library effectively work on timeframe of 5-minute and 15-minute.
ColourUtilitiesLibrary "ColourUtilities"
Utility functions for colour manipulation
adjust_colour(rgb, desaturation_amount, transparency_amount)
to reduce saturation or increase transparency of an RGB colour
Parameters:
rgb (color)
desaturation_amount (float) : 0 means no desaturation (colours remains as-is), and 1 means full desaturation (colour turns grey). Can also be used inversely with negative numbers
transparency_amount (float) : How much more transparent the default transparency should become. E.g. with a value of 0.5, a transparency of 0 becomes 50 and 40 becomes 70. A value of 1 makes it fully transparent, en -1 fully opaque.
Returns: color with adjusted saturation and transparency
method apply_default_palette(self, palette_name)
Some nice looking colour palettes, consisting of 6 gradient colours, are already defined here and can be quickly applied to the Palette class
Namespace types: Palette
Parameters:
self (Palette)
palette_name (string) : Currently there are 4 6-coloured palettes available: "GYTS flux signal", "GYTS purple", "GYTS flux filter" and "GYTS maroon"
Returns: None, as it populates the Palette class with pre-defined colours
method get_colour(self, colour_no, transparency)
Retrieves colour from the palette and possibly changes transparency if set
Namespace types: Palette
Parameters:
self (Palette)
colour_no (int) : from the palette
transparency (int) : to possibly change the default transparency of the palette
Returns: colour
method get_dynamic_colour(self, x, mid_point, colour_lb, colour_ub, trend_lookback, use_rate)
Retrieves a colour based on strength and direction of the passed series
Namespace types: Palette
Parameters:
self (Palette)
x (float) : the input data series
mid_point (float) : value as a cutoff point where the bullish/bearish colour scenario
colour_lb (float) : value (lower bound) where to apply the bearish colour at full strength
colour_ub (float) : value (upper bound) where to apply the bullish colour at full strength
trend_lookback (int) : how much bars back to check if there was a consistent move into a certain direction, otherwise a the neutral colour from the centre of the palette will be used.
use_rate (bool) : whether to use the rate (proportional difference with previous `x` value) or the input series `x` directly
Returns: colour
Palette
Fields:
transparency (series__integer)
palette (array__color)
VolumeSpreadAnalysisLibrary "VolumeSpreadAnalysis"
A library for Volume Spread Analysis (VSA).
spread(_barIndex)
Calculates the spread of a bar.
Parameters:
_barIndex (int) : (int) The index of the bar.
Returns: (float) The spread of the bar.
volume(_barIndex)
Retrieves the volume of a bar.
Parameters:
_barIndex (int) : (int) The index of the bar.
Returns: (float) The volume of the bar.
body(_barIndex)
Calculates the body of a bar.
Parameters:
_barIndex (simple int) : (int) The index of the bar.
Returns: (float) The body size of the bar.
wickUpper(_barIndex)
Calculates the upper wick of a bar (upper shadow).
Parameters:
_barIndex (simple int) : (int) The index of the bar.
Returns: (float) The upper wick size of the bar.
wickLower(_barIndex)
Calculates the lower wick of a bar (lower shadow).
Parameters:
_barIndex (simple int) : (int) The index of the bar.
Returns: (float) The lower wick size of the bar.
calcForecastedSMA(_source, _length, _forecastedLevel)
Calculates the forecasted Simple Moving Average (SMA).
Parameters:
_source (float) : (series float) Source data for calculation.
_length (simple int) : (int) The length of the SMA.
_forecastedLevel (float) : (float) The forecasted level to include in the calculation.
Returns: (float) The forecasted SMA value.
calcForecastedEMA(_source, _length, _forecastedLevel)
Calculates the forecasted Exponential Moving Average (EMA).
Parameters:
_source (float) : (series float) Source data for calculation.
_length (simple int) : (int) The length of the EMA.
_forecastedLevel (float) : (float) The forecasted level to include in the calculation.
Returns: (float) The forecasted EMA value.
calcForecastedRMA(_source, _length, _forecastedLevel)
Calculates the forecasted Relative Moving Average (RMA).
Parameters:
_source (float) : (series float) Source data for calculation.
_length (simple int) : (int) The length of the RMA.
_forecastedLevel (float) : (float) The forecasted level to include in the calculation.
Returns: (float) The forecasted RMA value.
calcForecastedWMA(_source, _length, _forecastedLevel)
Calculates the forecasted Weighted Moving Average (WMA).
Parameters:
_source (float) : (series float) Source data for calculation.
_length (simple int) : (int) The length of the WMA.
_forecastedLevel (float) : (float) The forecasted level to include in the calculation.
Returns: (float) The forecasted WMA value.
calcElapsedTimePercent()
Calculates the elapsed time percent of the current bar.
Returns: (float) The elapsed time percent.
calcForecastedSpread(multiplierAtMidpoints, multiplierAtPeaks)
Calculates the forecasted spread using elapsed time and dynamic multipliers, handling spread's non-linear nature.
Parameters:
multiplierAtMidpoints (float) : (float) The multiplier value at midpoints.
multiplierAtPeaks (float) : (float) The multiplier value at peaks.
Returns: (float) The forecasted spread value.
calcForecastedVolume()
Calculates the forecasted volume using elapsed time, satisfying volume's linear nature.
Returns: (float) The forecasted volume value.
calcForecastedMA(_source, _length, _forecastedSource, _type)
Calculates the forecasted Moving Average (MA) based on the specified type.
Parameters:
_source (float) : (series float) Source data for calculation.
_length (simple int) : (int) The length of the MA.
_forecastedSource (float) : (float) The forecasted level to include in the calculation.
_type (simple string) : (string) The type of the MA ("SMA", "EMA", "SMMA (RMA)", "WMA").
Returns: (float) The forecasted MA value.
calcMA(_source, _length, _type)
Calculates the Moving Average (MA) based on the specified type.
Parameters:
_source (float) : (series float) Source data for calculation.
_length (simple int) : (int) The length of the MA.
_type (simple string) : (string) The type of the MA ("SMA", "EMA", "SMMA (RMA)", "WMA").
Returns: (float) The MA value.
bullBar(_barIndex)
Determines if the bar is bullish.
Parameters:
_barIndex (simple int) : (int) The index of the bar.
Returns: (bool) True if the bar is bullish, otherwise false.
bearBar(_barIndex)
Determines if the bar is bearish.
Parameters:
_barIndex (simple int) : (int) The index of the bar.
Returns: (bool) True if the bar is bearish, otherwise false.
breakout(_barIndex)
Determines if there is a breakout above the previous bar.
Parameters:
_barIndex (simple int) : (int) The index of the bar.
Returns: (bool) True if there is a breakout, otherwise false.
breakdown(_barIndex)
Determines if there is a breakdown below the previous bar.
Parameters:
_barIndex (simple int) : (int) The index of the bar.
Returns: (bool) True if there is a breakdown, otherwise false.
rejectionWickUpper(_rejectionWick)
Determines if the upper wick is a rejection wick.
Parameters:
_rejectionWick (simple float) : (float) The rejection wick percentage.
Returns: (bool) True if the upper wick is a rejection wick, otherwise false.
rejectionWickLower(_rejectionWick)
Determines if the lower wick is a rejection wick.
Parameters:
_rejectionWick (simple float) : (float) The rejection wick percentage.
Returns: (bool) True if the lower wick is a rejection wick, otherwise false.
setupDataVolume(_data, _mult_Low, _mult_High, _mult_Ultra, _maLengthVolume, _maTypeVolume)
Sets up data for volume levels.
Parameters:
_data (map) : (map) The map to store the levels.
_mult_Low (simple float) : (float) The multiplier for low level.
_mult_High (simple float) : (float) The multiplier for high level.
_mult_Ultra (simple float) : (float) The multiplier for ultra level.
_maLengthVolume (simple int) : (int) The length for MA.
_maTypeVolume (simple string) : (string) The type for MA.
Returns: (void) Nothing.
setupDataSpread(_data, _mult_Low, _mult_High, _mult_Ultra, _maLengthSpread, _maTypeSpread)
Sets up data for spread levels.
Parameters:
_data (map) : (map) The map to store the levels.
_mult_Low (simple float) : (float) The multiplier for low level.
_mult_High (simple float) : (float) The multiplier for high level.
_mult_Ultra (simple float) : (float) The multiplier for ultra level.
_maLengthSpread (simple int) : (int) The length for MA.
_maTypeSpread (simple string) : (string) The type for MA.
Returns: (void) Nothing.
setupDataForecastVolume(_dataForecast, _mult_Low, _mult_High, _mult_Ultra, _maLengthVolume, _predictedLevelVolume, _maTypeVolume)
Sets up data for volume and spread levels for forecast.
Parameters:
_dataForecast (map)
_mult_Low (simple float) : (float) The multiplier for low level.
_mult_High (simple float) : (float) The multiplier for high level.
_mult_Ultra (simple float) : (float) The multiplier for ultra level.
_maLengthVolume (simple int) : (int) The length for MA.
_predictedLevelVolume (float) : (float) The predicted level for MA.
_maTypeVolume (simple string) : (string) The type for MA.
Returns: (void) Nothing.
setupDataForecastSpread(_dataForecast, _mult_Low, _mult_High, _mult_Ultra, _maLengthSpread, _predictedLevelSpread, _maTypeSpread)
Sets up data for spread levels for forecast.
Parameters:
_dataForecast (map)
_mult_Low (simple float) : (float) The multiplier for low level.
_mult_High (simple float) : (float) The multiplier for high level.
_mult_Ultra (simple float) : (float) The multiplier for ultra level.
_maLengthSpread (simple int) : (int) The length for MA.
_predictedLevelSpread (float) : (float) The predicted level for MA.
_maTypeSpread (simple string) : (string) The type for MA.
Returns: (void) Nothing.
isVolumeLow(_data, _barIndex)
Determines if the volume is low.
Parameters:
_data (map) : (map) The data map with volume levels.
_barIndex (int)
Returns: (bool) True if the volume is low, otherwise false.
isVolumeNormal(_data, _barIndex)
Determines if the volume is normal.
Parameters:
_data (map) : (map) The data map with volume levels.
_barIndex (int)
Returns: (bool) True if the volume is normal, otherwise false.
isVolumeHigh(_data, _barIndex)
Determines if the volume is high.
Parameters:
_data (map) : (map) The data map with volume levels.
_barIndex (int)
Returns: (bool) True if the volume is high, otherwise false.
isVolumeUltra(_data, _barIndex)
Determines if the volume is ultra.
Parameters:
_data (map) : (map) The data map with volume levels.
_barIndex (int)
Returns: (bool) True if the volume is ultra, otherwise false.
isSpreadLow(_data, _barIndex)
Determines if the spread is low.
Parameters:
_data (map) : (map) The data map with spread levels.
_barIndex (int)
Returns: (bool) True if the spread is low, otherwise false.
isSpreadNormal(_data, _barIndex)
Determines if the spread is normal.
Parameters:
_data (map) : (map) The data map with spread levels.
_barIndex (int)
Returns: (bool) True if the spread is normal, otherwise false.
isSpreadHigh(_data, _barIndex)
Determines if the spread is high.
Parameters:
_data (map) : (map) The data map with spread levels.
_barIndex (int)
Returns: (bool) True if the spread is high, otherwise false.
isSpreadUltra(_data, _barIndex)
Determines if the spread is ultra.
Parameters:
_data (map) : (map) The data map with spread levels.
_barIndex (int)
Returns: (bool) True if the spread is ultra, otherwise false.
isVolumeText(_data)
Determines text string representing the volume area level.
Parameters:
_data (map) : (map) The data map with volume levels.
Returns: (string) Text string of Low, Normal, High, or Ultra.
isSpreadText(_data)
Determines text string representing the spread area level.
Parameters:
_data (map) : (map) The data map with spread levels.
Returns: (string) Text string of Low, Normal, High, or Ultra.
calcBarColor(_value, _level)
Calculates the color based level.
Parameters:
_value (float) : (float) The value to check.
_level (float) : (float) The value level for comparison.
Returns: (color) The color for the bar.
bullPinBar(_maxBodyPercent, _minWickPercent)
Determines if the bar is a bull pin bar.
Parameters:
_maxBodyPercent (simple float) : (float) The maximum body percentage.
_minWickPercent (simple float) : (float) The minimum wick percentage.
Returns: (bool) True if the bar is a bull pin bar, otherwise false.
bearPinBar(_maxBodyPercent, _minWickPercent)
Determines if the bar is a bear pin bar.
Parameters:
_maxBodyPercent (simple float) : (float) The maximum body percentage.
_minWickPercent (simple float) : (float) The minimum wick percentage.
Returns: (bool) True if the bar is a bear pin bar, otherwise false.
dojiBar(_maxBodyPercent)
Determines if the bar is a doji.
Parameters:
_maxBodyPercent (simple float) : (float) The maximum body percentage.
Returns: (bool) True if the bar is a doji, otherwise false.
spinningTopBar(_minWicksPercent, _emaLength)
Determines if the bar is a spinning top.
Parameters:
_minWicksPercent (simple float) : (float) The minimum wicks percentage.
_emaLength (simple int) : (int) The length for EMA calculation.
Returns: (bool) True if the bar is a spinning top, otherwise false.
highWaveBar(_minBodyPercent, _minWickPercent, _bars)
Determines if the bar is a high wave bar.
Parameters:
_minBodyPercent (simple float) : (float) The minimum body percentage.
_minWickPercent (simple float) : (float) The minimum wick percentage.
_bars (simple int) : (int) The number of bars for comparison.
Returns: (bool) True if the bar is a high wave bar, otherwise false.
consolidationBar(_data, _spread, _bars)
Determines if the bars are in consolidation.
Parameters:
_data (map) : (map) The data map with spread levels.
_spread (simple float) : (float) The spread percentage for comparison.
_bars (simple int) : (int) The number of bars for comparison.
Returns: (bool) True if the bars are in consolidation, otherwise false.
S_DownThrust(_data, _bullPinBarMaxBody, _bullPinBarMinWick)
Determines if there is a sign of strength (DownThrust).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_bullPinBarMaxBody (simple float) : (float) The maximum body percentage for bull pin bar.
_bullPinBarMinWick (simple float) : (float) The minimum wick percentage for bull pin bar.
Returns: (bool) True if there is a sign of strength (DownThrust), otherwise false.
S_SellingClimax(_data, _rejectionWick)
Determines if there is a sign of strength (Selling Climax).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_rejectionWick (simple float) : (float) The rejection wick percentage.
Returns: (bool) True if there is a sign of strength (Selling Climax), otherwise false.
S_NoEffortBearishResult()
Determines if there is a sign of strength (No Effort Bearish Result).
Returns: (bool) True if there is a sign of strength (No Effort Bearish Result), otherwise false.
S_BearishEffortNoResult()
Determines if there is a sign of strength (Bearish Effort No Result).
Returns: (bool) True if there is a sign of strength (Bearish Effort No Result), otherwise false.
S_InverseDownThrust(_data, _bearPinBarMaxBody, _bearPinBarMinWick)
Determines if there is a sign of strength (Inverse DownThrust).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_bearPinBarMaxBody (simple float) : (float) The maximum body percentage for bear pin bar.
_bearPinBarMinWick (simple float) : (float) The minimum wick percentage for bear pin bar.
Returns: (bool) True if there is a sign of strength (Inverse DownThrust), otherwise false.
S_FailedSellingClimax()
Determines if there is a sign of strength (Failed Selling Climax).
Returns: (bool) True if there is a sign of strength (Failed Selling Climax), otherwise false.
S_BullOutsideReversal(_data)
Determines if there is a sign of strength (Bull Outside Reversal).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
Returns: (bool) True if there is a sign of strength (Bull Outside Reversal), otherwise false.
S_EndOfFallingMarket(_data)
Determines if there is a sign of strength (End of Falling Market).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
Returns: (bool) True if there is a sign of strength (End of Falling Market), otherwise false.
S_PseudoDownThrust(_bullPinBarMaxBody, _bullPinBarMinWick)
Determines if there is a sign of strength (Pseudo DownThrust).
Parameters:
_bullPinBarMaxBody (simple float) : (float) The maximum body percentage for bull pin bar.
_bullPinBarMinWick (simple float) : (float) The minimum wick percentage for bull pin bar.
Returns: (bool) True if there is a sign of strength (Pseudo DownThrust), otherwise false.
S_NoSupply(_bullPinBarMaxBody, _bullPinBarMinWick)
Determines if there is a sign of strength (No Supply).
Parameters:
_bullPinBarMaxBody (simple float) : (float) The maximum body percentage for bull pin bar.
_bullPinBarMinWick (simple float) : (float) The minimum wick percentage for bull pin bar.
Returns: (bool) True if there is a sign of strength (No Supply), otherwise false.
W_UpThrust(_data, _bearPinBarMaxBody, _bearPinBarMinWick)
Determines if there is a sign of weakness (UpThrust).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_bearPinBarMaxBody (simple float) : (float) The maximum body percentage for bear pin bar.
_bearPinBarMinWick (simple float) : (float) The minimum wick percentage for bear pin bar.
Returns: (bool) True if there is a sign of weakness (UpThrust), otherwise false.
W_BuyingClimax(_data, _rejectionWick)
Determines if there is a sign of weakness (Buying Climax).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_rejectionWick (simple float) : (float) The rejection wick percentage.
Returns: (bool) True if there is a sign of weakness (Buying Climax), otherwise false.
W_NoEffortBullishResult()
Determines if there is a sign of weakness (No Effort Bullish Result).
Returns: (bool) True if there is a sign of weakness (No Effort Bullish Result), otherwise false.
W_BullishEffortNoResult()
Determines if there is a sign of weakness (Bullish Effort No Result).
Returns: (bool) True if there is a sign of weakness (Bullish Effort No Result), otherwise false.
W_InverseUpThrust(_data, _bullPinBarMaxBody, _bullPinBarMinWick)
Determines if there is a sign of weakness (Inverse UpThrust).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_bullPinBarMaxBody (simple float) : (float) The maximum body percentage for bull pin bar.
_bullPinBarMinWick (simple float) : (float) The minimum wick percentage for bull pin bar.
Returns: (bool) True if there is a sign of weakness (Inverse UpThrust), otherwise false.
W_FailedBuyingClimax()
Determines if there is a sign of weakness (Failed Buying Climax).
Returns: (bool) True if there is a sign of weakness (Failed Buying Climax), otherwise false.
W_BearOutsideReversal(_data)
Determines if there is a sign of weakness (Bear Outside Reversal).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
Returns: (bool) True if there is a sign of weakness (Bear Outside Reversal), otherwise false.
W_EndOfRisingMarket(_data)
Determines if there is a sign of weakness (End of Rising Market).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
Returns: (bool) True if there is a sign of weakness (End of Rising Market), otherwise false.
W_PseudoUpThrust(_bearPinBarMaxBody, _bearPinBarMinWick)
Determines if there is a sign of weakness (Pseudo UpThrust).
Parameters:
_bearPinBarMaxBody (simple float) : (float) The maximum body percentage for bear pin bar.
_bearPinBarMinWick (simple float) : (float) The minimum wick percentage for bear pin bar.
Returns: (bool) True if there is a sign of weakness (Pseudo UpThrust), otherwise false.
W_NoDemand(_bearPinBarMaxBody, _bearPinBarMinWick)
Determines if there is a sign of weakness (No Demand).
Parameters:
_bearPinBarMaxBody (simple float) : (float) The maximum body percentage for bear pin bar.
_bearPinBarMinWick (simple float) : (float) The minimum wick percentage for bear pin bar.
Returns: (bool) True if there is a sign of weakness (No Demand), otherwise false.
N_QuietDoji(_dojiBarMaxBody)
Determines if there is a neutral signal (Quiet Doji).
Parameters:
_dojiBarMaxBody (simple float) : (float) The maximum body percentage for doji bar.
Returns: (bool) True if there is a neutral signal (Quiet Doji), otherwise false.
N_BalancedDoji(_data, _dojiBarMaxBody)
Determines if there is a neutral signal (Balanced Doji).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_dojiBarMaxBody (simple float) : (float) The maximum body percentage for doji bar.
Returns: (bool) True if there is a neutral signal (Balanced Doji), otherwise false.
N_StrongDoji(_dojiBarMaxBody)
Determines if there is a neutral signal (Strong Doji).
Parameters:
_dojiBarMaxBody (simple float) : (float) The maximum body percentage for doji bar.
Returns: (bool) True if there is a neutral signal (Strong Doji), otherwise false.
N_QuietSpinningTop(_spinningTopBarMinWicks, _spinningTopBarEmaLength)
Determines if there is a neutral signal (Quiet Spinning Top).
Parameters:
_spinningTopBarMinWicks (simple float) : (float) The minimum wicks percentage for spinning top bar.
_spinningTopBarEmaLength (simple int) : (int) The length for EMA calculation.
Returns: (bool) True if there is a neutral signal (Quiet Spinning Top), otherwise false.
N_BalancedSpinningTop(_data, _spinningTopBarMinWicks, _spinningTopBarEmaLength)
Determines if there is a neutral signal (Balanced Spinning Top).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_spinningTopBarMinWicks (simple float) : (float) The minimum wicks percentage for spinning top bar.
_spinningTopBarEmaLength (simple int) : (int) The length for EMA calculation.
Returns: (bool) True if there is a neutral signal (Balanced Spinning Top), otherwise false.
N_StrongSpinningTop(_spinningTopBarMinWicks, _spinningTopBarEmaLength)
Determines if there is a neutral signal (Strong Spinning Top).
Parameters:
_spinningTopBarMinWicks (simple float) : (float) The minimum wicks percentage for spinning top bar.
_spinningTopBarEmaLength (simple int) : (int) The length for EMA calculation.
Returns: (bool) True if there is a neutral signal (Strong Spinning Top), otherwise false.
N_QuietHighWave(_highWaveBarMinBody, _highWaveBarMinWick, _highWaveBarBars)
Determines if there is a neutral signal (Quiet High Wave).
Parameters:
_highWaveBarMinBody (simple float) : (float) The minimum body percentage for high wave bar.
_highWaveBarMinWick (simple float) : (float) The minimum wick percentage for high wave bar.
_highWaveBarBars (simple int) : (int) The number of bars for comparison.
Returns: (bool) True if there is a neutral signal (Quiet High Wave), otherwise false.
N_BalancedHighWave(_data, _highWaveBarMinBody, _highWaveBarMinWick, _highWaveBarBars)
Determines if there is a neutral signal (Balanced High Wave).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_highWaveBarMinBody (simple float) : (float) The minimum body percentage for high wave bar.
_highWaveBarMinWick (simple float) : (float) The minimum wick percentage for high wave bar.
_highWaveBarBars (simple int) : (int) The number of bars for comparison.
Returns: (bool) True if there is a neutral signal (Balanced High Wave), otherwise false.
N_StrongHighWave(_highWaveBarMinBody, _highWaveBarMinWick, _highWaveBarBars)
Determines if there is a neutral signal (Strong High Wave).
Parameters:
_highWaveBarMinBody (simple float) : (float) The minimum body percentage for high wave bar.
_highWaveBarMinWick (simple float) : (float) The minimum wick percentage for high wave bar.
_highWaveBarBars (simple int) : (int) The number of bars for comparison.
Returns: (bool) True if there is a neutral signal (Strong High Wave), otherwise false.
N_Consolidation(_data, _consolidationBarSpread, _consolidationBarBars)
Determines if there is a neutral signal (Consolidation).
Parameters:
_data (map) : (map) The data map with volume and spread levels.
_consolidationBarSpread (simple float) : (float) The spread percentage for consolidation bar.
_consolidationBarBars (simple int) : (int) The number of bars for comparison.
Returns: (bool) True if there is a neutral signal (Consolidation), otherwise false.
Volatility_ZigZag_LibraryThis is a Pine Script library for the public indicator "Volatility ZigZag" by brettkind. For further description, please refer to the information available on the original indicator page.
Library "Volatility_ZigZag_Library"
getValues_andStyling_VolatilityZigZag_byBrettkind(hl_src, SOURCE, length, min_dev_input, stdev_fctr, ZigZag, zz_color, zz_width, zz_devline, zz_points, zz_alert_sign, ZZ_Label, ZZ_Label_clr, rev_text, zz_bars_text, pcabs_text, avg_pcabs_text, pcrel_text, avg_pcrel_text, vol_text, avg_vol_text, input_currency)
Parameters:
hl_src (bool)
SOURCE (float)
length (int)
min_dev_input (float)
stdev_fctr (float)
ZigZag (bool)
zz_color (color)
zz_width (int)
zz_devline (bool)
zz_points (bool)
zz_alert_sign (bool)
ZZ_Label (bool)
ZZ_Label_clr (color)
rev_text (bool)
zz_bars_text (bool)
pcabs_text (bool)
avg_pcabs_text (bool)
pcrel_text (bool)
avg_pcrel_text (bool)
vol_text (bool)
avg_vol_text (bool)
input_currency (string)
getStatisticTable_VolatilityZigZag_byBrettkind(x1, Y1_array, draw_tbl)
Parameters:
x1 (int)
Y1_array (array)
draw_tbl (bool)
TRIGLibrary "TRIG"
degreesToRadians(degrees)
Parameters:
degrees (float)
radiansToDegrees(radians)
Parameters:
radians (float)
rt_get_angleAlphaFromLine(x1, y1, x2, y2, inDegrees)
Parameters:
x1 (int)
y1 (float)
x2 (int)
y2 (float)
inDegrees (bool)
rt_get_angleBetaFromLine(x1, y1, x2, y2)
Parameters:
x1 (int)
y1 (float)
x2 (int)
y2 (float)
ALGEBRALibrary "ALGEBRA"
line_fromXy(x1, y1, x2, y2)
Parameters:
x1 (int)
y1 (float)
x2 (int)
y2 (float)
line_getPrice(x, slope, yInt)
Parameters:
x (int)
slope (float)
yInt (float)
line_length(x1, y1, x2, y2)
Parameters:
x1 (int)
y1 (float)
x2 (int)
y2 (float)
distance(x1, y1, x2, y2)
Parameters:
x1 (int)
y1 (float)
x2 (int)
y2 (float)
ImrLibraryLibrary "ImrLibrary"
TODO: add library description here
STG(Length)
TODO: add function description here
Parameters:
Length (int)
Returns: TODO: add what function returns
ISI(Length)
Parameters:
Length (simple int)
statsLibrary "stats"
stats
factorial(x)
factorial
Parameters:
x (int)
standardize(x, length, lengthSmooth)
standardize
@description Moving Standardization of a time series.
Parameters:
x (float)
length (int)
lengthSmooth (int)
dnorm(x, mean, sd)
dnorm
@description Approximation for Normal Density Function.
Parameters:
x (float)
mean (float)
sd (float)
pnorm(x, mean, sd, log)
pnorm
@description Approximation for Normal Cumulative Distribution Function.
Parameters:
x (float)
mean (float)
sd (float)
log (bool)
ewma(x, length, tau_hl)
ewma
@description Exponentially Weighted Moving Average.
Parameters:
x (float)
length (int)
tau_hl (float)
ewm_sd(x, length, tau_hl)
Exponentially Weighted Moving Standard Deviation.
Parameters:
x (float)
length (int)
tau_hl (float)
ewm_scoring(x, length, tau_hl)
ewm_scoring
@description Exponentially Weighted Moving Standardization:
Parameters:
x (float)
length (int)
tau_hl (float)
colorLabLibrary "colorLab"
The ColorLab library presents an essential solution for color optimization, leveraging color terms and philosophy. Through its capabilities, it furnishes the necessary versatility to attain optimal color representation and coherence by integrating functions.
tint_level(colour, level)
Determines a Tinted color
Parameters:
colour (color) : (series color) Pure color.
level (float) : (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is white color.
Returns: (series color) A color Computed from a linear "Tint" gradient.
shade_level(colour, level)
Determines a Shaded color.
Parameters:
colour (color) : (series color) Pure color.
level (float) : (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is Black color.
Returns: (series color) A color Computed from a linear "Shade" gradient.
tone_level(colour, level)
Determines a Tone color.
Parameters:
colour (color) : (series color) Pure color.
level (float) : (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is Gray color.
Returns: (series color) A color Computed from a linear "Tone" gradient.
lightness_gradient(colour, value, bottom_value, top_value, bottom_lightness, top_lightness)
Determines a color from a "Lightness" gradient, based on the position of an entered value within a defined range.
Parameters:
colour (color) : (series color) Pure color.
value (float) : (series float) Value.
bottom_value (float) : (series float) Bottom Value.
top_value (float) : (series float) Top Value.
bottom_lightness (simple float) : (simple float) Optional argument, default = 70. Lightness Percentage. 100% is lightest and 0% is darkest
top_lightness (simple float) : (simple float) Optional argument, default = 30. Lightness Percentage. 100% is lightest and 0% is darkest
Returns: (series color) A color Computed a the linear "Lightness" gradient.
saturation_gradient(colour, value, bottom_value, top_value, bottom_saturated, top_saturated)
Determines a color from a "Saturation" gradient, based on the position of an entered value within a defined range.
Parameters:
colour (color) : (series color) Pure color.
value (float) : (series float) Value.
bottom_value (float) : (series float) Bottom Value.
top_value (float) : (series float) Top Value.
bottom_saturated (simple float) : (simple float) Optional argument, default = 15. Low Saturated Percentage.
top_saturated (simple float) : (simple float) Optional argument, default = 80. High Saturated Percentage.
Returns: (series color) A color Computed from a linear "Saturation" gradient.
hue_gradient(colour, value, bottom_value, top_value, bottom_hue, top_hue)
Determines a color from a "Hue" gradient, based on the position of an entered value within a defined range.
Parameters:
colour (color) : (series color) Pure color.
value (float) : (series float) Value.
bottom_value (float) : (series float) Bottom Value.
top_value (float) : (series float) Top Value.
bottom_hue (simple float) : (simple float) Optional argument, Default = 0. Low Hue is a degree where value in range 0 to 360 degrees.
top_hue (simple float) : (simple float) Optional argument, default = 300. High Hue is a degree where value in range 0 to 360 degrees.
Returns: (series color) A color Computed from a linear "Saturation" gradient.
opposColor(colour)
Generates the opposite color of inputted color.
Parameters:
colour (color) : (series color) Pure color.
Returns: (series color) An opposite color.
randColor(seed)
Generates a random color.
Parameters:
seed (simple int) : (simple int) Optional argument. With identifying seed, it will generate similar color sequence.
Returns: (series color) A random color.
bk_or_wh(colour, lightness)
Determines a white or back fits with an inputted color.
Parameters:
colour (color) : (series color) Pure color.
lightness (float) : (series float) Optional argument, default = 50. If the lightness percentage of inputted color is higher, the output is white; otherwise, it's black.
Returns: (series color) white or back color.
monochrome(colour, lightness, saturation)
Generates a monochromatic color scheme.
Parameters:
colour (color) : (series color) Pure color.
lightness (float) : (series float) Optional argument, default = NA. To custom Lightness percentage manually, 100% is lightest and 0% is darkest.
saturation (float) : (series float) Optional argument, default = NA. To custom Saturation percentage manually, 100% is highest and 0% is lowest saturated.
Returns: (tuple of two color series) .
complementary(colour)
Generates a complementary color scheme.
Parameters:
colour (color) : (series color) Pure color.
Returns: (tuple of two color series) .
analogous(colour)
Generates an analogous color scheme.
Parameters:
colour (color) : (series color) Pure color.
Returns: (tuple of three color series) .
triadic(colour)
Generates an Triadic color scheme.
Parameters:
colour (color) : (series color) Pure color.
Returns: (tuple of three color series) .
tetradic(colour)
Generates an Tetradic color scheme.
Parameters:
colour (color) : (series color) Main color.
Returns: (tuple of four color series) .
tst_scheme(colour, size, _type)
Generates an array of requested type (tint, shade, or tone) scheme colors.
Parameters:
colour (simple color) : (simple color) Pure color.
size (simple int) : (simple input) Number of elements in color array.
_type (simple string) : (simple string) Type of color scheme, possible input "tint", "shade", and "tone".
Returns: (simple array) An array contains elements of the requested type scheme colors.
lsh_scheme(colour, size, _type, topLevel, botLevel)
Generates an array of requested type (lightness, saturation or hue) scheme colors.
Parameters:
colour (simple color) : (simple color) Pure color.
size (simple int) : (simple input) Number of elements in color array.
_type (simple string) : (simple string) Type of color scheme, possible input "lightness", "saturation" and "hue".
topLevel (simple float) : (simple float) Optional argument, default = NA.
1. if "lightness", in a percentage where value in range 0 to 100, 100% lightest.
2. if "saturation", in a percentage where value in range 0 to 100, 100% highest saturated.
3. if "hue", in a degree where value in range 0 to 360 degrees.
botLevel (simple float) : (simple float) Optional argument, default = NA.
1. if "lightness", in a percentage where value in range 0 to 100, 0% darkest.
2. if "saturation", in a percentage where value in range 0 to 100, 0% lowest saturated.
3. if "hue", in a degree where value in range 0 to 360 degrees.
Returns: (simple array) An array contains elements of the requested type scheme colors.
display_color(colour, location)
Displays color including RGB and HSL.
Parameters:
colour (simple color) : (simple color) Pure color.
location (simple string) : (simple string) Optional argument, default = "top_right". cell location.
Returns: (simple table) A table cell contains RGB and HSL of entered color.
display_scheme(arrayColour, location)
Displays Scheme colors including RGB and HSL.
Parameters:
arrayColour (array)
location (simple string) : (simple string) Optional argument, default = "top_right". cell location.
Returns: (simple table) A table cells contain RGB and HSL of entered color.
TradersPost WebhookMessage Library - Automatically Build JSONLibrary "WebhookMessageLibrary"
The webhook message library provides several functions for building JSON payloads
method buildWebhookJson(msg, constants)
Builds the final JSON payload from a webhookMessage type.
Namespace types: webhookMessage
Parameters:
msg (webhookMessage) : (webhookMessage) A prepared webhookMessage.
constants (CONSTANTS)
Returns: A JSON Payload.
method buildTakeProfitJson(msg)
Builds the takeProfit JSON message to be used in a webhook message.
Namespace types: takeProfitMessage
Parameters:
msg (takeProfitMessage) : (takeProfitMessage)
Returns: A JSON takeProfit payload.
method buildStopLossJson(msg, constants)
Builds the stopLoss JSON message to be used in a webhook message.
Namespace types: stopLossMessage
Parameters:
msg (stopLossMessage) : (stopLossMessage)
constants (CONSTANTS)
Returns: A JSON stopLoss payload.
CONSTANTS
Constants for payload values.
Fields:
ACTION_BUY (series string)
ACTION_SELL (series string)
ACTION_EXIT (series string)
ACTION_CANCEL (series string)
ACTION_ADD (series string)
SENTIMENT_BULLISH (series string)
SENTIMENT_BEARISH (series string)
SENTIMENT_LONG (series string)
SENTIMENT_SHORT (series string)
SENTIMENT_FLAT (series string)
STOP_LOSS_TYPE_STOP (series string)
STOP_LOSS_TYPE_STOP_LIMIT (series string)
STOP_LOSS_TYPE_TRAILING_STOP (series string)
webhookMessage
Final webhook message.
Fields:
ticker (series string)
action (series string)
sentiment (series string)
price (series float)
quantity (series int)
takeProfit (series string)
stopLoss (series string)
takeProfitMessage
Take profit message.
Fields:
limitPrice (series float)
percent (series float)
amount (series float)
stopLossMessage
Stop loss message.
Fields:
type (series string)
percent (series float)
amount (series float)
stopPrice (series float)
limitPrice (series float)
trailPrice (series float)
trailPercent (series float)
EC_2025_Q4_ENLibrary "EC_2025_Q4_EN"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2025_Q3_ENLibrary "EC_2025_Q3_EN"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2025_Q2_ENLibrary "EC_2025_Q2_EN"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2025_Q1_ENLibrary "EC_2025_Q1_EN"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2025_Q4_SPLibrary "EC_2025_Q4_SP"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2025_Q3_SPLibrary "EC_2025_Q3_SP"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2025_Q2_SPLibrary "EC_2025_Q2_SP"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2025_Q1_SPLibrary "EC_2025_Q1_SP"
output2025()
Returns the list of events during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2025()
Returns the list of event names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2025()
Returns the list of impact names during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2025()
Returns the list of currencies during the period.
Returns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text