SupportResitanceAndTrendLibrary "SupportResitanceAndTrend"
Contains utilities for finding key levels of support, resistance and direction of trend.
superTrendPlus(multiple, h, l, atr, closeBars)
A more flexible version of SuperTrend that allows for supplying the series used and sensitivity adjustment by confirming close bars.
Parameters:
multiple : The multiple to apply to the average true range.
h : The high values.
l : The low values.
atr : The average true range values.
closeBars : The number of bars to confirm a change in trend.
Returns:
superTrend(multiple, period, mode, closeBars)
superTrendPlus with simplified parameters.
Parameters:
multiple : The multiple to apply to the average true range.
period : The number of bars to measure.
mode : The type of moving average to use with the true range.
closeBars : The number of bars to confirm a change in trend.
Returns:
superTrendCleaned(multiple, period, mode, closeBars, maxDeviation)
superTrendPlus with default compensation for extreme volatility.
Parameters:
multiple : The multiple to apply to the average true range.
period : The number of bars to measure.
mode : The type of moving average to use with the true range.
closeBars : The number of bars to confirm a change in trend.
maxDeviation : The optional standard deviation level to use when cleaning the series. The default is the value of the provided level.
Returns:
stochSR()
Identifies support and resistance levels by when a stochastic RSI reverses.
Returns:
stochAVWAP()
Identifies anchored VWAP levels by when a stochastic RSI reverses.
Returns:
Indicators and strategies
MovingAveragesLibrary "MovingAverages"
vawma(len, src, volumeDefault)
VAWMA = VWMA and WMA combined. Simply put, this attempts to determine the average price per share over time weighted heavier for recent values. Uses a triangular algorithm to taper off values in the past (same as WMA does).
Parameters:
len : The number of bars to measure with.
src : The series to measure from. Default is 'hlc3'.
volumeDefault : The default value to use when a chart has no (N/A) volume.
Returns: The volume adjusted triangular weighted moving average of the series.
cma(n, D, C, compound)
Coefficient Moving Avereage (CMA) is a variation of a moving average that can simulate SMA or WMA with the advantage of previous data.
Parameters:
n : The number of bars to measure with.
D : The series to measure from. Default is 'close'.
C : The coefficient to use when averaging. 0 behaves like SMA, 1 behaves like WMA.
compound : When true (default is false) will use a compounding method for weighting the average.
ema(len, src)
Same as ta.ema(src,len) but properly ignores NA values.
Parameters:
len : The number of samples to derive the average from.
src : The series to measure from. Default is 'close'.
wma(len, src, startingWeight)
Same as ta.wma(src,len) but properly ignores NA values.
Parameters:
len : The number of samples to derive the average from.
src : The series to measure from. Default is 'close'.
startingWeight : The weight to begin with when calculating the average. Higher numbers will decrease the bias.
vwma(len, src, volumeDefault)
Same as ta.vwma(src,len) but properly ignores NA values.
Parameters:
len : The number of bars to measure with.
src : The series to measure from. Default is 'hlc3'.
volumeDefault : The default value to use when a chart has no (N/A) volume.
get(type, len, src)
Generates a moving average based upon a 'type'.
Parameters:
type : The type of moving average to generate. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
len : The number of bars to measure with.
src : The series to measure from. Default is 'close'.
Returns: The moving average series requested.
DataCleanerLibrary "DataCleaner"
outlierLevel(src, len, level)
Gets the (standard deviation) outlier level for a given series.
Parameters:
src : The series to average and add a multiple of the standard deviation to.
len : The The number of bars to measure.
level : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
Returns: The average of the series plus the multiple of the standard deviation.
naOutliers(src, len, maxDeviation)
Returns only values that are within the maximum deviation.
Parameters:
src : The series to filter results from.
len : The The number of bars to measure.
maxDeviation : The maximum deviation before considered an outlier.
normalize(src, len, maxDeviation, baseline)
Returns the source value adjusted by its standard deviation.
Parameters:
src : The series to measure.
len : The number of bars to measure the standard deviation.
maxDeviation : The maximum deviation before considered an outlier.
baseline : The value considered to be at center. Typically zero.
cleanUsing(src, result, len, maxDeviation)
Returns an array representing the result series with (outliers provided by the source) removed.
Parameters:
src : The source series to read from.
result : The result series.
len : The maximum size of the resultant array.
maxDeviation : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
Returns: An array containing the cleaned series.
clean(src, len, maxDeviation)
Returns an array representing the source series with outliers removed.
Parameters:
src : The source series to read from.
len : The maximum size of the resultant array.
maxDeviation : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
Returns: An array containing the cleaned series.
cleanArray(src, maxDeviation)
Returns an array representing the source array with outliers removed.
Parameters:
src : The source series to read from.
maxDeviation : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
Returns: An array containing the cleaned series.
naArrayOutliers(src, maxDeviation)
Returns an array representing the source array with outliers removed.
Parameters:
src : The array to set outliers to N/A.
maxDeviation : The maximum deviation before considered an outlier.
Returns: True if there were any outliers; otherwise false.
outlierLevelAdjusted(src, len, level, maxDeviation)
Gets the (standard deviation) outlier level for a given series after a single pass of removing any outliers.
Parameters:
src : The series to average and add a multiple of the standard deviation to.
len : The The number of bars to measure.
level : The positive or negative multiple of the standard deviation to apply to the average. A positive number will be the upper boundary and a negative number will be the lower boundary.
maxDeviation : The optional standard deviation level to use when cleaning the series. The default is the value of the provided level.
Returns: The average of the series plus the multiple of the standard deviation.
FrostyBotLibrary "FrostyBot"
JSON Alert Builder for FrostyBot.js Binance Futures and FTX orders
github.com
More Complete Version Soon.
TODO: Comment Functions and annotations from command reference ^^
TODO: Add additional whitelist and symbol mappings.
leverage()
buy()
sell()
cancelall()
closelong()
closeshort()
traillong()
trailshort()
long()
short()
takeprofit()
stoploss()
DiscordLibraryLibrary "DiscordLibrary"
BoldString()
Bold String in Discord Function
ItalicizeString()
Italicize String in Discord Function
StrikeThroughString()
Strikethrough a String in Discord Function
UnderlineString()
Underline a String in Discord Function
SpoilerString()
When you send the text, it will be shown as a black block, and only by clicking on it will you be able to see what is written below, in a way, unveiling the text or giving spoilers
HighlightString()
Highlight String Function
BoxedString()
Put String in a Box Function
NonEmbeddedURLString()
Format URL String so that it is not an embedded Image but just the Link
InvisibleString()
Send Inivisible Text
FormatTimePeriodForDiscord()
GetDiscordEmbedJSON()
Generate discord embed JSON
GetDiscordTextJSON()
Formats Content Only JSON Message
Truncate()
Custom function to truncate (cut) excess decimal places
FormatDiscordMessage()
format Content message
FormatCoin()
Format Ticker Symbol
PineHelperLibrary "PineHelper"
This library provides various functions to reduce your time.
recent_opentrade_entry_bar_index()
get a recent opentrade entry bar_index
Returns: (int) bar_index
recent_closedtrade_entry_bar_index()
get a recent closedtrade entry bar_index
Returns: (int) bar_index
recent_closedtrade_exit_bar_index()
get a recent closedtrade exit bar_index
Returns: (int) bar_index
all_opnetrades_roi()
get all aopentrades roi
Returns: (float) roi
bars_since_recent_opentrade_entry()
get bars since recent opentrade entry
Returns: (int) number of bars
bars_since_recent_closedtrade_entry()
get bars since recent closedtrade entry
Returns: (int) number of bars
bars_since_recent_closedtrade_exit()
get bars since recent closedtrade exit
Returns: (int) number of bars
recent_opentrade_entry_id()
get recent opentrade entry ID
Returns: (string) entry ID
recent_closedtrade_entry_id()
get recent closedtrade entry ID
Returns: (string) entry ID
recent_closedtrade_exit_id()
get recent closedtrade exit ID
Returns: (string) exit ID
recent_opentrade_entry_price()
get recent opentrade entry price
Returns: (float) price
recent_closedtrade_entry_price()
get recent closedtrade entry price
Returns: (float) price
recent_closedtrade_exit_price()
get recent closedtrade exit price
Returns: (float) price
recent_opentrade_entry_time()
get recent opentrade entry time
Returns: (int) time
recent_closedtrade_entry_time()
get recent closedtrade entry time
Returns: (int) time
recent_closedtrade_exit_time()
get recent closedtrade exit time
Returns: (int) time
time_since_recent_opentrade_entry()
get time since recent opentrade entry
Returns: (int) time
time_since_recent_closedtrade_entry()
get time since recent closedtrade entry
Returns: (int) time
time_since_recent_closedtrade_exit()
get time since recent closedtrade exit
Returns: (int) time
recent_opentrade_size()
get recent opentrade size
Returns: (float) size
recent_closedtrade_size()
get recent closedtrade size
Returns: (float) size
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 : (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 : (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()
get bool using number of bars
Returns: (bool) allowedToTrade
discord_message(name, message)
get json format discord message
Parameters:
name : (string) name of bot
message : (string) message that you want to send
Returns: (string) json format string
telegram_message(chat_id, message)
get json format telegram message
Parameters:
chat_id : (string) chatId of bot
message : (string) message that you want to send
Returns: (string) json format string
MetaWorldEngineFilterLibrary3Library "MetaWorldEngineFilterLibrary3"
GetCandleStickSize(Rule, Rule)
returns size of the candle
Parameters:
Rule : 1: (float) _src_high
Rule : 2: (float) _src_low
Returns: candlestick size
GetCandleStickBodySize(Rule, Rule)
returns size of the candle body
Parameters:
Rule : 1: (float) _src_open
Rule : 2: (float) _src_close
Returns: candlestick body size
FilterLongerLowerWickCandles(Rule, Rule, Rule)
Alters Candlestick Value to Magnify Candles with Long Wicks
Parameters:
Rule : 1: (float) open
Rule : 2: (float) close
Rule : 2: (float) low
Returns: Midpoint of the candle body less the lower wick. If value returned has a large delta from midpoint of the body, then it is short wick
IsBullish(Rule, Rule)
Determine if Candle is Bullish or Bearish
Parameters:
Rule : 1: (float) open
Rule : 2: (float) close
Returns: True is Bullish
IsDoji(Rule, Rule)
Determine if Candle is a Doji
Parameters:
Rule : 1: (int) Candle Index
Rule : 2: (float) Percentage of candle size. Larger the Number the less stringent the doji criterion
Returns: True if a Doji
MACD(Rule, Rule, Rule, Rule)
Computes MACD
Parameters:
Rule : 1: (float) _src
Rule : 2: (int) _fastLength input fast ema length
Rule : 2: (int) _slowLength input slow ema length
Rule : 3: (int) _signalLength input length of signal line (sma of MACD line)
Returns: Returns MACD and Signal Line
isFastSlowCrossed(Rule, Rule)
Computes if SeriesA crosses SeriesB
Parameters:
Rule : 1: (float) Series Input
Rule : 2: (float) Series Input
Returns: if SeriesA crosses SeriesB then true else false
isReversalUpTrend(Rule, Rule)
Computes if SeriesA crosses over SeriesB to determine reversal uptrend
Parameters:
Rule : 1: (float) Series Input
Rule : 2: (float) Series Input
Returns: if SeriesA crosses over SeriesB then true else false
isReversalDownTrend(Rule, Rule)
Computes if SeriesA crosses over SeriesB to determine reversal uptrend
Parameters:
Rule : 1: (float) Series Input
Rule : 2: (float) Series Input
Returns: if SeriesA crosses over SeriesB then true else false
SSMA(Rule, Rule)
Computes smoothed SMA
Parameters:
Rule : 1: (float) source
Rule : 2: (float) sma length
Returns: a single concatenated string for evaluation
GetTimeFrame()
Get Current timeframe in minutes
Returns: an integer value in minutes
getMA(float, int, string, float)
Gets a Moving Average based on type
Parameters:
float : _src The source data
int : length The MA period
string : maType The type of MA
float : sigma / smoothness of ALMA, else NA
Returns: A moving average with the given parameters
TradersCustomLibraryLibrary "TradersCustomLibrary"
TODO: add library description here
SelectOptimalTimeframeTrendlineSettings()
calculateShortStopLoss()
calculateLongStopLoss()
werdygerTrend()
trendLines()
stoch()
timeToString()
obvFilterThis library comes with everything you need to add an On Balance Volume (OBV) filter to your strategy.
getOnBalanceVolumeFilter(source, maType, fastMaLength, fastMaLength)
Get the fast and slow moving average for on balance volume
Parameters:
source : hook this up to an 'input.source' input
maType : Choose from EMA, SMA, RMA, or WMA
fastMaLength : int smoothing length for fast moving average
fastMaLength : int smoothing length for fast moving average int smoothing length for slow moving average
Returns: Tuple with fast obv moving average and slow obv moving average
Add this to your strategy
▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾ ▾
import jordanfray/obvFilter/1 as obv
obvSource = input.source(defval=close, title="OBV Source", group="On Balance Volume Filter")
obvMaType = input.string(defval="EMA", title="OBV Smoothing Type", options = , group="On Balance Volume Filter")
fastMaLength = input.int(title = "Fast OBV MA Length", defval = 9, minval = 2, maxval = 200, group="On Balance Volume Filter")
slowMaLength = input.int(title = "Slow OBV MA Length", defval = 21, minval = 1, maxval = 200, group="On Balance Volume Filter")
= obv.getOnBalanceVolumeFilter(obvSource, obvMaType, fastMaLength, slowMaLength)
TrigLibrary "Trig"
Trigonometric functions
rt_get_angleAlpha(a, b, c, deg)
Get angle α of a right triangle, given the lengths of its sides
Parameters:
a : length of leg a (float)
b : length of leg b (float)
c : length of hypotenuse (float)
deg : flag to return angle in degrees (bool - default = false)
Returns: angle α in radians (or degrees if deg == true)
rt_get_angleAlphaFromLine(x1, y1, x2, y2, l, deg)
Get angle α of a right triangle formed by the given line
Parameters:
x1 : x coordinate 1 (int - optional, required if argument l is not specified)
y1 : y coordinate 1 (float - optional, required if argument l is not specified)
x2 : x coordinate 2 (int - optional, required if argument l is not specified)
y2 : y coordinate 2 (float - optional, required if argument l is not specified)
l : line object (line - optional, required if x1, y1, x2, and y2 agruments are not specified)
deg : flag to return angle in degrees (bool - default = false)
Returns: angle α in radians (or degrees if deg == true)
rt_get_angleBeta(a, b, c, deg)
Get angle β of a right triangle, given the lengths of its sides
Parameters:
a : length of leg a (float)
b : length of leg b (float)
c : length of hypotenuse (float)
deg : flag to return angle in degrees (bool - default = false)
Returns: angle β in radians (or degrees if deg == true)
rt_get_angleBetaFromLine(x1, y1, x2, y2, l, deg)
Get angle β of a right triangle formed by the given line
Parameters:
x1 : x coordinate 1 (int - optional, required if argument l is not specified)
y1 : y coordinate 1 (float - optional, required if argument l is not specified)
x2 : x coordinate 2 (int - optional, required if argument l is not specified)
y2 : y coordinate 2 (float - optional, required if argument l is not specified)
l : line object (line - optional, required if x1, y1, x2, and y2 agruments are not specified)
deg : flag to return angle in degrees (bool - default = false)
Returns: angle β in radians (or degrees if deg == true)
PlurexSignalLibrary "PlurexSignal"
Provides functions that wrap the built in TradingView strategy functions so you can seemlessly integrate with Plurex Signal automation.
NOTE: Be sure to set your strategy close_entries_rule="ANY" and pyramiding=20 or some other amount appropriate to your strategy in order to have multiple entries.
plurexMarket()
Build a Plurex market string from a base and quote asset symbol.
Returns: A market string that can be used in Plurex Signal messages.
tickerToPlurexMarket()
Builds Plurex market string from the syminfo
Returns: A market string that can be used in Plurex Signal messages.
simpleMessage(secret, action, marketOverride)
Builds Plurex Signal Message json to be sent to a Signal webhook
Parameters:
secret : The secret for your Signal on plurex
action : The action of the message. One of .
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
Returns: A json string message that can be used in alerts to send messages to Plurex.
long(secret, marketOverride, qty)
Open a new long entry. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
qty : Corresponds to strategy.entry qty
short(secret, marketOverride, qty)
Open a new short entry. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
qty : Corresponds to strategy.entry qty
closeAll(secret, marketOverride)
Close all positions. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
closeLongs(secret, marketOverride)
Close all longs. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
closeShorts(secret, marketOverride)
Close all shorts. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
closeLastLong(secret, marketOverride)
Close last long entry. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
closeFirstLong(secret, marketOverride)
Close first long entry. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
closeLastShort(secret, marketOverride)
Close last short entry. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
closeFirstShort(secret, marketOverride)
Close first short entry. Wraps strategy function and sends plurex message as an alert.
Parameters:
secret : The secret for your Signal on plurex
marketOverride : Optional, defaults to the syminfo for the ticker. Use the `plurexMarket` function to build your own.
Moving Averages ProxyLibrary "MovingAveragesProxy"
Moving Averages Proxy - Library of all moving averages spread out in different libraries
rvwap(_src, fixedTfInput, minsInput, hoursInput, daysInput, minBarsInput)
Calculates the Rolling VWAP (customized VWAP developed by the team of TradingView)
Parameters:
_src : (float) Source. Default: close
fixedTfInput : (bool) Use a fixed time period. Default: false
minsInput : (int) Minutes. Default: 0
hoursInput : (int) Hours. Default: 0
daysInput : (int) Days. Default: 1
minBarsInput : (int) Bars. Default: 10
Returns: (float) Rolling VWAP
correlationMa(src, len, factor)
Correlation Moving Average
Parameters:
src : (float) Source. Default: close
len : (int) Length
factor : (float) Factor. Default: 1.7
Returns: (float) Correlation Moving Average
regma(src, len, lambda)
Regularized Exponential Moving Average
Parameters:
src : (float) Source. Default: close
len : (int) Length
lambda : (float) Lambda. Default: 0.5
Returns: (float) Regularized Exponential Moving Average
repma(src, len)
Repulsion Moving Average
Parameters:
src : (float) Source. Default: close
len : (int) Length
Returns: (float) Repulsion Moving Average
epma(src, length, offset)
End Point Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
offset : (float) Offset. Default: 4
Returns: (float) End Point Moving Average
lc_lsma(src, length)
1LC-LSMA (1 line code lsma with 3 functions)
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) 1LC-LSMA Moving Average
aarma(src, length)
Adaptive Autonomous Recursive Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Adaptive Autonomous Recursive Moving Average
alsma(src, length)
Adaptive Least Squares
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Adaptive Least Squares
ahma(src, length)
Ahrens Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Ahrens Moving Average
adema(src)
Ahrens Moving Average
Parameters:
src : (float) Source. Default: close
Returns: (float) Moving Average
autol(src, lenDev)
Auto-Line
Parameters:
src : (float) Source. Default: close
lenDev : (int) Length for standard deviation
Returns: (float) Auto-Line
fibowma(src, length)
Fibonacci Weighted Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Moving Average
fisherlsma(src, length)
Fisher Least Squares Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Moving Average
leoma(src, length)
Leo Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Moving Average
linwma(src, period, weight)
Linear Weighted Moving Average
Parameters:
src : (float) Source. Default: close
period : (int) Length
weight : (int) Weight
Returns: (float) Moving Average
mcma(src, length)
McNicholl Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Moving Average
srwma(src, length)
Square Root Weighted Moving Average
Parameters:
src : (float) Source. Default: close
length : (int) Length
Returns: (float) Moving Average
EDSMA(src, len)
Ehlers Dynamic Smoothed Moving Average.
Parameters:
src : Series to use ('close' is used if no argument is supplied).
len : Lookback length to use.
Returns: EDSMA smoothing.
dema(x, t)
Double Exponential Moving Average.
Parameters:
x : Series to use ('close' is used if no argument is supplied).
t : Lookback length to use.
Returns: DEMA smoothing.
tema(src, len)
Triple Exponential Moving Average.
Parameters:
src : Series to use ('close' is used if no argument is supplied).
len : Lookback length to use.
Returns: TEMA smoothing.
smma(src, len)
Smoothed Moving Average.
Parameters:
src : Series to use ('close' is used if no argument is supplied).
len : Lookback length to use.
Returns: SMMA smoothing.
hullma(src, len)
Hull Moving Average.
Parameters:
src : Series to use ('close' is used if no argument is supplied).
len : Lookback length to use.
Returns: Hull smoothing.
frama(x, t)
Fractal Reactive Moving Average.
Parameters:
x : Series to use ('close' is used if no argument is supplied).
t : Lookback length to use.
Returns: FRAMA smoothing.
kama(x, t)
Kaufman's Adaptive Moving Average.
Parameters:
x : Series to use ('close' is used if no argument is supplied).
t : Lookback length to use.
Returns: KAMA smoothing.
vama(src, len)
Volatility Adjusted Moving Average.
Parameters:
src : Series to use ('close' is used if no argument is supplied).
len : Lookback length to use.
Returns: VAMA smoothing.
donchian(len)
Donchian Calculation.
Parameters:
len : Lookback length to use.
Returns: Average of the highest price and the lowest price for the specified look-back period.
Jurik(src, len)
Jurik Moving Average.
Parameters:
src : Series to use ('close' is used if no argument is supplied).
len : Lookback length to use.
Returns: JMA smoothing.
xema(src, len)
Optimized Exponential Moving Average.
Parameters:
src : Series to use ('close' is used if no argument is supplied).
len : Lookback length to use.
Returns: XEMA smoothing.
ehma(src, len)
EHMA - Exponential Hull Moving Average
Parameters:
src : Source
len : Period
Returns: Exponential Hull Moving Average (EHMA)
covwema(src, len)
Coefficient of Variation Weighted Exponential Moving Average (COVWEMA)
Parameters:
src : Source
len : Period
Returns: Coefficient of Variation Weighted Exponential Moving Average (COVWEMA)
covwma(src, len)
Coefficient of Variation Weighted Moving Average (COVWMA)
Parameters:
src : Source
len : Period
Returns: Coefficient of Variation Weighted Moving Average (COVWMA)
eframa(src, len, FC, SC)
Ehlrs Modified Fractal Adaptive Moving Average (EFRAMA)
Parameters:
src : Source
len : Period
FC : Lower Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average
SC : Upper Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average
Returns: Ehlrs Modified Fractal Adaptive Moving Average (EFRAMA)
etma(src, len)
Exponential Triangular Moving Average (ETMA)
Parameters:
src : Source
len : Period
Returns: Exponential Triangular Moving Average (ETMA)
rma(src, len)
RMA - RSI Moving average
Parameters:
src : Source
len : Period
Returns: RSI Moving average (RMA)
thma(src, len)
THMA - Triple Hull Moving Average
Parameters:
src : Source
len : Period
Returns: Triple Hull Moving Average (THMA)
vidya(src, len)
Variable Index Dynamic Average (VIDYA)
Parameters:
src : Source
len : Period
Returns: Variable Index Dynamic Average (VIDYA)
zsma(src, len)
Zero-Lag Simple Moving Average (ZSMA)
Parameters:
src : Source
len : Period
Returns: Zero-Lag Simple Moving Average (ZSMA)
zema(src, len)
Zero-Lag Exponential Moving Average (ZEMA)
Parameters:
src : Source
len : Period
Returns: Zero-Lag Exponential Moving Average (ZEMA)
evwma(src, len)
EVWMA - Elastic Volume Weighted Moving Average
Parameters:
src : Source
len : Period
Returns: Elastic Volume Weighted Moving Average (EVWMA)
tt3(src, len, a1_t3)
Tillson T3
Parameters:
src : Source
len : Period
a1_t3 : Tillson T3 Volume Factor
Returns: Tillson T3
gma(src, len)
GMA - Geometric Moving Average
Parameters:
src : Source
len : Period
Returns: Geometric Moving Average (GMA)
wwma(src, len)
WWMA - Welles Wilder Moving Average
Parameters:
src : Source
len : Period
Returns: Welles Wilder Moving Average (WWMA)
cma(src, len)
Corrective Moving average (CMA)
Parameters:
src : Source
len : Period
Returns: Corrective Moving average (CMA)
edma(src, len)
Exponentially Deviating Moving Average (MZ EDMA)
Parameters:
src : Source
len : Period
Returns: Exponentially Deviating Moving Average (MZ EDMA)
rema(src, len)
Range EMA (REMA)
Parameters:
src : Source
len : Period
Returns: Range EMA (REMA)
sw_ma(src, len)
Sine-Weighted Moving Average (SW-MA)
Parameters:
src : Source
len : Period
Returns: Sine-Weighted Moving Average (SW-MA)
mama(src, len)
MAMA - MESA Adaptive Moving Average
Parameters:
src : Source
len : Period
Returns: MESA Adaptive Moving Average (MAMA)
fama(src, len)
FAMA - Following Adaptive Moving Average
Parameters:
src : Source
len : Period
Returns: Following Adaptive Moving Average (FAMA)
hkama(src, len)
HKAMA - Hilbert based Kaufman's Adaptive Moving Average
Parameters:
src : Source
len : Period
Returns: Hilbert based Kaufman's Adaptive Moving Average (HKAMA)
getMovingAverage(type, src, len, lsmaOffset, inputAlmaOffset, inputAlmaSigma, FC, SC, a1_t3, fixedTfInput, daysInput, hoursInput, minsInput, minBarsInput, lambda, volumeWeighted, gamma_aarma, smooth, linweight, volatility_lookback, jurik_phase, jurik_power)
Abstract proxy function that invokes the calculation of a moving average according to type
Parameters:
type : (string) Type of moving average
src : (float) Source of series (close, high, low, etc.)
len : (int) Period of loopback to calculate the average
lsmaOffset : (int) Offset for Least Squares MA
inputAlmaOffset : (float) Offset for ALMA
inputAlmaSigma : (float) Sigma for ALMA
FC : (int) Lower Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average
SC : (int) Upper Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average
a1_t3 : (float) Tillson T3 Volume Factor
fixedTfInput : (bool) Use a fixed time period in Rolling VWAP
daysInput : (int) Days in Rolling VWAP
hoursInput : (int) Hours in Rolling VWAP
minsInput : (int) Minutrs in Rolling VWAP
minBarsInput : (int) Bars in Rolling VWAP
lambda : (float) Regularization Constant in Regularized EMA
volumeWeighted : (bool) Apply volume weighted calculation in selected moving average
gamma_aarma : (float) Gamma for Adaptive Autonomous Recursive Moving Average
smooth : (float) Smooth for Adaptive Least Squares
linweight : (float) Weight for Volume Weighted Moving Average
volatility_lookback : (int) Loopback for Volatility Adjusted Moving Average
jurik_phase : (int) Phase for Jurik Moving Average
jurik_power : (int) Power for Jurik Moving Average
Returns: (float) Moving average
TALibrary "TA"
General technical analysis functions
div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW)
Test for bullish divergence
Parameters:
pS : Price series (float)
iS : Indicator series (float)
cp_length_after : Bars after current (divergent) pivot low to be considered a valid pivot (optional int)
cp_length_before : Bars before current (divergent) pivot low to be considered a valid pivot (optional int)
pivot_length : Bars before and after prior pivot low to be considered valid pivot (optional int)
lookback : Bars back to search for prior pivot low (optional int)
no_broken : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW : Weight of change in price, used in degree of divergence calculation (optional float)
iW : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
div_bear(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW)
Test for bearish divergence
Parameters:
pS : Price series (float)
iS : Indicator series (float)
cp_length_after : Bars after current (divergent) pivot high to be considered a valid pivot (optional int)
cp_length_before : Bars before current (divergent) pivot highto be considered a valid pivot (optional int)
pivot_length : Bars before and after prior pivot high to be considered valid pivot (optional int)
lookback : Bars back to search for prior pivot high (optional int)
no_broken : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW : Weight of change in price, used in degree of divergence calculation (optional float)
iW : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
AlgebraLibrary "Algebra"
Algebra functions.
line_fromXy(x1, y1, x2, y2)
Get line slope and y-intercept from coordinates
Parameters:
x1 : x coordinate 1 (int - bar index)
y1 : y coordinate 1 (float - price/value)
x2 : x coordinate 2 (int - bar index)
y2 : y coordinate 2 (float - price/value)
Returns: of line
line_getPrice(x, slope, yInt)
Get line slope and y-intercept from coordinates
Parameters:
x : x coordinate to solve for y (int - bar index)
slope : slope of line (float)
yInt : y-intercept of line (float)
Returns: y (price/value)
ConsoleLibrary "Console"
█ OVERVIEW
An easy way to output messages to a console like table using a a simple "print" function that can be called from anywhere in your code including functions.
█ Supports:
- Scrollable console messages
- Customisable number of displayed messages
- More than one "console" for different types of output if required
- The ability to choose which message to start viewing from (useful if the message list is long)
- The ability to place the console table at different positions on the chart to mitigate against
overwriting an existing table.
█ Limitations:
The "scrollbar" handle is actually a modified time widget handle. As the handle is grabbed and moved left or right across the chart bars, this script calculates the offset of the bar being pointed to from the last bar in the chart and uses that as the console message offset. However, It isn't possible to position this on the last chart bar with code.
So there are two solutions:
1) Manually change timestamp of the variable scrollStart to the current time (roughly)
eg. scrollStart = "25 Dec 2022 14:30 +0000"
2) Use a higher timeframe (Weeks or Months) and visually find the scroll bar. If it is to the right of the chart bars the console output will read NaN. Grab the handle and move it left and it will snap to the last chart candle position. If it is to the left then find it and move it to the right as needed.
█ Notes On Usage
- Import the library as console (the call will be console.print(...) )
- Assign a console variable name and call the console.initialise function
eg. var con1=console.initialise()
- Use the console.print() function to print a message or messages
This takes two parameters:
_consoleName :this is the console name you are printing to
_message: this is the message that you want to display. It is a string and can be built in the normal way using any pinescript string functions like str.tostring() etc
- Use the console.display function to display the messages.
To work as intended this display function should be placed at the last line with the following code
if i_showMessages
....if i_displayTable == "con1"
........display(con1, i_lineOffset, i_rowsToDisplay, i_gotoMsg, posn)
(More "consoles" can be written to and the example code provided with the library shows this in more detail. Also, the indents don't show in these notes)
Lastly, placement of a console.print() without a qualifying "if" statement will occur for every bar. This may be desired. If not then use under an if statement (example in the supplied code).
Happy debugging :)
-----------------------------------------------------------------------------------------------------------
initialise()
initialise: creates the message array
Parameters:
none :
Returns: message array: this is assigned to the "console" identifier
print(_consoleName, _message)
used to output the desired text string to the console
Parameters:
_consoleName : : the message array
_message : : the console message
Returns: none
display(_consoleName, _lineOffset, _rowsToDisplay, _gotoMsg, _posn)
display: placed in the last section of code. Displays the console messages
Parameters:
_consoleName : : the message array
_lineOffset : : the setting of the scroll bar (time widget)
_rowsToDisplay : : how many rows to show in the console table
_gotoMsg : : which message to display from (default is 0)
_posn : : where the console table will be displayed
Returns: none
KlintLibraryLibrary "KlintLibrary"
GetDecimals()
this is my library, for my own use
thanks for reading
UtilitiesLibrary "Utilities"
General utilities
print_series(s, skip_na, position, show_index, from_index, to_index)
Print series values
Parameters:
s : Series (string)
skip_na : Flag to skip na values (optional bool, dft = false)
position : Position to print the Table (optional string, dft = position.bottom_center)
show_index : Flag to show series indices (optional bool, dft = true)
from_index : First index to print (optional int, dft = 0)
to_index : Last index to print (optional int, dft = last_bar_index)
Returns: Table object, if series was printed
print(v, position, at_index)
Print value
Parameters:
v : Value (string)
position : Position to print the Table (optional string, dft = position.bottom_center)
at_index : Index at which to print (optional int, dft = last_bar_index)
Returns: Table object, if value was printed
lower_tf█ OVERVIEW
This library is a Pine programmer’s tool containing functions to help those who use the request.security_lower_tf() function. Its `ltf()` function helps translate user inputs into a lower timeframe string usable with request.security_lower_tf() . Another function, `ltfStats()`, accumulates statistics on processed chart bars and intrabars.
█ CONCEPTS
Chart bars
Chart bars , as referred to in our publications, are bars that occur at the current chart timeframe, as opposed to those that occur at a timeframe that is higher or lower than that of the chart view.
Intrabars
Intrabars are chart bars at a lower timeframe than the chart's. Each 1H chart bar of a 24x7 market will, for example, usually contain 60 intrabars at the LTF of 1min, provided there was market activity during each minute of the hour. Mining information from intrabars can be useful in that it offers traders visibility on the activity inside a chart bar.
Lower timeframes (LTFs)
A lower timeframe is a timeframe that is smaller than the chart's timeframe. This framework exemplifies how authors can determine which LTF to use by examining the chart's timeframe. The LTF determines how many intrabars are examined for each chart bar; the lower the timeframe, the more intrabars are analyzed.
Intrabar precision
The precision of calculations increases with the number of intrabars analyzed for each chart bar. As there is a 100K limit to the number of intrabars that can be analyzed by a script, a trade-off occurs between the number of intrabars analyzed per chart bar and the chart bars for which calculations are possible.
█ `ltf()`
This function returns a timeframe string usable with request.security_lower_tf() . It calculates the returned timeframe by taking into account a user selection between eight different calculation modes and the chart's timeframe. You send it the user's selection, along with the text corresponding to the eight choices from which the user has chosen, and the function returns a corresponding LTF string.
Because the function processes strings and doesn't require recalculation on each bar, using var to declare the variable to which its result is assigned will execute the function only once on bar zero and speed up your script:
var string ltfString = ltf(ltfModeInput, LTF1, LTF2, LTF3, LTF4, LTF5, LTF6, LTF7, LTF8)
The eight choices users can select from are of two types: the first four allow a selection from the desired amount of chart bars to be covered, the last four are choices of a fixed number of intrabars to be analyzed per chart bar. Our example code shows how to structure your input call and then make the call to `ltf()`. By changing the text associated with the `LTF1` to `LTF8` constants, you can tailor it to your preferences while preserving the functionality of `ltf()` because you will be sending those string constants as the function's arguments so it can determine the user's selection. The association between each `LTFx` constant and its calculation mode is fixed, so the order of the arguments is important when you call `ltf()`.
These are the first four modes and the `LTFx` constants corresponding to each:
Covering most chart bars (least precise) — LTF1
Covers all chart bars. This is accomplished by dividing the current timeframe in seconds by 4 and converting that number back to a string in timeframe.period format using secondsToTfString() . Due to the fact that, on premium subscriptions, the typical historical bar count is between 20-25k bars, dividing the timeframe by 4 ensures the highest level of intrabar precision possible while achieving complete coverage for the entire dataset with the maximum allowed 100K intrabars.
Covering some chart bars (less precise) — LTF2
Covering less chart bars (more precise) — LTF3
These levels offer a stepped LTF in relation to the chart timeframe with slightly more, or slightly less precision. The stepped lower timeframe tiers are calculated from the chart timeframe as follows:
Chart Timeframe Lower Timeframe
Less Precise More Precise
< 1hr 1min 1min
< 1D 15min 1min
< 1W 2hr 30min
> 1W 1D 60min
Covering the least chart bars (most precise) — LTF4
Analyzes the maximum quantity of intrabars possible by using the 1min LTF, which also allows the least amount of chart bars to be covered.
The last four modes allow the user to specify a fixed number of intrabars to analyze per chart bar. Users can choose from 12, 24, 50 or 100 intrabars, respectively corresponding to the `LTF5`, `LTF6`, `LTF7` and `LTF8` constants. The value is a target; the function will do its best to come up with a LTF producing the required number of intrabars. Because of considerations such as the length of a ticker's session, rounding of the LTF to the closest allowable timeframe, or the lowest allowable timeframe of 1min intrabars, it is often impossible for the function to find a LTF producing the exact number of intrabars. Requesting 100 intrabars on a 60min chart, for example, can only produce 60 1min intrabars. Higher chart timeframes, tickers with high liquidity or 24x7 markets will produce optimal results.
█ `ltfStats()`
`ltfStats()` returns statistics that will be useful to programmers using intrabar inspection. By analyzing the arrays returned by request.security_lower_tf() in can determine:
• intrabarsInChartBar : The number of intrabars analyzed for each chart bar.
• chartBarsCovered : The number of chart bars where intrabar information is available.
• avgIntrabars : The average number of intrabars analyzed per chart bar. Events like holidays, market activity, or reduced hours sessions can cause the number of intrabars to vary, bar to bar.
The function must be called on each bar to produce reliable results.
█ DEMONSTRATION CODE
Our example code shows how to provide users with an input from which they can select a LTF calculation mode. If you use this library's functions, feel free to reuse our input setup code, including the tooltip providing users with explanations on how it works for them.
We make a simple call to request.security_lower_tf() to fetch the close values of intrabars, but we do not use those values. We simply send the returned array to `ltfStats()` and then plot in the indicator's pane the number of intrabars examined on each bar and its average. We also display an information box showing the user's selection of the LTF calculation mode, the resulting LTF calculated by `ltf()` and some statistics.
█ NOTES
• As in several of our recent publications, this script uses secondsToTfString() to produce a timeframe string in timeframe.period format from a timeframe expressed in seconds.
• The script utilizes display.data_window and display.status_line to restrict the display of certain plots.
These new built-ins allow coders to fine-tune where a script’s plot values are displayed.
• We implement a new recommended best practice for tables which works faster and reduces memory consumption.
Using this new method, tables are declared only once with var , as usual. Then, on bar zero only, we use table.cell() calls to populate the table.
Finally, table.set_*() functions are used to update attributes of table cells on the last bar of the dataset.
This greatly reduces the resources required to render tables. We encourage all Pine Script™ programmers to do the same.
Look first. Then leap.
█ FUNCTIONS
The library contains the following functions:
ltf(userSelection, choice1, choice2, choice3, choice4, choice5, choice6, choice7, choice8)
Selects a LTF from the chart's TF, depending on the `userSelection` input string.
Parameters:
userSelection : (simple string) User-selected input string which must be one of the `choicex` arguments.
choice1 : (simple string) Input selection corresponding to "Least precise, covering most chart bars".
choice2 : (simple string) Input selection corresponding to "Less precise, covering some chart bars".
choice3 : (simple string) Input selection corresponding to "More precise, covering less chart bars".
choice4 : (simple string) Input selection corresponding to "Most precise, 1min intrabars".
choice5 : (simple string) Input selection corresponding to "~12 intrabars per chart bar".
choice6 : (simple string) Input selection corresponding to "~24 intrabars per chart bar".
choice7 : (simple string) Input selection corresponding to "~50 intrabars per chart bar".
choice8 : (simple string) Input selection corresponding to "~100 intrabars per chart bar".
Returns: (simple string) A timeframe string to be used with `request.security_lower_tf()`.
ltfStats()
Returns statistics about analyzed intrabars and chart bars covered by calls to `request.security_lower_tf()`.
Parameters:
intrabarValues : (float [ ]) The ID of a float array containing values fetched by a call to `request.security_lower_tf()`.
Returns: A 3-element tuple: [ (series int) intrabarsInChartBar, (series int) chartBarsCovered, (series float) avgIntrabars ].
HSV and HSL gradient Tools ( Built-in Drop-in replacement )Library "hsvColor"
HSV and HSL Gradient Tool Alternatives and helpers. Demo'd is built-in in the middle with HSL/HSV gradients on top/bottom
TODO: Solve for #000000 issue
rgbhsv(_col)
RGB Color to HSV Values
Parameters:
_col : Color input (#abc012 or color.name or color.rgb(0,0,0,0))
Returns: values
rgbhsv(_r, _g, _b, _t)
RGB Color to HSV Values
Parameters:
_r : Red 0 - 255
_g : Green 0 - 255
_b : Blue 0 - 255
_t : Transp 0 - 100
Returns: values
hsv(_h, _s, _v, _a)
HSV colors, Auto fix if past boundaries
Parameters:
_h : Hue Input (-360 - 360) or further
_s : Saturation 0.- 1.
_v : Value 0.- 1.
_a : Alpha 0.- 1.
Returns: Color output
hue(_col)
returns 0-359 hue on color wheel
Parameters:
_col :
Returns: 360 degree hue value
hsv_gradient(signal, _startVal, _endVal, _startCol, _endCol)
Color Gradient Replacement Function for HSV calculated Gradents
Parameters:
signal : Control signal
_startVal : start color limit
_endVal : end color limit
_startCol : start color
_endCol : end color
Returns: HSV calculated gradient
hsl_gradient(signal, _startVal, _endVal, _startCol, _endCol)
Color Gradient Replacement Function for HSV calculated Gradents
Parameters:
signal : Control signal
_startVal : start color limit
_endVal : end color limit
_startCol : start color
_endCol : end color
Returns: HSV calculated gradient
Tosch Stacked EMAs (Fibonacci)Library "Tosch_Stacked_EMAs (Fibonacci)"
stacked()
Returns true if all EMAs are stacked, either way.
bullish()
Returns true if the EMAs are stacked bullish, false otherwise
emas()
Returns the EMA values for lengths 5, 8, 13, 21, 34, 55, 89
Tosch Market Sessions (US/GB/JP)Library "Tosch Market Sessions"
Returns if the NYSE, London SE, Tokyo SE are open
@function Returns if the NYSE (US), London SE (GB), Tokyo SE (JP) are open
@returns
bus, bgb, bjp - bool: true if the corresponding exchange is open
count - int: count of how many exchanges are open at the moment
ccolor - color: color that indicates the number of open exchanges
0 => color.black
1 => color.blue
2 => color.orange
3 => color.white
Chaikin Money Flow - LibraryLibrary "Chaikin Money Flow"
cmf()
Developed by Marc Chaikin, Chaikin Money Flow measures the amount of Money Flow Volume over a specific period.
Money Flow Volume forms the basis for the Accumulation Distribution Line. Instead of a cumulative total of
Money Flow Volume, Chaikin Money Flow simply sums Money Flow Volume for a specific look-back period, typically
20 or 21 days. The resulting indicator fluctuates above/below the zero line just like an oscillator. Chartists
weigh the balance of buying or selling pressure with the absolute level of Chaikin Money Flow. Chartists can
also look for crosses above or below the zero line to identify changes on money flow.
The Accumulation Distribution Line was developed by Marc Chaikin to measure the cumulative flow of money into and
out of an index or security. The Accumulation/Distribution Line can be compared to the OBV (On Balance Volume),
which adds or subtracts volume depending on the closing price. Marc Chaikin chose a different approach, instead
of relying on the closing price, he used CLV (Close Location Value).
testJust testing how to use libraries ignore this
Just testing how to use libraries ignore this
Just testing how to use libraries ignore this
Just testing how to use libraries ignore this
Just testing how to use libraries ignore this