High Risk Trading TimeLibrary "HighRiskTradingTime"
Utilities for time range labeling
openTime()
timeMinInDay(t, timezone)
Convert given time to minutes of day
Parameters:
t (int) : Time
timezone (string) : Timezone of the input h:m
@return Minutes of day
All exported functions args should be typified
timeMinInDayManual(h, m)
Convert given hour and minute to minutes of day
Parameters:
h (int) : Hour in a day
m (int) : Minute in a day
isForexHighRiskTime()
Return if current time is High Risk for Forex
Indicators and strategies
TimeFormattingLibraryLibrary "TimeFormattingLibrary"
Time formatting functions: formating functions to make timestrings more human readable friendly (for both fixed time and time-elapsed).
Also functions for last and first instance in month of day of week input.
Also a function for identifying bank holiday Mondays.
timeFormatFxn(showDayOfWeek, showDayOfMonth, showMonth, showYear, showHrMin, _time, _timezone)
converts time into readable format
Parameters:
showDayOfWeek (bool) : if you want to show day of week (i.e. Mon, Tues etc)
showDayOfMonth (bool) : if you want to show day number of month with superscript ordinals (i.e. 1ˢᵗ, 2ⁿᵈ, etc)
showMonth (bool) : if you want to show the month (i.e. Jan, Feb, etc)
showYear (bool) : if you want to show the year (i.e. 2023)
showHrMin (bool) : if you want to show time in 24hr clock format
_time (int) : is the unix time (i.e. time or time_close)
_timezone (string) : the user timezone input as string (e.g. "America/New_York", "UTC-5", "GMT+0530")
Returns: time date string
timeElapsedFxn(timespan)
converts timespan into readable format
Parameters:
timespan (int) : is the length of time in milliseconds to be converted into a human readable string
Returns: timespan string (whether it be a for showing 'time-elapsed' or for showing a 'countdown timer')
isFirstXdayofmonth(_dayofweek)
gives bool result for when first occurence in month of the day-of-week input
Parameters:
_dayofweek (int) : (can be integer 1-7 or can be dayofweek variable; i.e. dayofweek.wednesday)
isLastXdayofmonth(_dayofweek)
gives bool result for when last occurence in month of the day-of-week input
Parameters:
_dayofweek (int) : (can be integer 1-7 or can be dayofweek variable; i.e. dayofweek.wednesday)
wasBankHolidayMonday()
gives bool result for if yesterday was a bank holiday monday. Only for use with with request.security() function, see example code below
WeightedSumIndexLibrary "WeightedSumIndex"
WeightedSumIndex: Helper class to build indices.
Index value is a normalized weighted sum of all its input signals.
The value is from 0 to 100
fun(x)
TODO: add function description here
Parameters:
x (float) : TODO: add parameter x description here
Returns: TODO: add what function returns
init()
Initialize an Index
Returns: A new instance of Index object with no signals
method add(idx, signal)
Adds the specified signal to the index
Namespace types: Index
Parameters:
idx (Index) : The Index object
signal (Signal) : Signal object
method calc(idx)
Caclulates the Index value
Namespace types: Index
Parameters:
idx (Index) : The Index object
Returns: Normalized weighted sum of all signals with on=true
method update(idx)
Calculates the Index value by calling idx.calc() and stores its value in the Index object.
Namespace types: Index
Parameters:
idx (Index) : The Index object
Signal
Parameters of input signal
Fields:
on (series bool) : Switch the signal on/off
weight (series float)
value (series float) : Value of the signal: should be between min and max
min (series float)
max (series float)
Index
The Index type with its properties and stored values
Fields:
signals (Signal )
value (series float) : Value of the index, must be calculated using calc() method
GuageLibrary "Gauge"
The gauge library utilizes a gaugeParams object, encapsulating crucial parameters for gauge creation. Essential attributes include num (the measured value) , min (the minimum value equating to 100% on the gauge's minimum scale) , and max (the maximum value equating to 100% on the gauge's maximum scale) . The size attribute (defaulting to 10) splits the scale into increments, each representing 100% divided by the specified size.
The num value dynamically shifts within the gauge based on its percentage move from the mathematical average between min and max . When num is below the average, the minimum portion of the scale activates, displaying the appropriate percentage based on the distance from the average to the minimum. The same principle applies when num exceeds the average. The 100% scale is reached at either end when num equals min or max .
The library offers full customization, allowing users to configure color schemes, labels, and titles. The gauge can be displayed either vertically (default) or horizontally. The colors employ a gradient, adapting based on the number's movement. Overall, the gauge library provides a flexible and comprehensive tool for visualizing and interpreting numerical values within a specified range.
MarketHolidaysLibrary "MarketHolidays"
The MarketHolidays library compiles market holidays (including historical special market closures) into arrays, which can then be utilized in TradingView indicators and strategies to account for non-trading days. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
getHolidays(_country)
The getHolidays function aggregates holiday data from different time periods to create a single array with market holidays for a specified country.
Parameters:
_country (string) : The country code for which to retrieve market holidays. Accepts syminfo.country or pre-set country code in ISO 3166-1 alpha-2 format.
Returns: An array of timestamps of market holidays \ non-trading days for the given country.
holidays_2020to2025Library "holidays_2020to2025"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_2015to2020Library "holidays_2015to2020"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_2010to2015Library "holidays_2010to2015"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_2005to2010Library "holidays_2005to2010"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_2000to2005Library "holidays_2000to2005"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_1990to2000Library "holidays_1990to2000"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_1980to1990Library "holidays_1980to1990"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_1970to1980Library "holidays_1970to1980"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
holidays_1962to1970Library "holidays_1962to1970"
This dataset is part of my "MarketHolidays" library. The datasets were split into different libraries to overcome compiling limitations, streamline the process of removing specific time frames if not needed, and to enhance code execution speed. The timestamps are generated using a custom Python script that employs the 'pandas_market_calendars' library. To build your own set of arrays, you can find the script and instructions at github.com
holidays(_country)
Parameters:
_country (string)
NetLiquidityLibraryMacFLibrary "NetLiquidityLibraryMacF"
The Net Liquidity Library provides daily values for net liquidity. Net liquidity is measured as Fed Balance Sheet - Treasury General Account - Reverse Repo. Time series for each individual component included too.
get_net_liquidity(component)
Gets the Net Liquidity time series for the last 250 trading days. Dates that are not present are represented as na.
Parameters:
component (simple string) : The component of the Net Liquidity function to return. Possible values: 'fed', 'tga', and 'rrp'. (`Net Liquidity` is returned if no argument is supplied).
Returns: The Net Liquidity time series or a component of the Net Liquidity function.
TableUtilsLibrary "TableUtils"
Collection of table utility functions
getTablePositionByLabel(tablePosition)
Return the position for the table by given label. Useful if you want to control the position of the table with a pine script input selector that use a more human friendly labels
Parameters:
tablePosition (string) : (string) Label of the table position. Possible values are: "Top left", "Top right", "Bottom left", "Bottom right", "Middle left", "Middle right"
Returns: the position for the table by given label. Useful if you want to control the position of the table with a pine script input selector that use a more human friendly labels
chrono_utilsLibrary "chrono_utils"
📝 Description
Collection of objects and common functions that are related to datetime windows session days and time ranges. The main purpose of this library is to handle time-related functionality and make it easy to reason about a future bar checking if it will be part of a predefined session and/or inside a datetime window. All existing session functionality I found in the documentation e.g. "not na(time(timeframe, session, timezone))" are not suitable for strategy scripts, since the execution of the orders is delayed by one bar, due to the script execution happening at the bar close. Moreover, a history operator with a negative value that looks forward is not allowed in any pinescript expression. So, a prediction for the next bar using the bars_back argument of "time()"" and "time_close()" was necessary. Thus, I created this library to overcome this small but very important limitation. In the meantime, I added useful functionality to handle session-based behavior. An interesting utility that emerged from this development is data anomaly detection where a comparison between the prediction and the actual value is happening. If those two values are different then a data inconsistency happens between the prediction bar and the actual bar (probably due to a holiday, half session day, a timezone change etc..)
🤔 How to Guide
To use the functionality this library provides in your script you have to import it first!
Copy the import statement of the latest release by pressing the copy button below and then paste it into your script. Give a short name to this library so you can refer to it later on. The import statement should look like this:
import jason5480/chrono_utils/2 as chr
To check if a future bar will be inside a window first of all you have to initialize a DateTimeWindow object.
A code example is the following:
var dateTimeWindow = chr.DateTimeWindow.new().init(fromDateTime = timestamp('01 Jan 2023 00:00'), toDateTime = timestamp('01 Jan 2024 00:00'))
Then you have to "ask" the dateTimeWindow if the future bar defined by an offset (default is 1 that corresponds th the next bar), will be inside that window:
// Filter bars outside of the datetime window
bool dateFilterApproval = dateTimeWindow.is_bar_included()
You can visualize the result by drawing the background of the bars that are outside the given window:
bgcolor(color = dateFilterApproval ? na : color.new(color.fuchsia, 90), offset = 1, title = 'Datetime Window Filter')
In the same way, you can "ask" the Session if the future bar defined by an offset it will be inside that session.
First of all, you should initialize a Session object.
A code example is the following:
var sess = chr.Session.new().from_sess_string(sess = '0800-1700:23456', refTimezone = 'UTC')
Then check if the given bar defined by the offset (default is 1 that corresponds th the next bar), will be inside the session like that:
// Filter bars outside the sessions
bool sessionFilterApproval = view.sess.is_bar_included()
You can visualize the result by drawing the background of the bars that are outside the given session:
bgcolor(color = sessionFilterApproval ? na : color.new(color.red, 90), offset = 1, title = 'Session Filter')
In case you want to visualize multiple session ranges you can create a SessionView object like that:
var view = SessionView.new().init(SessionDays.new().from_sess_string('2345'), array.from(SessionTimeRange.new().from_sess_string('0800-1600'), SessionTimeRange.new().from_sess_string('1300-2200')), array.from('London', 'New York'), array.from(color.blue, color.orange))
and then call the draw method of the SessionView object like that:
view.draw()
🏋️♂️ Please refer to the "EXAMPLE DATETIME WINDOW FILTER" and "EXAMPLE SESSION FILTER" regions of the script for more advanced code examples of how to utilize the full potential of this library, including user input settings and advanced visualization!
⚠️ Caveats
As I mentioned in the description there are some cases that the prediction of the next bar is not accurate. A wrong prediction will affect the outcome of the filtering. The main reasons this could happen are the following:
Public holidays when the market is closed
Half trading days usually before public holidays
Change in the daylight saving time (DST)
A data anomaly of the chart, where there are missing and/or inconsistent data.
A bug in this library (Please report by PM sending the symbol, timeframe, and settings)
Special thanks to @robbatt and @skinra for the constructive feedback 🏆. Without them, the exposed API of this library would be very lengthy and complicated to use. Thanks to them, now the user of this library will be able to get the most, with only a few lines of code!
TouchedLibrary "Touched"
Breakout(zone, lookback)
Tells if the zone has been broken on the current bar.
Parameters:
zone (Zone) : The definitiin of the zone.
lookback (int) : How many bars to look back.
Returns: a Touch object that tells if the zone has been broken up or down.
FalseBreakout(zone, lookback)
Tells if the zone has a false breakout on the current bar.
Parameters:
zone (Zone) : The definitiin of the zone.
lookback (int) : How many bars to look back.
Returns: a Touch object that tells if the zone has had a false breakout up or down.
Retest(zone, lookback)
Tells if the zone has been retested on the current bar.
Parameters:
zone (Zone) : The definitiin of the zone.
lookback (int) : How many bars to look back.
Returns: a Touch object that tells if the zone has been retested up or down.
Zone
Fields:
High (series__float)
Low (series__float)
BaseTime (series__integer)
Touch
Fields:
Up (series__bool)
Down (series__bool)
ETFFinderLibLibrary "ETFFinderLib"
TODO: add library description here
etf_search_ticker(ticker)
searches the entire ETF library by ticker and identifies which ETFs hold a specific tickers.
Parameters:
ticker (string)
Returns: returns 2 arrays, holding_array (string array) and compo_array(float array)
etf_search_sectors(sector)
searches the entire ETF library by sector and pulls by desired sector
Parameters:
sector (string)
Returns: returns 2 arrays, sector_array (string array) and composition array (float array)
A_Traders_Edge__LibraryLibrary "A_Traders_Edge__Library"
- A Trader's Edge (ATE)_Library was created to assist in constructing Market Overview Scanners (MOS)
LabelLocation(_firstLocation)
This function is used when there's a desire to print an assets ALERT LABELS at a set location on the scale that will
NOT change throughout the progression of the script. This is created so that if a lot of alerts are triggered, they
will stay relatively visible and not overlap each other. Ex. If you set your '_firstLocation' parameter as 1, since
there are a max of 40 assets that can be scanned, the 1st asset's location is assigned the value in the '_firstLocation' parameter,
the 2nd asset's location is the (1st asset's location+1)...and so on. If your first location is set to 81 then
the 1st asset is 81 and 2nd is 82 and so on until the 40th location = 120(in this particular example).
Parameters:
_firstLocation (simple int) : (simple int)
Optional(starts at 1 if no parameter added).
Location that you want the first asset to print its label if is triggered to do so.
ie. loc2=loc1+1, loc3=loc2+1, etc.
Returns: Returns 40 output variables each being a different location to print the labels so that an asset is asssigned to
a particular location on the scale. Regardless of if you have the maximum amount of assets being screened (40 max), this
function will output 40 locations… So there needs to be 40 variables assigned in the tuple in this function. What I
mean by that is you need to have 40 output location variables within your tuple (ie. between the ' ') regarless of
if your scanning 40 assets or not. If you only have 20 assets in your scripts input settings, then only the first 20
variables within the ' ' Will be assigned to a value location and the other 20 will be assigned 'NA', but their
variables still need to be present in the tuple.
SeparateTickerids(_string)
You must form this single tickerID input string exactly as described in the scripts info panel (little gray 'i' that
is circled at the end of the settings in the settings/input panel that you can hover your cursor over this 'i' to read the
details of that particular input). IF the string is formed correctly then it will break up this single string parameter into
a total of 40 separate strings which will be all of the tickerIDs that the script is using in your MO scanner.
Parameters:
_string (simple string) : (string)
A maximum of 40 Tickers (ALL joined as 1 string for the input parameter) that is formulated EXACTLY as described
within the tooltips of the TickerID inputs in my MOS Scanner scripts:
assets = input.text_area(tIDset1, title="TickerID (MUST READ TOOLTIP)", tooltip="Accepts 40 TICKERID's for each
copy of the script on the chart. TEXT FORMATTING RULES FOR TICKERID'S:
(1) To exclude the EXCHANGE NAME in the Labels, de-select the next input option.
(2) MUST have a space (' ') AFTER each TickerID.
(3) Capitalization in the Labels will match cap of these TickerID's.
(4) If your asset has a BaseCurrency & QuoteCurrency (ie. ADAUSDT ) BUT you ONLY want Labels
to show BaseCurrency(ie.'ADA'), include a FORWARD SLASH ('/') between the Base & Quote (ie.'ADA/USDT')", display=display.none)
Returns: Returns 40 output variables of the different strings of TickerID's (ie. you need to output 40 variables within the
tuple ' ' regardless of if you were scanning using all possible (40) assets or not.
If your scanning for less than 40 assets, then once the variables are assigned to all of the tickerIDs, the rest
of the 40 variables in the tuple will be assigned "NA".
TickeridForLabelsAndSecurity(_includeExchange, _ticker)
This function accepts the TickerID Name as its parameter and produces a single string that will be used in all of your labels.
Parameters:
_includeExchange (simple bool) : (bool)
Optional(if parameter not included in function it defaults to false ).
Used to determine if the Exchange name will be included in all labels/triggers/alerts.
_ticker (simple string) : (string)
For this parameter, input the varible named '_coin' from your 'f_main()' function for this parameter. It is the raw
Ticker ID name that will be processed.
Returns: ( )
Returns 2 output variables:
1st ('_securityTickerid') is to be used in the 'request.security()' function as this string will contain everything
TV needs to pull the correct assets data.
2nd ('lblTicker') is to be used in all of the labels in your MOS as it will only contain what you want your labels
to show as determined by how the tickerID is formulated in the MOS's input.
InvalidTID(_tablePosition, _stackVertical, _close, _securityTickerid, _invalidArray)
This is to add a table in the middle right of your chart that prints all the TickerID's that were either not formulated
correctly in the '_source' input or that is not a valid symbol and should be changed.
Parameters:
_tablePosition (simple string) : (string)
Optional(if parameter not included, it defaults to position.middle_right). Location on the chart you want the table printed.
Possible strings include: position.top_center, position.top_left, position.top_right, position.middle_center,
position.middle_left, position.middle_right, position.bottom_center, position.bottom_left, position.bottom_right.
_stackVertical (simple bool) : (bool)
Optional(if parameter not included, it defaults to true). All of the assets that are counted as INVALID will be
created in a list. If you want this list to be prited as a column then input 'true' here.
_close (float) : (float)
If you want them printed as a single row then input 'false' here.
This should be the closing value of each of the assets being tested to determine in the TickerID is valid or not.
_securityTickerid (string) : (string)
Throughout the entire charts updates, if a '_close' value is never regestered then the logic counts the asset as INVALID.
This will be the 1st TickerID varible (named _securityTickerid) outputted from the tuple of the TickeridForLabels()
function above this one.
_invalidArray (string ) : (array string)
Input the array from the original script that houses all of the invalidArray strings.
Returns: (na)
Returns a table with the screened assets Invalid TickerID's. Table draws automatically if any are Invalid, thus,
no output variable to deal with.
LabelSizes(_barCnt, _lblSzRfrnce)
This function sizes your Alert Trigger Labels according to the amount of Printed Bars the chart has printed within
a set time period, while also keeping in mind the smallest relative reference size you input in the 'lblSzRfrnceInput'
parameter of this function. A HIGHER % of Printed Bars(aka...more trades occurring for that asset on the exchange),
the LARGER the Name Label will print, potentially showing you the better opportunities on the exchange to avoid
exchange manipulation liquidations.
*** SHOULD NOT be used as size of labels that are your asset Name Labels next to each asset's Line Plot...
if your MOS includes these as you want these to be the same size for every asset so the larger ones dont cover the
smaller ones if the plots are all close to each other ***
Parameters:
_barCnt (float) : (float)
Get the 1st variable('barCnt') from the 'PrintedBarCount' function's tuple and input it as this functions 1st input
parameter which will directly affect the size of the 2nd output variable ('alertTrigLabel') outputted by this function.
_lblSzRfrnce (string) : (string)
Optional(if parameter not included, it defaults to size.small). This will be the size of the 1st variable outputted
by this function ('assetNameLabel') BUT also affects the 2nd variable outputted by this function.
Returns: ( )
Returns 2 variables:
1st output variable ('AssetNameLabel') is assigned to the size of the 'lblSzRfrnceInput' parameter.
2nd output variable('alertTrigLabel') can be of variying sizes depending on the 'barCnt' parameter...BUT the smallest
size possible for the 2nd output variable ('alertTrigLabel') will be the size set in the 'lblSzRfrnceInput' parameter.
AssetColor()
This function is used to assign 40 different colors to 40 variables to be used for the different labels/plots.
Returns: Returns 40 output variables each with a different color assigned to them to be used in your plots & labels.
Regardless of if you have the maximum amount of assets your scanning(40 max) or less,
this function will assign 40 colors to 40 variables that you have between the ' '.
PrintedBarCount(_time, _barCntLength, _barCntPercentMin)
The Printed BarCount Filter looks back a User Defined amount of minutes and calculates the % of bars that have printed
out of the TOTAL amount of bars that COULD HAVE been printed within the same amount of time.
Parameters:
_time (int) : (int)
The time associated with the chart of the particular asset that is being screened at that point.
_barCntLength (int) : (int)
The amount of time (IN MINUTES) that you want the logic to look back at to calculate the % of bars that have actually
printed in the span of time you input into this parameter.
_barCntPercentMin (int) : (int)
The minimum % of Printed Bars of the asset being screened has to be GREATER than the value set in this parameter
for the output variable 'bc_gtg' to be true.
Returns: ( )
Returns 2 outputs:
1st is the % of Printed Bars that have printed within the within the span of time you input in the '_barCntLength' parameter.
2nd is true/false according to if the Printed BarCount % is above the threshold that you input into the '_barCntPercentMin' parameter.
RCI(_rciLength, _source, _interval)
You will see me using this a lot. DEFINITELY my favorite oscillator to utilize for SO many different things from
timing entries/exits to determining trends.Calculation of this indicator based on Spearmans Correlation.
Parameters:
_rciLength (int) : (int)
Amount of bars back to use in RCI calculations.
_source (float) : (float)
Source to use in RCI calculations (can use ANY source series. Ie, open,close,high,low,etc).
_interval (int) : (int)
Optional(if parameter not included, it defaults to 3). RCI calculation groups bars by this amount and then will.
rank these groups of bars.
Returns: (float)
Returns a single RCI value that will oscillates between -100 and +100.
RCIAVG(firstLength, _amtBtLengths, _rciSMAlen, _source, _interval)
20 RCI's are averaged together to get this RCI Avg (Rank Correlation Index Average). Each RCI (of the 20 total RCI)
has a progressively LARGER Lookback Length. Though the RCI Lengths are not individually adjustable,
there are 2 factors that ARE:
(1) the Lookback Length of the 1st RCI and
(2) the amount of values between one RCI's Lookback Length and the next.
*** If you set 'firstLength' to it's default of 200 and '_amtBtLengths' to it's default of 120 (aka AMOUNT BETWEEN LENGTHS=120)...
then RCI_2 Length=320, RCI_3 Length=440, RCI_4 Length=560, and so on.
Parameters:
firstLength (int) : (int)
Optional(if parameter is not included when the function is called, then it defaults to 200).
This parameter is the Lookback Length for the 1st RCI used in the RCI Avg.
_amtBtLengths (int) : (int)
Optional(if parameter not included when the function is called, then it defaults to 120).
This parameter is the value amount between each of the progressively larger lengths used for the 20 RCI's that
are averaged in the RCI Avg.
***** BEWARE ***** Too large of a value here will cause the calc to look back too far, causing an error(thus the value must be lowered)
_rciSMAlen (int) : (int)
Unlike the Single RCI Function, this function smooths out the end result using an SMA with a length value that is this parameter.
_source (float) : (float)
Source to use in RCI calculations (can use ANY source series. Ie, open,close,high,low,etc).
_interval (int) : (int)
Optional(if parameter not included, it defaults to 3). Within the RCI calculation, bars next to each other are grouped together
and then these groups are Ranked against each other. This parameter is the number of adjacent bars that are grouped together.
Returns: (float)
Returns a single RCI value that is the Avg of many RCI values that will oscillate between -100 and +100.
PercentChange(_startingValue, _endingValue)
This is a quick function to calculate how much % change has occurred between the '_startingValue' and the '_endingValue'
that you input into the function.
Parameters:
_startingValue (float) : (float)
The source value to START the % change calculation from.
_endingValue (float) : (float)
The source value to END the % change caluclation from.
Returns: Returns a single output being the % value between 0-100 (with trailing numbers behind a decimal). If you want only
a certain amount of numbers behind the decimal, this function needs to be put within a formatting function to do so.
Rescale(_source, _oldMin, _oldMax, _newMin, _newMax)
Rescales series with a known '_oldMin' & '_oldMax'. Use this when the scale of the '_source' to
rescale is known (bounded).
Parameters:
_source (float) : (float)
Source to be normalized.
_oldMin (int) : (float)
The known minimum of the '_source'.
_oldMax (int) : (float)
The known maximum of the '_source'.
_newMin (int) : (float)
What you want the NEW minimum of the '_source' to be.
_newMax (int) : (float)
What you want the NEW maximum of the '_source' to be.
Returns: Outputs your previously bounded '_source', but now the value will only move between the '_newMin' and '_newMax'
values you set in the variables.
Normalize_Historical(_source, _minimumLvl, _maximumLvl)
Normalizes '_source' that has a previously unknown min/max(unbounded) determining the max & min of the '_source'
FROM THE ENTIRE CHARTS HISTORY. ]
Parameters:
_source (float) : (float)
Source to be normalized.
_minimumLvl (int) : (float)
The Lower Boundary Level.
_maximumLvl (int) : (float)
The Upper Boundary Level.
Returns: Returns your same '_source', but now the value will MOSTLY stay between the minimum and maximum values you set in the
'_minimumLvl' and '_maximumLvl' variables (ie. if the source you input is an RSI...the output is the same RSI value but
instead of moving between 0-100 it will move between the maxand min you set).
Normailize_Local(_source, _length, _minimumLvl, _maximumLvl)
Normalizes series with previously unknown min/max(unbounded). Much like the Normalize_Historical function above this one,
but rather than using the Highest/Lowest Values within the ENTIRE charts history, this on looks for the Highest/Lowest
values of '_source' within the last ___ bars (set by user as/in the '_length' parameter. ]
Parameters:
_source (float) : (float)
Source to be normalized.
_length (int) : (float)
The amount of bars to look back to determine the highest/lowest '_source' value.
_minimumLvl (int) : (float)
The Lower Boundary Level.
_maximumLvl (int) : (float)
The Upper Boundary Level.
Returns: Returns a single output variable being the previously unbounded '_source' that is now normalized and bound between
the values used for '_minimumLvl'/'_maximumLvl' of the '_source' within the user defined lookback period.
ETFHoldingsLibLibrary "ETFHoldingsLib"
spy_get()
: pulls SPY ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
qqq_get()
: pulls QQQ ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
arkk_get()
: pulls ARKK ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xle_get()
: pulls XLE ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
brk_get()
: pulls BRK ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
ita_get()
: pulls ITA ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
iwm_get()
: pulls IWM ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xlf_get()
: pulls XLF ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xlv_get()
: pulls XLV ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vnq_get()
: pulls VNQ ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
xbi_get()
: pulls XBI ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
blcr_get()
: pulls BLCR ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vgt_get()
: pulls VGT ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vwo_get()
: pulls VWO ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vig_get()
: pulls VIG ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vug_get()
: pulls VUG ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vtv_get()
: pulls VTV ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
vea_get()
: pulls VEA ETF data
Returns: : tickers held (string array), percent ticker holding (float array), sectors (string array), percent secture positioning (float array)
lib_mathLibrary "lib_math"
a collection of functions calculating without history operator to avoid max_bars_back errors
mean(value, reset)
Parameters:
value (float) : series to track
reset (bool) : flag to reset tracking
@return returns average/mean of value since last reset
vwap(value, reset)
Parameters:
value (float) : series to track
reset (bool) : flag to reset tracking
@return returns vwap of value and volume since last reset
variance(value, reset)
Parameters:
value (float) : series to track
reset (bool) : flag to reset tracking
@return returns variance of value since last reset
trend(value, reset)
Parameters:
value (float) : series to track
reset (bool) : flag to reset tracking
@return where slope is the trend direction, correlation is a measurement for how well the values fit to the trendline (positive means ), stddev is how far the values deviate from the trend, x1 would be the time where reset is true and x2 would be the current time
DBTVLibrary "DBTV"
entry_message(password, percent, leverage, margin_mode, kis_number)
Create a entry message for POABOT
Parameters:
password (string) : (string) The password of your bot.
percent (float) : (float) The percent for entry based on your wallet balance.
leverage (int) : (int) The leverage of entry. If not set, your levereage doesn't change.
margin_mode (string) : (string) The margin mode for trade(only for OKX). "cross" or "isolated"
kis_number (int) : (int) The number of koreainvestment account. Default 1
Returns: (string) A json formatted string for webhook message.