PRINT_DROVINGLibrary "PRINT_DROVING"
method print_droving(foot_bar, sup)
printing all footprint objects
Namespace types: footprint_type.Footprint_bar
Parameters:
foot_bar (Footprint_bar type from Alesetup/PRINT_TYPE/1) : instance of Footprint_bar type
sup (Support_objects type from Alesetup/PRINT_TYPE/1) : instance of Support_objects type
Returns: Void.
Statistics
PRINT_LOGICLibrary "PRINT_LOGIC"
method fill_imba_line(imba_line, foot_bar, sup)
fill imbalance line
Namespace types: footprint_type.Imbalance_line
Parameters:
imba_line (Imbalance_line type from Alesetup/PRINT_TYPE/1) : instance of Imbalance_line type
foot_bar (Footprint_bar type from Alesetup/PRINT_TYPE/1) : instance of Footprint_bar type
sup (Support_objects type from Alesetup/PRINT_TYPE/1) : instance of Support_objects type
Returns: Void
method fill_footprint_type(foot_bar, sup)
Namespace types: footprint_type.Footprint_bar
Parameters:
foot_bar (Footprint_bar type from Alesetup/PRINT_TYPE/1) : instance of Footprint_bar type
sup (Support_objects type from Alesetup/PRINT_TYPE/1) : instance of Support_objects type
Returns: Void
method fill_footprint_object(foot_bar, sup)
fill all footprint objects
Namespace types: footprint_type.Footprint_bar
Parameters:
foot_bar (Footprint_bar type from Alesetup/PRINT_TYPE/1) : instance of Footprint_bar type
sup (Support_objects type from Alesetup/PRINT_TYPE/1) : instance of Support_objects type
Returns: Void
PRINT_TYPELibrary "PRINT_TYPE"
Inputs
Inputs objects
Fields:
inbalance_percent (series int) : percentage coefficient to determine the Imbalance of price levels
stacked_input (series int) : minimum number of consecutive Imbalance levels required to draw extended lines
show_summary_footprint (series bool)
procent_volume_area (series int) : definition size Value area
new_imbalance_cond (series bool) : bool input for setup alert on new imbalance buy and sell
new_imbalance_line_cond (series bool) : bool input for setup alert on new imbalance line buy and sell
stop_past_imbalance_line_cond (series bool) : bool input for setup alert on stop past imbalance line buy and sell
Constants
Constants all Constants objects
Fields:
imbalance_high_char (series string) : char for printing buy imbalance
imbalance_low_char (series string) : char for printing sell imbalance
color_title_sell (series color) : color for footprint sell
color_title_buy (series color) : color for footprint buy
color_line_sell (series color) : color for sell line
color_line_buy (series color) : color for buy line
color_title_none (series color) : color None
Calculation_data
Calculation_data data for calculating
Fields:
detail_open (array) : array open from calculation timeframe
detail_high (array) : array high from calculation timeframe
detail_low (array) : array low from calculation timeframe
detail_close (array) : array close from calculation timeframe
detail_vol (array) : array volume from calculation timeframe
previos_detail_close (array) : array close from calculation timeframe
isBuyVolume (series bool) : attribute previosly bar buy or sell
Footprint_row
Footprint_row objects one footprint row
Fields:
price (series float) : row price
buy_vol (series float) : buy volume
sell_vol (series float) : sell volume
imbalance_buy (series bool) : attribute buy inbalance
imbalance_sell (series bool) : attribute sell imbalance
buy_vol_box (series box) : for ptinting buy volume
sell_vol_box (series box) : for printing sell volume
buy_vp_box (series box) : for ptinting volume profile buy
sell_vp_box (series box) : for ptinting volume profile sell
row_line (series label) : for ptinting row price
empty (series bool) : = true attribute row with zero volume buy and zero volume sell
Imbalance_line_var_object
Imbalance_line_var_object var objects printing and calculation imbalance line
Fields:
cum_buy_line (array) : line array for saving all history buy imbalance line
cum_sell_line (array) : line array for saving all history sell imbalance line
Imbalance_line
Imbalance_line objects printing and calculation imbalance line
Fields:
buy_price_line (array) : float array for saving buy imbalance price level
sell_price_line (array) : float array for saving sell imbalance price level
var_imba_line (Imbalance_line_var_object) : var objects this type
Footprint_bar
Footprint_bar all objects one bar with footprint
Fields:
foot_rows (array) : objects one row footprint
imba_line (Imbalance_line) : objects imbalance line
row_size (series float) : size rows
total_vol (series float) : total volume one footprint bar
foot_buy_vol (series float) : buy volume one footprint bar
foot_sell_vol (series float) : sell volume one footprint bar
foot_max_price_vol (map) : map with one value - price row with max volume buy + sell
calc_data (Calculation_data) : objects with detail data from calculation resolution
Support_objects
Support_objects support object for footprint calculation
Fields:
consts (Constants) : all consts objects
inp (Inputs) : all input objects
bar_index_show_condition (series bool) : calculation bool value for show all objects footprint
row_line_color (series color) : calculation value - color for row price
dop_info (series string)
show_table_cond (series bool)
analytics_tablesLibrary "analytics_tables"
📝 Description
This library provides the implementation of several performance-related statistics and metrics, presented in the form of tables.
The metrics shown in the afforementioned tables where developed during the past years of my in-depth analalysis of various strategies in an atempt to reason about the performance of each strategy.
The visualization and some statistics where inspired by the existing implementations of the "Seasonality" script, and the performance matrix implementations of @QuantNomad and @ZenAndTheArtOfTrading scripts.
While this library is meant to be used by my strategy framework "Template Trailing Strategy (Backtester)" script, I wrapped it in a library hoping this can be usefull for other community strategy scripts that will be released in the future.
🤔 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/analytics_tables/1 as ant
There are three types of tables provided by this library in the initial release. The stats table the metrics table and the seasonality table.
Each one shows different kinds of performance statistics.
The table UDT shall be initialized once using the `init()` method.
They can be updated using the `update()` method where the updated data UDT object shall be passed.
The data UDT can also initialized and get updated on demend depending on the use case
A code example for the StatsTable is the following:
var ant.StatsData statsData = ant.StatsData.new()
statsData.update(SideStats.new(), SideStats.new(), 0)
if (barstate.islastconfirmedhistory or (barstate.isrealtime and barstate.isconfirmed))
var statsTable = ant.StatsTable.new().init(ant.getTablePos('TOP', 'RIGHT'))
statsTable.update(statsData)
A code example for the MetricsTable is the following:
var ant.StatsData statsData = ant.StatsData.new()
statsData.update(ant.SideStats.new(), ant.SideStats.new(), 0)
if (barstate.islastconfirmedhistory or (barstate.isrealtime and barstate.isconfirmed))
var metricsTable = ant.MetricsTable.new().init(ant.getTablePos('BOTTOM', 'RIGHT'))
metricsTable.update(statsData, 10)
A code example for the SeasonalityTable is the following:
var ant.SeasonalData seasonalData = ant.SeasonalData.new().init(Seasonality.monthOfYear)
seasonalData.update()
if (barstate.islastconfirmedhistory or (barstate.isrealtime and barstate.isconfirmed))
var seasonalTable = ant.SeasonalTable.new().init(seasonalData, ant.getTablePos('BOTTOM', 'LEFT'))
seasonalTable.update(seasonalData)
🏋️♂️ Please refer to the "EXAMPLE" regions of the script for more advanced and up to date code examples!
Special thanks to @Mrcrbw for the proposal to develop this library and @DCNeu for the constructive feedback 🏆.
getTablePos(ypos, xpos)
Get table position compatible string
Parameters:
ypos (simple string) : The position on y axise
xpos (simple string) : The position on x axise
Returns: The position to be passed to the table
method init(this, pos, height, width, positiveTxtColor, negativeTxtColor, neutralTxtColor, positiveBgColor, negativeBgColor, neutralBgColor)
Initialize the stats table object with the given colors in the given position
Namespace types: StatsTable
Parameters:
this (StatsTable) : The stats table object
pos (simple string) : The table position string
height (simple float) : The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells
width (simple float) : The width of the table as a percentage of the charts height. By default, 0 auto-adjusts the width based on the text inside the cells
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
neutralTxtColor (simple color) : The text color when neutral
positiveBgColor (simple color) : The background color with transparency when positive
negativeBgColor (simple color) : The background color with transparency when negative
neutralBgColor (simple color) : The background color with transparency when neutral
method init(this, pos, height, width, neutralBgColor)
Initialize the metrics table object with the given colors in the given position
Namespace types: MetricsTable
Parameters:
this (MetricsTable) : The metrics table object
pos (simple string) : The table position string
height (simple float) : The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells
width (simple float) : The width of the table as a percentage of the charts width. By default, 0 auto-adjusts the width based on the text inside the cells
neutralBgColor (simple color) : The background color with transparency when neutral
method init(this, seas)
Initialize the seasonal data
Namespace types: SeasonalData
Parameters:
this (SeasonalData) : The seasonal data object
seas (simple Seasonality) : The seasonality of the matrix data
method init(this, data, pos, maxNumOfYears, height, width, extended, neutralTxtColor, neutralBgColor)
Initialize the seasonal table object with the given colors in the given position
Namespace types: SeasonalTable
Parameters:
this (SeasonalTable) : The seasonal table object
data (SeasonalData) : The seasonality data of the table
pos (simple string) : The table position string
maxNumOfYears (simple int) : The maximum number of years that fit into the table
height (simple float) : The height of the table as a percentage of the charts height. By default, 0 auto-adjusts the height based on the text inside the cells
width (simple float) : The width of the table as a percentage of the charts width. By default, 0 auto-adjusts the width based on the text inside the cells
extended (simple bool) : The seasonal table with extended columns for performance
neutralTxtColor (simple color) : The text color when neutral
neutralBgColor (simple color) : The background color with transparency when neutral
method update(this, wins, losses, numOfInconclusiveExits)
Update the strategy info data of the strategy
Namespace types: StatsData
Parameters:
this (StatsData) : The strategy statistics object
wins (SideStats)
losses (SideStats)
numOfInconclusiveExits (int) : The number of inconclusive trades
method update(this, stats, positiveTxtColor, negativeTxtColor, negativeBgColor, neutralBgColor)
Update the stats table object with the given data
Namespace types: StatsTable
Parameters:
this (StatsTable) : The stats table object
stats (StatsData) : The stats data to update the table
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
negativeBgColor (simple color) : The background color with transparency when negative
neutralBgColor (simple color) : The background color with transparency when neutral
method update(this, stats, buyAndHoldPerc, positiveTxtColor, negativeTxtColor, positiveBgColor, negativeBgColor)
Update the metrics table object with the given data
Namespace types: MetricsTable
Parameters:
this (MetricsTable) : The metrics table object
stats (StatsData) : The stats data to update the table
buyAndHoldPerc (float) : The buy and hold percetage
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
positiveBgColor (simple color) : The background color with transparency when positive
negativeBgColor (simple color) : The background color with transparency when negative
method update(this)
Update the seasonal data based on the season and eon timeframe
Namespace types: SeasonalData
Parameters:
this (SeasonalData) : The seasonal data object
method update(this, data, positiveTxtColor, negativeTxtColor, neutralTxtColor, positiveBgColor, negativeBgColor, neutralBgColor, timeBgColor)
Update the seasonal table object with the given data
Namespace types: SeasonalTable
Parameters:
this (SeasonalTable) : The seasonal table object
data (SeasonalData) : The seasonal cell data to update the table
positiveTxtColor (simple color) : The text color when positive
negativeTxtColor (simple color) : The text color when negative
neutralTxtColor (simple color) : The text color when neutral
positiveBgColor (simple color) : The background color with transparency when positive
negativeBgColor (simple color) : The background color with transparency when negative
neutralBgColor (simple color) : The background color with transparency when neutral
timeBgColor (simple color) : The background color of the time gradient
SideStats
Object that represents the strategy statistics data of one side win or lose
Fields:
numOf (series int)
sumFreeProfit (series float)
freeProfitStDev (series float)
sumProfit (series float)
profitStDev (series float)
sumGain (series float)
gainStDev (series float)
avgQuantityPerc (series float)
avgCapitalRiskPerc (series float)
avgTPExecutedCount (series float)
avgRiskRewardRatio (series float)
maxStreak (series int)
StatsTable
Object that represents the stats table
Fields:
table (series table) : The actual table
rows (series int) : The number of rows of the table
columns (series int) : The number of columns of the table
StatsData
Object that represents the statistics data of the strategy
Fields:
wins (SideStats)
losses (SideStats)
numOfInconclusiveExits (series int)
avgFreeProfitStr (series string)
freeProfitStDevStr (series string)
lossFreeProfitStDevStr (series string)
avgProfitStr (series string)
profitStDevStr (series string)
lossProfitStDevStr (series string)
avgQuantityStr (series string)
MetricsTable
Object that represents the metrics table
Fields:
table (series table) : The actual table
rows (series int) : The number of rows of the table
columns (series int) : The number of columns of the table
SeasonalData
Object that represents the seasonal table dynamic data
Fields:
seasonality (series Seasonality)
eonToMatrixRow (map)
numOfEons (series int)
mostRecentMatrixRow (series int)
balances (matrix)
returnPercs (matrix)
maxDDs (matrix)
eonReturnPercs (array)
eonCAGRs (array)
eonMaxDDs (array)
SeasonalTable
Object that represents the seasonal table
Fields:
table (series table) : The actual table
headRows (series int) : The number of head rows of the table
headColumns (series int) : The number of head columns of the table
eonRows (series int) : The number of eon rows of the table
seasonColumns (series int) : The number of season columns of the table
statsRows (series int)
statsColumns (series int) : The number of stats columns of the table
rows (series int) : The number of rows of the table
columns (series int) : The number of columns of the table
extended (series bool) : Whether the table has additional performance statistics
[ALGOA+] Markov Chains Library by @metacamaleoLibrary "MarkovChains"
Markov Chains library by @metacamaleo. Created in 09/08/2024.
This library provides tools to calculate and visualize Markov Chain-based transition matrices and probabilities. This library supports two primary algorithms: a rolling window Markov Chain and a conditional Markov Chain (which operates based on specified conditions). The key concepts used include Markov Chain states, transition matrices, and future state probabilities based on past market conditions or indicators.
Key functions:
- `mc_rw()`: Builds a transition matrix using a rolling window Markov Chain, calculating probabilities based on a fixed length of historical data.
- `mc_cond()`: Builds a conditional Markov Chain transition matrix, calculating probabilities based on the current market condition or indicator state.
Basically, you will just need to use the above functions on your script to default outputs and displays.
Exported UDTs include:
- s_map: An UDT variable used to store a map with dummy states, i.e., if possible states are bullish, bearish, and neutral, and current is bullish, it will be stored
in a map with following keys and values: "bullish", 1; "bearish", 0; and "neutral", 0. You will only use it to customize your own script, otherwise, it´s only for internal use.
- mc_states: This UDT variable stores user inputs, calculations and MC outputs. As the above, you don´t need to use it, but you may get features to customize your own script.
For example, you may use mc.tm to get the transition matrix, or the prob map to customize the display. As you see, functions are all based on mc_states UDT. The s_map UDT is used within mc_states´s s array.
Optional exported functions include:
- `mc_table()`: Displays the transition matrix in a table format on the chart for easy visualization of the probabilities.
- `display_list()`: Displays a map (or array) of string and float/int values in a table format, used for showing transition counts or probabilities.
- `mc_prob()`: Calculates and displays probabilities for a given number of future bars based on the current state in the Markov Chain.
- `mc_all_states_prob()`: Calculates probabilities for all states for future bars, considering all possible transitions.
The above functions may be used to customize your outputs. Use the returned variable mc_states from mc_rw() and mc_cond() to display each of its matrix, maps or arrays using mc_table() (for matrices) and display_list() (for maps and arrays) if you desire to debug or track the calculation process.
See the examples in the end of this script.
Have good trading days!
Best regards,
@metacamaleo
-----------------------------
KEY FUNCTIONS
mc_rw(state, length, states, pred_length, show_table, show_prob, table_position, prob_position, font_size)
Builds the transition matrix for a rolling window Markov Chain.
Parameters:
state (string) : The current state of the market or system.
length (int) : The rolling window size.
states (array) : Array of strings representing the possible states in the Markov Chain.
pred_length (int) : The number of bars to predict into the future.
show_table (bool) : Boolean to show or hide the transition matrix table.
show_prob (bool) : Boolean to show or hide the probability table.
table_position (string) : Position of the transition matrix table on the chart.
prob_position (string) : Position of the probability list on the chart.
font_size (string) : Size of the table font.
Returns: The transition matrix and probabilities for future states.
mc_cond(state, condition, states, pred_length, show_table, show_prob, table_position, prob_position, font_size)
Builds the transition matrix for conditional Markov Chains.
Parameters:
state (string) : The current state of the market or system.
condition (string) : A string representing the condition.
states (array) : Array of strings representing the possible states in the Markov Chain.
pred_length (int) : The number of bars to predict into the future.
show_table (bool) : Boolean to show or hide the transition matrix table.
show_prob (bool) : Boolean to show or hide the probability table.
table_position (string) : Position of the transition matrix table on the chart.
prob_position (string) : Position of the probability list on the chart.
font_size (string) : Size of the table font.
Returns: The transition matrix and probabilities for future states based on the HMM.
lib_no_delayLibrary "lib_no_delay"
This library contains modifications to standard functions that return na before reaching the bar of their 'length' parameter.
That is because they do not compromise speed at current time for correct results in the past. This is good for live trading in short timeframes but killing applications on Monthly / Weekly timeframes if instruments, like in crypto, do not have extensive history (why would you even trade the monthly on a meme coin ... not my decision).
Also, some functions rely on source (value at previous bar), which is not available on bar 1 and therefore cascading to a na value up to the last bar ... which in turn leads to a non displaying indicator and waste of time debugging this)
Anyway ... there you go, let me know if I should add more functions.
sma(source, length)
Parameters:
source (float) : Series of values to process.
length (simple int) : Number of bars (length).
Returns: Simple moving average of source for length bars back.
ema(source, length)
Parameters:
source (float) : Series of values to process.
length (simple int) : Number of bars (length).
Returns: (float) The exponentially weighted moving average of the source.
rma(source, length)
Parameters:
source (float) : Series of values to process.
length (simple int) : Number of bars (length).
Returns: Exponential moving average of source with alpha = 1 / length.
atr(length)
Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close ), abs(low - close )). This adapted version extends ta.atr to start without delay at first bar and deliver usable data instead of na by averaging ta.tr(true) via manual SMA.
Parameters:
length (simple int) : Number of bars back (length).
Returns: Average true range.
rsi(source, length)
Relative strength index. It is calculated using the ta.rma() of upward and downward changes of source over the last length bars. This adapted version extends ta.rsi to start without delay at first bar and deliver usable data instead of na.
Parameters:
source (float) : Series of values to process.
length (simple int) : Number of bars back (length).
Returns: Relative Strength Index.
COMET_Scanner_Library_FINALLibrary "COMET_Scanner_Library"
- A Trader's Edge (ATE)_Library was created to assist in constructing COM Scanners
TickerIDs(_string)
TickerIDs: 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 COM 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 COM Scanner scripts:
assets = input.text_area(tIDs, title="TickerIDs (MUST READ TOOLTIP)", group=g2, tooltip="Accepts 40 TICKERID's
for each copy of the script on the chart. *** MUST FORMAT THIS WAY *** Each FULL tickerID
(ie 'Exchange:ticker') must be separated by A SINGLE BLANK SPACE for correct formatting. The blank space tells
the script where to break off the ticker to assign it to a variable to be used later in the script. So this input
will be a single string constructed from up to 40 tickerID's with a space between each tickerID
(ie. 'BINANCE:BTCUSDT BINANCE:SXPUSDT BINANCE:XRPUSDT').", display=display.none)
Returns: Returns 40 output variables in the tuple (ie. between the ' ') with the separated TickerIDs,
Locations(_firstLocation)
Locations: This function is used when there's a desire to print an assets ALERT LABELS. A set Location on the scale is assigned to each asset.
This is created so that if a lot of alerts are triggered, they will stay relatively visible and not overlap each other.
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.
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 variables for the locations for alert labels
LabelSize(_barCnt, _lblSzRfrnce)
INVALID TICKERIDs: 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.
LABEL SIZES: 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 COM Scanner 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 Security function's tuple and input it as this functions 1st input
parameter which will directly affect the size of the 2nd output variable ('alertTrigLabel') that is also outputted by this function.
_lblSzRfrnce (string) : (string)
Optional (if parameter not included, it defaults to size.small). This will be the size of the variable outputted
by this function named 'assetNameLabel' BUT also affects the size of the output variable 'alertTrigLabel' as it uses this parameter's size
as the smallest size for 'alertTrigLabel' then uses the '_barCnt' parameter to determine the next sizes up depending on the "_barCnt" value.
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.
InvalidTickerIDs(_close, _securityTickerid, _invalidArray, _tablePosition, _stackVertical)
Parameters:
_close (float)
_securityTickerid (string)
_invalidArray (array)
_tablePosition (simple string)
_stackVertical (simple bool)
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.
GraphLibrary "Graph"
Library to collect data and draw scatterplot and heatmap as graph
method init(this)
Initialise Quadrant Data
Namespace types: Quadrant
Parameters:
this (Quadrant) : Quadrant object that needs to be initialised
Returns: current Quadrant object
method init(this)
Initialise Graph Data
Namespace types: Graph
Parameters:
this (Graph) : Graph object that needs to be initialised with 4 Quadrants
Returns: current Graph object
method add(this, data)
Add coordinates to graph
Namespace types: Graph
Parameters:
this (Graph) : Graph object
data (Coordinate) : Coordinates containing x, y data
Returns: current Graph object
method calculate(this)
Calculation required for plotting the graph
Namespace types: Graph
Parameters:
this (Graph) : Graph object
Returns: current Graph object
method paint(this)
Draw graph
Namespace types: Graph
Parameters:
this (Graph) : Graph object
Returns: current Graph object
Coordinate
Coordinates of sample data
Fields:
xValue (series float) : x value of the sample data
yValue (series float) : y value of the sample data
Quadrant
Data belonging to particular quadrant
Fields:
coordinates (array) : Coordinates present in given quadrant
GraphProperties
Properties of Graph that needs to be drawn
Fields:
rows (series int) : Number of rows (y values) in each quadrant
columns (series int) : number of columns (x values) in each quadrant
graphtype (series GraphType) : Type of graph - scatterplot or heatmap
plotColor (series color) : color of plots or heatmap
plotSize (series string) : size of cells in the table
plotchar (series string) : Character to be printed for display of scatterplot
outliers (series int) : Excude the outlier percent of data from calculating the min and max
position (series string) : Table position
bgColor (series color) : graph background color
PlotRange
Range of a plot in terms of x and y values and the number of data points that fall within the Range
Fields:
minX (series float) : min range of X value
maxX (series float) : max range of X value
minY (series float) : min range of Y value
maxY (series float) : max range of Y value
count (series int) : number of samples in the range
Graph
Graph data and properties
Fields:
properties (GraphProperties) : Graph Properties object associated
quadrants (array) : Array containing 4 quadrant data
plotRanges (matrix) : range and count for each cell
xArray (array) : array of x values
yArray (array) : arrray of y values
PubLibPatternLibrary "PubLibPattern"
pattern conditions for indicator and strategy development
bear_5_0(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bearish 5-0 harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bull_5_0(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bullish 5-0 harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bear_abcd(bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bearish abcd harmonic pattern condition
Parameters:
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bull_abcd(bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bullish abcd harmonic pattern condition
Parameters:
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bear_alt_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bearish alternate bat harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bull_alt_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bullish alternate bat harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bear_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bearish bat harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bull_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bullish bat harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bear_butterfly(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bearish butterfly harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bull_butterfly(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bullish butterfly harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bear_cassiopeia_a(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bearish cassiopeia a harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bull_cassiopeia_a(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bullish cassiopeia a harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bear_cassiopeia_b(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bearish cassiopeia b harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bull_cassiopeia_b(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bullish cassiopeia b harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bear_cassiopeia_c(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bearish cassiopeia c harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bull_cassiopeia_c(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
bullish cassiopeia c harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
Returns: bool
bear_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bearish crab harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bull_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bullish crab harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bear_deep_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bearish deep crab harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bull_deep_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bullish deep crab harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bear_cypher(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, xc_low_tol, xc_up_tol)
bearish cypher harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
xc_low_tol (float)
xc_up_tol (float)
Returns: bool
bull_cypher(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, xc_low_tol, xc_up_tol)
bullish cypher harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
xc_low_tol (float)
xc_up_tol (float)
Returns: bool
bear_gartley(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bearish gartley harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bull_gartley(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
bullish gartley harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
cd_low_tol (float)
cd_up_tol (float)
ad_low_tol (float)
ad_up_tol (float)
Returns: bool
bear_shark(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, xc_low_tol, xc_up_tol)
bearish shark harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
xc_low_tol (float)
xc_up_tol (float)
Returns: bool
bull_shark(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, xc_low_tol, xc_up_tol)
bullish shark harmonic pattern condition
Parameters:
ab_low_tol (float)
ab_up_tol (float)
bc_low_tol (float)
bc_up_tol (float)
xc_low_tol (float)
xc_up_tol (float)
Returns: bool
bear_three_drive(x1_low_tol, a1_low_tol, a1_up_tol, a2_low_tol, a2_up_tol, b2_low_tol, b2_up_tol, b3_low_tol, b3_upt_tol)
bearish three drive harmonic pattern condition
Parameters:
x1_low_tol (float)
a1_low_tol (float)
a1_up_tol (float)
a2_low_tol (float)
a2_up_tol (float)
b2_low_tol (float)
b2_up_tol (float)
b3_low_tol (float)
b3_upt_tol (float)
Returns: bool
bull_three_drive(x1_low_tol, a1_low_tol, a1_up_tol, a2_low_tol, a2_up_tol, b2_low_tol, b2_up_tol, b3_low_tol, b3_upt_tol)
bullish three drive harmonic pattern condition
Parameters:
x1_low_tol (float)
a1_low_tol (float)
a1_up_tol (float)
a2_low_tol (float)
a2_up_tol (float)
b2_low_tol (float)
b2_up_tol (float)
b3_low_tol (float)
b3_upt_tol (float)
Returns: bool
asc_broadening()
ascending broadening pattern condition
Returns: bool
broadening()
broadening pattern condition
Returns: bool
desc_broadening()
descending broadening pattern condition
Returns: bool
double_bot(low_tol, up_tol)
double bottom pattern condition
Parameters:
low_tol (float)
up_tol (float)
Returns: bool
double_top(low_tol, up_tol)
double top pattern condition
Parameters:
low_tol (float)
up_tol (float)
Returns: bool
triple_bot(low_tol, up_tol)
triple bottom pattern condition
Parameters:
low_tol (float)
up_tol (float)
Returns: bool
triple_top(low_tol, up_tol)
triple top pattern condition
Parameters:
low_tol (float)
up_tol (float)
Returns: bool
bear_elliot()
bearish elliot wave pattern condition
Returns: bool
bull_elliot()
bullish elliot wave pattern condition
Returns: bool
bear_alt_flag(ab_ratio, bc_ratio)
bearish alternate flag pattern condition
Parameters:
ab_ratio (float)
bc_ratio (float)
Returns: bool
bull_alt_flag(ab_ratio, bc_ratio)
bullish alternate flag pattern condition
Parameters:
ab_ratio (float)
bc_ratio (float)
Returns: bool
bear_flag(ab_ratio, bc_ratio, be_ratio)
bearish flag pattern condition
Parameters:
ab_ratio (float)
bc_ratio (float)
be_ratio (float)
Returns: bool
bull_flag(ab_ratio, bc_ratio, be_ratio)
bullish flag pattern condition
Parameters:
ab_ratio (float)
bc_ratio (float)
be_ratio (float)
Returns: bool
bear_asc_head_shoulders()
bearish ascending head and shoulders pattern condition
Returns: bool
bull_asc_head_shoulders()
bullish ascending head and shoulders pattern condition
Returns: bool
bear_desc_head_shoulders()
bearish descending head and shoulders pattern condition
Returns: bool
bull_desc_head_shoulders()
bullish descending head and shoulders pattern condition
Returns: bool
bear_head_shoulders()
bearish head and shoulders pattern condition
Returns: bool
bull_head_shoulders()
bullish head and shoulders pattern condition
Returns: bool
bear_pennant(ab_ratio, bc_ratio)
bearish pennant pattern condition
Parameters:
ab_ratio (float)
bc_ratio (float)
Returns: bool
bull_pennant(ab_ratio, bc_ratio)
bullish pennant pattern condition
Parameters:
ab_ratio (float)
bc_ratio (float)
Returns: bool
asc_wedge()
ascending wedge pattern condition
Returns: bool
desc_wedge()
descending wedge pattern condition
Returns: bool
wedge()
wedge pattern condition
Returns: bool
PubLibTrendLibrary "PubLibTrend"
trend, multi-part trend, double trend and multi-part double trend conditions for indicator and strategy development
rlut()
return line uptrend condition
Returns: bool
dt()
downtrend condition
Returns: bool
ut()
uptrend condition
Returns: bool
rldt()
return line downtrend condition
Returns: bool
dtop()
double top condition
Returns: bool
dbot()
double bottom condition
Returns: bool
rlut_1p()
1-part return line uptrend condition
Returns: bool
rlut_2p()
2-part return line uptrend condition
Returns: bool
rlut_3p()
3-part return line uptrend condition
Returns: bool
rlut_4p()
4-part return line uptrend condition
Returns: bool
rlut_5p()
5-part return line uptrend condition
Returns: bool
rlut_6p()
6-part return line uptrend condition
Returns: bool
rlut_7p()
7-part return line uptrend condition
Returns: bool
rlut_8p()
8-part return line uptrend condition
Returns: bool
rlut_9p()
9-part return line uptrend condition
Returns: bool
rlut_10p()
10-part return line uptrend condition
Returns: bool
rlut_11p()
11-part return line uptrend condition
Returns: bool
rlut_12p()
12-part return line uptrend condition
Returns: bool
rlut_13p()
13-part return line uptrend condition
Returns: bool
rlut_14p()
14-part return line uptrend condition
Returns: bool
rlut_15p()
15-part return line uptrend condition
Returns: bool
rlut_16p()
16-part return line uptrend condition
Returns: bool
rlut_17p()
17-part return line uptrend condition
Returns: bool
rlut_18p()
18-part return line uptrend condition
Returns: bool
rlut_19p()
19-part return line uptrend condition
Returns: bool
rlut_20p()
20-part return line uptrend condition
Returns: bool
rlut_21p()
21-part return line uptrend condition
Returns: bool
rlut_22p()
22-part return line uptrend condition
Returns: bool
rlut_23p()
23-part return line uptrend condition
Returns: bool
rlut_24p()
24-part return line uptrend condition
Returns: bool
rlut_25p()
25-part return line uptrend condition
Returns: bool
rlut_26p()
26-part return line uptrend condition
Returns: bool
rlut_27p()
27-part return line uptrend condition
Returns: bool
rlut_28p()
28-part return line uptrend condition
Returns: bool
rlut_29p()
29-part return line uptrend condition
Returns: bool
rlut_30p()
30-part return line uptrend condition
Returns: bool
dt_1p()
1-part downtrend condition
Returns: bool
dt_2p()
2-part downtrend condition
Returns: bool
dt_3p()
3-part downtrend condition
Returns: bool
dt_4p()
4-part downtrend condition
Returns: bool
dt_5p()
5-part downtrend condition
Returns: bool
dt_6p()
6-part downtrend condition
Returns: bool
dt_7p()
7-part downtrend condition
Returns: bool
dt_8p()
8-part downtrend condition
Returns: bool
dt_9p()
9-part downtrend condition
Returns: bool
dt_10p()
10-part downtrend condition
Returns: bool
dt_11p()
11-part downtrend condition
Returns: bool
dt_12p()
12-part downtrend condition
Returns: bool
dt_13p()
13-part downtrend condition
Returns: bool
dt_14p()
14-part downtrend condition
Returns: bool
dt_15p()
15-part downtrend condition
Returns: bool
dt_16p()
16-part downtrend condition
Returns: bool
dt_17p()
17-part downtrend condition
Returns: bool
dt_18p()
18-part downtrend condition
Returns: bool
dt_19p()
19-part downtrend condition
Returns: bool
dt_20p()
20-part downtrend condition
Returns: bool
dt_21p()
21-part downtrend condition
Returns: bool
dt_22p()
22-part downtrend condition
Returns: bool
dt_23p()
23-part downtrend condition
Returns: bool
dt_24p()
24-part downtrend condition
Returns: bool
dt_25p()
25-part downtrend condition
Returns: bool
dt_26p()
26-part downtrend condition
Returns: bool
dt_27p()
27-part downtrend condition
Returns: bool
dt_28p()
28-part downtrend condition
Returns: bool
dt_29p()
29-part downtrend condition
Returns: bool
dt_30p()
30-part downtrend condition
Returns: bool
ut_1p()
1-part uptrend condition
Returns: bool
ut_2p()
2-part uptrend condition
Returns: bool
ut_3p()
3-part uptrend condition
Returns: bool
ut_4p()
4-part uptrend condition
Returns: bool
ut_5p()
5-part uptrend condition
Returns: bool
ut_6p()
6-part uptrend condition
Returns: bool
ut_7p()
7-part uptrend condition
Returns: bool
ut_8p()
8-part uptrend condition
Returns: bool
ut_9p()
9-part uptrend condition
Returns: bool
ut_10p()
10-part uptrend condition
Returns: bool
ut_11p()
11-part uptrend condition
Returns: bool
ut_12p()
12-part uptrend condition
Returns: bool
ut_13p()
13-part uptrend condition
Returns: bool
ut_14p()
14-part uptrend condition
Returns: bool
ut_15p()
15-part uptrend condition
Returns: bool
ut_16p()
16-part uptrend condition
Returns: bool
ut_17p()
17-part uptrend condition
Returns: bool
ut_18p()
18-part uptrend condition
Returns: bool
ut_19p()
19-part uptrend condition
Returns: bool
ut_20p()
20-part uptrend condition
Returns: bool
ut_21p()
21-part uptrend condition
Returns: bool
ut_22p()
22-part uptrend condition
Returns: bool
ut_23p()
23-part uptrend condition
Returns: bool
ut_24p()
24-part uptrend condition
Returns: bool
ut_25p()
25-part uptrend condition
Returns: bool
ut_26p()
26-part uptrend condition
Returns: bool
ut_27p()
27-part uptrend condition
Returns: bool
ut_28p()
28-part uptrend condition
Returns: bool
ut_29p()
29-part uptrend condition
Returns: bool
ut_30p()
30-part uptrend condition
Returns: bool
rldt_1p()
1-part return line downtrend condition
Returns: bool
rldt_2p()
2-part return line downtrend condition
Returns: bool
rldt_3p()
3-part return line downtrend condition
Returns: bool
rldt_4p()
4-part return line downtrend condition
Returns: bool
rldt_5p()
5-part return line downtrend condition
Returns: bool
rldt_6p()
6-part return line downtrend condition
Returns: bool
rldt_7p()
7-part return line downtrend condition
Returns: bool
rldt_8p()
8-part return line downtrend condition
Returns: bool
rldt_9p()
9-part return line downtrend condition
Returns: bool
rldt_10p()
10-part return line downtrend condition
Returns: bool
rldt_11p()
11-part return line downtrend condition
Returns: bool
rldt_12p()
12-part return line downtrend condition
Returns: bool
rldt_13p()
13-part return line downtrend condition
Returns: bool
rldt_14p()
14-part return line downtrend condition
Returns: bool
rldt_15p()
15-part return line downtrend condition
Returns: bool
rldt_16p()
16-part return line downtrend condition
Returns: bool
rldt_17p()
17-part return line downtrend condition
Returns: bool
rldt_18p()
18-part return line downtrend condition
Returns: bool
rldt_19p()
19-part return line downtrend condition
Returns: bool
rldt_20p()
20-part return line downtrend condition
Returns: bool
rldt_21p()
21-part return line downtrend condition
Returns: bool
rldt_22p()
22-part return line downtrend condition
Returns: bool
rldt_23p()
23-part return line downtrend condition
Returns: bool
rldt_24p()
24-part return line downtrend condition
Returns: bool
rldt_25p()
25-part return line downtrend condition
Returns: bool
rldt_26p()
26-part return line downtrend condition
Returns: bool
rldt_27p()
27-part return line downtrend condition
Returns: bool
rldt_28p()
28-part return line downtrend condition
Returns: bool
rldt_29p()
29-part return line downtrend condition
Returns: bool
rldt_30p()
30-part return line downtrend condition
Returns: bool
dut()
double uptrend condition
Returns: bool
ddt()
double downtrend condition
Returns: bool
dut_1p()
1-part double uptrend condition
Returns: bool
dut_2p()
2-part double uptrend condition
Returns: bool
dut_3p()
3-part double uptrend condition
Returns: bool
dut_4p()
4-part double uptrend condition
Returns: bool
dut_5p()
5-part double uptrend condition
Returns: bool
dut_6p()
6-part double uptrend condition
Returns: bool
dut_7p()
7-part double uptrend condition
Returns: bool
dut_8p()
8-part double uptrend condition
Returns: bool
dut_9p()
9-part double uptrend condition
Returns: bool
dut_10p()
10-part double uptrend condition
Returns: bool
dut_11p()
11-part double uptrend condition
Returns: bool
dut_12p()
12-part double uptrend condition
Returns: bool
dut_13p()
13-part double uptrend condition
Returns: bool
dut_14p()
14-part double uptrend condition
Returns: bool
dut_15p()
15-part double uptrend condition
Returns: bool
dut_16p()
16-part double uptrend condition
Returns: bool
dut_17p()
17-part double uptrend condition
Returns: bool
dut_18p()
18-part double uptrend condition
Returns: bool
dut_19p()
19-part double uptrend condition
Returns: bool
dut_20p()
20-part double uptrend condition
Returns: bool
dut_21p()
21-part double uptrend condition
Returns: bool
dut_22p()
22-part double uptrend condition
Returns: bool
dut_23p()
23-part double uptrend condition
Returns: bool
dut_24p()
24-part double uptrend condition
Returns: bool
dut_25p()
25-part double uptrend condition
Returns: bool
dut_26p()
26-part double uptrend condition
Returns: bool
dut_27p()
27-part double uptrend condition
Returns: bool
dut_28p()
28-part double uptrend condition
Returns: bool
dut_29p()
29-part double uptrend condition
Returns: bool
dut_30p()
30-part double uptrend condition
Returns: bool
ddt_1p()
1-part double downtrend condition
Returns: bool
ddt_2p()
2-part double downtrend condition
Returns: bool
ddt_3p()
3-part double downtrend condition
Returns: bool
ddt_4p()
4-part double downtrend condition
Returns: bool
ddt_5p()
5-part double downtrend condition
Returns: bool
ddt_6p()
6-part double downtrend condition
Returns: bool
ddt_7p()
7-part double downtrend condition
Returns: bool
ddt_8p()
8-part double downtrend condition
Returns: bool
ddt_9p()
9-part double downtrend condition
Returns: bool
ddt_10p()
10-part double downtrend condition
Returns: bool
ddt_11p()
11-part double downtrend condition
Returns: bool
ddt_12p()
12-part double downtrend condition
Returns: bool
ddt_13p()
13-part double downtrend condition
Returns: bool
ddt_14p()
14-part double downtrend condition
Returns: bool
ddt_15p()
15-part double downtrend condition
Returns: bool
ddt_16p()
16-part double downtrend condition
Returns: bool
ddt_17p()
17-part double downtrend condition
Returns: bool
ddt_18p()
18-part double downtrend condition
Returns: bool
ddt_19p()
19-part double downtrend condition
Returns: bool
ddt_20p()
20-part double downtrend condition
Returns: bool
ddt_21p()
21-part double downtrend condition
Returns: bool
ddt_22p()
22-part double downtrend condition
Returns: bool
ddt_23p()
23-part double downtrend condition
Returns: bool
ddt_24p()
24-part double downtrend condition
Returns: bool
ddt_25p()
25-part double downtrend condition
Returns: bool
ddt_26p()
26-part double downtrend condition
Returns: bool
ddt_27p()
27-part double downtrend condition
Returns: bool
ddt_28p()
28-part double downtrend condition
Returns: bool
ddt_29p()
29-part double downtrend condition
Returns: bool
ddt_30p()
30-part double downtrend condition
Returns: bool
PubLibSwingLibrary "PubLibSwing"
swing high and swing low conditions, prices, bar indices and range ratios for indicator and strategy development
sh()
swing high condition
Returns: bool
sl()
swing low condition
Returns: bool
shbi(occ)
swing high bar index, condition occurrence n
Parameters:
occ (simple int)
Returns: int
slbi(occ)
swing low bar index, condition occurrence n
Parameters:
occ (simple int)
Returns: int
shcp(occ)
swing high close price, condition occurrence n
Parameters:
occ (simple int)
Returns: float
slcp(occ)
swing low close price, condition occurrence n
Parameters:
occ (simple int)
Returns: float
shp(occ)
swing high price, condition occurrence n
Parameters:
occ (simple int)
Returns: float
slp(occ)
swing low price, condition occurrence n
Parameters:
occ (simple int)
Returns: float
shpbi(occ)
swing high price bar index, condition occurrence n
Parameters:
occ (simple int)
Returns: int
slpbi(occ)
swing low price bar index, condition occurrence n
Parameters:
occ (simple int)
Returns: int
shrr(occ)
swing high range ratio, condition occurrence n
Parameters:
occ (simple int)
Returns: float
slrr(occ)
swing low range ratio, condition occurrence n
Parameters:
occ (simple int)
Returns: float
PubLibCandleTrendLibrary "PubLibCandleTrend"
candle trend, multi-part candle trend, multi-part green/red candle trend, double candle trend and multi-part double candle trend conditions for indicator and strategy development
chh()
candle higher high condition
Returns: bool
chl()
candle higher low condition
Returns: bool
clh()
candle lower high condition
Returns: bool
cll()
candle lower low condition
Returns: bool
cdt()
candle double top condition
Returns: bool
cdb()
candle double bottom condition
Returns: bool
gc()
green candle condition
Returns: bool
gchh()
green candle higher high condition
Returns: bool
gchl()
green candle higher low condition
Returns: bool
gclh()
green candle lower high condition
Returns: bool
gcll()
green candle lower low condition
Returns: bool
gcdt()
green candle double top condition
Returns: bool
gcdb()
green candle double bottom condition
Returns: bool
rc()
red candle condition
Returns: bool
rchh()
red candle higher high condition
Returns: bool
rchl()
red candle higher low condition
Returns: bool
rclh()
red candle lower high condition
Returns: bool
rcll()
red candle lower low condition
Returns: bool
rcdt()
red candle double top condition
Returns: bool
rcdb()
red candle double bottom condition
Returns: bool
chh_1p()
1-part candle higher high condition
Returns: bool
chh_2p()
2-part candle higher high condition
Returns: bool
chh_3p()
3-part candle higher high condition
Returns: bool
chh_4p()
4-part candle higher high condition
Returns: bool
chh_5p()
5-part candle higher high condition
Returns: bool
chh_6p()
6-part candle higher high condition
Returns: bool
chh_7p()
7-part candle higher high condition
Returns: bool
chh_8p()
8-part candle higher high condition
Returns: bool
chh_9p()
9-part candle higher high condition
Returns: bool
chh_10p()
10-part candle higher high condition
Returns: bool
chh_11p()
11-part candle higher high condition
Returns: bool
chh_12p()
12-part candle higher high condition
Returns: bool
chh_13p()
13-part candle higher high condition
Returns: bool
chh_14p()
14-part candle higher high condition
Returns: bool
chh_15p()
15-part candle higher high condition
Returns: bool
chh_16p()
16-part candle higher high condition
Returns: bool
chh_17p()
17-part candle higher high condition
Returns: bool
chh_18p()
18-part candle higher high condition
Returns: bool
chh_19p()
19-part candle higher high condition
Returns: bool
chh_20p()
20-part candle higher high condition
Returns: bool
chh_21p()
21-part candle higher high condition
Returns: bool
chh_22p()
22-part candle higher high condition
Returns: bool
chh_23p()
23-part candle higher high condition
Returns: bool
chh_24p()
24-part candle higher high condition
Returns: bool
chh_25p()
25-part candle higher high condition
Returns: bool
chh_26p()
26-part candle higher high condition
Returns: bool
chh_27p()
27-part candle higher high condition
Returns: bool
chh_28p()
28-part candle higher high condition
Returns: bool
chh_29p()
29-part candle higher high condition
Returns: bool
chh_30p()
30-part candle higher high condition
Returns: bool
chl_1p()
1-part candle higher low condition
Returns: bool
chl_2p()
2-part candle higher low condition
Returns: bool
chl_3p()
3-part candle higher low condition
Returns: bool
chl_4p()
4-part candle higher low condition
Returns: bool
chl_5p()
5-part candle higher low condition
Returns: bool
chl_6p()
6-part candle higher low condition
Returns: bool
chl_7p()
7-part candle higher low condition
Returns: bool
chl_8p()
8-part candle higher low condition
Returns: bool
chl_9p()
9-part candle higher low condition
Returns: bool
chl_10p()
10-part candle higher low condition
Returns: bool
chl_11p()
11-part candle higher low condition
Returns: bool
chl_12p()
12-part candle higher low condition
Returns: bool
chl_13p()
13-part candle higher low condition
Returns: bool
chl_14p()
14-part candle higher low condition
Returns: bool
chl_15p()
15-part candle higher low condition
Returns: bool
chl_16p()
16-part candle higher low condition
Returns: bool
chl_17p()
17-part candle higher low condition
Returns: bool
chl_18p()
18-part candle higher low condition
Returns: bool
chl_19p()
19-part candle higher low condition
Returns: bool
chl_20p()
20-part candle higher low condition
Returns: bool
chl_21p()
21-part candle higher low condition
Returns: bool
chl_22p()
22-part candle higher low condition
Returns: bool
chl_23p()
23-part candle higher low condition
Returns: bool
chl_24p()
24-part candle higher low condition
Returns: bool
chl_25p()
25-part candle higher low condition
Returns: bool
chl_26p()
26-part candle higher low condition
Returns: bool
chl_27p()
27-part candle higher low condition
Returns: bool
chl_28p()
28-part candle higher low condition
Returns: bool
chl_29p()
29-part candle higher low condition
Returns: bool
chl_30p()
30-part candle higher low condition
Returns: bool
clh_1p()
1-part candle lower high condition
Returns: bool
clh_2p()
2-part candle lower high condition
Returns: bool
clh_3p()
3-part candle lower high condition
Returns: bool
clh_4p()
4-part candle lower high condition
Returns: bool
clh_5p()
5-part candle lower high condition
Returns: bool
clh_6p()
6-part candle lower high condition
Returns: bool
clh_7p()
7-part candle lower high condition
Returns: bool
clh_8p()
8-part candle lower high condition
Returns: bool
clh_9p()
9-part candle lower high condition
Returns: bool
clh_10p()
10-part candle lower high condition
Returns: bool
clh_11p()
11-part candle lower high condition
Returns: bool
clh_12p()
12-part candle lower high condition
Returns: bool
clh_13p()
13-part candle lower high condition
Returns: bool
clh_14p()
14-part candle lower high condition
Returns: bool
clh_15p()
15-part candle lower high condition
Returns: bool
clh_16p()
16-part candle lower high condition
Returns: bool
clh_17p()
17-part candle lower high condition
Returns: bool
clh_18p()
18-part candle lower high condition
Returns: bool
clh_19p()
19-part candle lower high condition
Returns: bool
clh_20p()
20-part candle lower high condition
Returns: bool
clh_21p()
21-part candle lower high condition
Returns: bool
clh_22p()
22-part candle lower high condition
Returns: bool
clh_23p()
23-part candle lower high condition
Returns: bool
clh_24p()
24-part candle lower high condition
Returns: bool
clh_25p()
25-part candle lower high condition
Returns: bool
clh_26p()
26-part candle lower high condition
Returns: bool
clh_27p()
27-part candle lower high condition
Returns: bool
clh_28p()
28-part candle lower high condition
Returns: bool
clh_29p()
29-part candle lower high condition
Returns: bool
clh_30p()
30-part candle lower high condition
Returns: bool
cll_1p()
1-part candle lower low condition
Returns: bool
cll_2p()
2-part candle lower low condition
Returns: bool
cll_3p()
3-part candle lower low condition
Returns: bool
cll_4p()
4-part candle lower low condition
Returns: bool
cll_5p()
5-part candle lower low condition
Returns: bool
cll_6p()
6-part candle lower low condition
Returns: bool
cll_7p()
7-part candle lower low condition
Returns: bool
cll_8p()
8-part candle lower low condition
Returns: bool
cll_9p()
9-part candle lower low condition
Returns: bool
cll_10p()
10-part candle lower low condition
Returns: bool
cll_11p()
11-part candle lower low condition
Returns: bool
cll_12p()
12-part candle lower low condition
Returns: bool
cll_13p()
13-part candle lower low condition
Returns: bool
cll_14p()
14-part candle lower low condition
Returns: bool
cll_15p()
15-part candle lower low condition
Returns: bool
cll_16p()
16-part candle lower low condition
Returns: bool
cll_17p()
17-part candle lower low condition
Returns: bool
cll_18p()
18-part candle lower low condition
Returns: bool
cll_19p()
19-part candle lower low condition
Returns: bool
cll_20p()
20-part candle lower low condition
Returns: bool
cll_21p()
21-part candle lower low condition
Returns: bool
cll_22p()
22-part candle lower low condition
Returns: bool
cll_23p()
23-part candle lower low condition
Returns: bool
cll_24p()
24-part candle lower low condition
Returns: bool
cll_25p()
25-part candle lower low condition
Returns: bool
cll_26p()
26-part candle lower low condition
Returns: bool
cll_27p()
27-part candle lower low condition
Returns: bool
cll_28p()
28-part candle lower low condition
Returns: bool
cll_29p()
29-part candle lower low condition
Returns: bool
cll_30p()
30-part candle lower low condition
Returns: bool
gc_1p()
1-part green candle condition
Returns: bool
gc_2p()
2-part green candle condition
Returns: bool
gc_3p()
3-part green candle condition
Returns: bool
gc_4p()
4-part green candle condition
Returns: bool
gc_5p()
5-part green candle condition
Returns: bool
gc_6p()
6-part green candle condition
Returns: bool
gc_7p()
7-part green candle condition
Returns: bool
gc_8p()
8-part green candle condition
Returns: bool
gc_9p()
9-part green candle condition
Returns: bool
gc_10p()
10-part green candle condition
Returns: bool
gc_11p()
11-part green candle condition
Returns: bool
gc_12p()
12-part green candle condition
Returns: bool
gc_13p()
13-part green candle condition
Returns: bool
gc_14p()
14-part green candle condition
Returns: bool
gc_15p()
15-part green candle condition
Returns: bool
gc_16p()
16-part green candle condition
Returns: bool
gc_17p()
17-part green candle condition
Returns: bool
gc_18p()
18-part green candle condition
Returns: bool
gc_19p()
19-part green candle condition
Returns: bool
gc_20p()
20-part green candle condition
Returns: bool
gc_21p()
21-part green candle condition
Returns: bool
gc_22p()
22-part green candle condition
Returns: bool
gc_23p()
23-part green candle condition
Returns: bool
gc_24p()
24-part green candle condition
Returns: bool
gc_25p()
25-part green candle condition
Returns: bool
gc_26p()
26-part green candle condition
Returns: bool
gc_27p()
27-part green candle condition
Returns: bool
gc_28p()
28-part green candle condition
Returns: bool
gc_29p()
29-part green candle condition
Returns: bool
gc_30p()
30-part green candle condition
Returns: bool
rc_1p()
1-part red candle condition
Returns: bool
rc_2p()
2-part red candle condition
Returns: bool
rc_3p()
3-part red candle condition
Returns: bool
rc_4p()
4-part red candle condition
Returns: bool
rc_5p()
5-part red candle condition
Returns: bool
rc_6p()
6-part red candle condition
Returns: bool
rc_7p()
7-part red candle condition
Returns: bool
rc_8p()
8-part red candle condition
Returns: bool
rc_9p()
9-part red candle condition
Returns: bool
rc_10p()
10-part red candle condition
Returns: bool
rc_11p()
11-part red candle condition
Returns: bool
rc_12p()
12-part red candle condition
Returns: bool
rc_13p()
13-part red candle condition
Returns: bool
rc_14p()
14-part red candle condition
Returns: bool
rc_15p()
15-part red candle condition
Returns: bool
rc_16p()
16-part red candle condition
Returns: bool
rc_17p()
17-part red candle condition
Returns: bool
rc_18p()
18-part red candle condition
Returns: bool
rc_19p()
19-part red candle condition
Returns: bool
rc_20p()
20-part red candle condition
Returns: bool
rc_21p()
21-part red candle condition
Returns: bool
rc_22p()
22-part red candle condition
Returns: bool
rc_23p()
23-part red candle condition
Returns: bool
rc_24p()
24-part red candle condition
Returns: bool
rc_25p()
25-part red candle condition
Returns: bool
rc_26p()
26-part red candle condition
Returns: bool
rc_27p()
27-part red candle condition
Returns: bool
rc_28p()
28-part red candle condition
Returns: bool
rc_29p()
29-part red candle condition
Returns: bool
rc_30p()
30-part red candle condition
Returns: bool
cdut()
candle double uptrend condition
Returns: bool
cddt()
candle double downtrend condition
Returns: bool
cdut_1p()
1-part candle double uptrend condition
Returns: bool
cdut_2p()
2-part candle double uptrend condition
Returns: bool
cdut_3p()
3-part candle double uptrend condition
Returns: bool
cdut_4p()
4-part candle double uptrend condition
Returns: bool
cdut_5p()
5-part candle double uptrend condition
Returns: bool
cdut_6p()
6-part candle double uptrend condition
Returns: bool
cdut_7p()
7-part candle double uptrend condition
Returns: bool
cdut_8p()
8-part candle double uptrend condition
Returns: bool
cdut_9p()
9-part candle double uptrend condition
Returns: bool
cdut_10p()
10-part candle double uptrend condition
Returns: bool
cdut_11p()
11-part candle double uptrend condition
Returns: bool
cdut_12p()
12-part candle double uptrend condition
Returns: bool
cdut_13p()
13-part candle double uptrend condition
Returns: bool
cdut_14p()
14-part candle double uptrend condition
Returns: bool
cdut_15p()
15-part candle double uptrend condition
Returns: bool
cdut_16p()
16-part candle double uptrend condition
Returns: bool
cdut_17p()
17-part candle double uptrend condition
Returns: bool
cdut_18p()
18-part candle double uptrend condition
Returns: bool
cdut_19p()
19-part candle double uptrend condition
Returns: bool
cdut_20p()
20-part candle double uptrend condition
Returns: bool
cdut_21p()
21-part candle double uptrend condition
Returns: bool
cdut_22p()
22-part candle double uptrend condition
Returns: bool
cdut_23p()
23-part candle double uptrend condition
Returns: bool
cdut_24p()
24-part candle double uptrend condition
Returns: bool
cdut_25p()
25-part candle double uptrend condition
Returns: bool
cdut_26p()
26-part candle double uptrend condition
Returns: bool
cdut_27p()
27-part candle double uptrend condition
Returns: bool
cdut_28p()
28-part candle double uptrend condition
Returns: bool
cdut_29p()
29-part candle double uptrend condition
Returns: bool
cdut_30p()
30-part candle double uptrend condition
Returns: bool
cddt_1p()
1-part candle double downtrend condition
Returns: bool
cddt_2p()
2-part candle double downtrend condition
Returns: bool
cddt_3p()
3-part candle double downtrend condition
Returns: bool
cddt_4p()
4-part candle double downtrend condition
Returns: bool
cddt_5p()
5-part candle double downtrend condition
Returns: bool
cddt_6p()
6-part candle double downtrend condition
Returns: bool
cddt_7p()
7-part candle double downtrend condition
Returns: bool
cddt_8p()
8-part candle double downtrend condition
Returns: bool
cddt_9p()
9-part candle double downtrend condition
Returns: bool
cddt_10p()
10-part candle double downtrend condition
Returns: bool
cddt_11p()
11-part candle double downtrend condition
Returns: bool
cddt_12p()
12-part candle double downtrend condition
Returns: bool
cddt_13p()
13-part candle double downtrend condition
Returns: bool
cddt_14p()
14-part candle double downtrend condition
Returns: bool
cddt_15p()
15-part candle double downtrend condition
Returns: bool
cddt_16p()
16-part candle double downtrend condition
Returns: bool
cddt_17p()
17-part candle double downtrend condition
Returns: bool
cddt_18p()
18-part candle double downtrend condition
Returns: bool
cddt_19p()
19-part candle double downtrend condition
Returns: bool
cddt_20p()
20-part candle double downtrend condition
Returns: bool
cddt_21p()
21-part candle double downtrend condition
Returns: bool
cddt_22p()
22-part candle double downtrend condition
Returns: bool
cddt_23p()
23-part candle double downtrend condition
Returns: bool
cddt_24p()
24-part candle double downtrend condition
Returns: bool
cddt_25p()
25-part candle double downtrend condition
Returns: bool
cddt_26p()
26-part candle double downtrend condition
Returns: bool
cddt_27p()
27-part candle double downtrend condition
Returns: bool
cddt_28p()
28-part candle double downtrend condition
Returns: bool
cddt_29p()
29-part candle double downtrend condition
Returns: bool
cddt_30p()
30-part candle double downtrend condition
Returns: bool
Harmonic Patterns Library [TradingFinder]🔵 Introduction
Harmonic patterns blend geometric shapes with Fibonacci numbers, making these numbers fundamental to understanding the patterns.
One person who has done a lot of research on harmonic patterns is Scott Carney.Scott Carney's research on harmonic patterns in technical analysis focuses on precise price structures based on Fibonacci ratios to identify market reversals.
Key patterns include the Gartley, Bat, Butterfly, and Crab, each with specific alignment criteria. These patterns help traders anticipate potential market turning points and make informed trading decisions, enhancing the predictability of technical analysis.
🟣 Understanding 5-Point Harmonic Patterns
In the current library version, you can easily draw and customize most XABCD patterns. These patterns often form M or W shapes, or a combination of both. By calculating the Fibonacci ratios between key points, you can estimate potential price movements.
All five-point patterns share a similar structure, differing only in line lengths and Fibonacci ratios. Learning one pattern simplifies understanding others.
🟣 Exploring the Gartley Pattern
The Gartley pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Gartley, point X is below point D, and point A surpasses point C. Point D marks the start of a strong upward trend, making it an optimal point to place a buy order.
The bearish Gartley mirrors the bullish pattern with inverted Fibonacci ratios. In this scenario, point D indicates the start of a significant price drop. Traders can place sell orders at this point and buy at lower prices for profit in two-way markets.
🟣 Analyzing the Butterfly Pattern
The Butterfly pattern also manifests in bullish (M shape) and bearish (W shape) forms. It resembles the Gartley pattern but with point D lower than point X in the bullish version.
The Butterfly pattern involves deeper price corrections than the Gartley, leading to more significant price fluctuations. Point D in the bullish Butterfly indicates the beginning of a sharp price rise, making it an entry point for buy orders.
The bearish Butterfly has inverted Fibonacci ratios, with point D marking the start of a sharp price decline, ideal for sell orders followed by buying at lower prices in two-way markets.
🟣 Insights into the Bat Pattern
The Bat pattern, appearing in bullish (M shape) and bearish (W shape) forms, is one of the most precise harmonic patterns. It closely resembles the Butterfly and Gartley patterns, differing mainly in Fibonacci levels.
The bearish Bat pattern shares the Fibonacci ratios with the bullish Bat, with an inverted structure. Point D in the bearish Bat marks the start of a significant price drop, suitable for sell orders followed by buying at lower prices for profit.
🟣 The Crab Pattern Explained
The Crab pattern, found in both bullish (M shape) and bearish (W shape) forms, is highly favored by analysts. Discovered in 2000, the Crab pattern features a larger final wave correction compared to other harmonic patterns.
The bearish Crab shares Fibonacci ratios with the bullish version but in an inverted form. Point D in the bearish Crab signifies the start of a sharp price decline, making it an ideal point for sell orders followed by buying at lower prices for profitable trades.
🟣 Understanding the Shark Pattern
The Shark pattern appears in bullish (M shape) and bearish (W shape) forms. It differs from previous patterns as point C in the bullish Shark surpasses point A, with unique level measurements.
The bearish Shark pattern mirrors the Fibonacci ratios of the bullish Shark but is inverted. Point D in the bearish Shark indicates the start of a sharp price drop, ideal for placing sell orders and buying at lower prices to capitalize on the pattern.
🟣 The Cypher Pattern Overview
The Cypher pattern is another that appears in both bullish (M shape) and bearish (W shape) forms. It resembles the Shark pattern, with point C in the bullish Cypher extending beyond point A, and point D forming within the XA line.
The bearish Cypher shares the Fibonacci ratios with the bullish Cypher but in an inverted structure. Point D in the bearish Cypher marks the start of a significant price drop, perfect for sell orders followed by buying at lower prices.
🟣 Introducing the Nen-Star Pattern
The Nen-Star pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Nen-Star, point C extends beyond point A, and point D, the final point, forms outside the XA line, making CD the longest wave.
The bearish Nen-Star has inverted Fibonacci ratios, with point D indicating the start of a significant price drop. Traders can place sell orders at point D and buy at lower prices to profit from this pattern in two-way markets.
The 5-point harmonic patterns, commonly referred to as XABCD patterns, are specific geometric price structures identified in financial markets. These patterns are used by traders to predict potential price movements based on historical price data and Fibonacci retracement levels.
Here are the main 5-point harmonic patterns :
Gartley Pattern
Anti-Gartley Pattern
Bat Pattern
Anti-Bat Pattern
Alternate Bat Pattern
Butterfly Pattern
Anti-Butterfly Pattern
Crab Pattern
Anti-Crab Pattern
Deep Crab Pattern
Shark Pattern
Anti- Shark Pattern
Anti Alternate Shark Pattern
Cypher Pattern
Anti-Cypher Pattern
🔵 How to Use
To add "Order Block Refiner Library", you must first add the following code to your script.
import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP
🟣 Parameters
XABCD(Name, Type, Show, Color, LineWidth, LabelSize, ShVF, FLPC, FLPCPeriod, Pivot, ABXAmin, ABXAmax, BCABmin, BCABmax, CDBCmin, CDBCmax, CDXAmin, CDXAmax) =>
Parameters:
Name (string)
Type (string)
Show (bool)
Color (color)
LineWidth (int)
LabelSize (string)
ShVF (bool)
FLPC (bool)
FLPCPeriod (int)
Pivot (int)
ABXAmin (float)
ABXAmax (float)
BCABmin (float)
BCABmax (float)
CDBCmin (float)
CDBCmax (float)
CDXAmin (float)
CDXAmax (float)
🟣 Genaral Parameters
Name : The name of the pattern.
Type: Enter "Bullish" to draw a Bullish pattern and "Bearish" to draw an Bearish pattern.
Show : Enter "true" to display the template and "false" to not display the template.
Color : Enter the desired color to draw the pattern in this parameter.
LineWidth : You can enter the number 1 or numbers higher than one to adjust the thickness of the drawing lines. This number must be an integer and increases with increasing thickness.
LabelSize : You can adjust the size of the labels by using the "size.auto", "size.tiny", "size.smal", "size.normal", "size.large" or "size.huge" entries.
🟣 Logical Parameters
ShVF : If this parameter is on "true" mode, only patterns will be displayed that they have exact format and no noise can be seen in them. If "false" is, the patterns displayed that maybe are noisy and do not exactly correspond to the original pattern.
FLPC : if Turned on, you can see this ability of patterns when their last pivot is formed. If this feature is off, it will see the patterns as soon as they are formed. The advantage of this option being clear is less formation of fielded patterns, and it is accompanied by the lateest pattern seeing and a sharp reduction in reward to risk.
FLPCPeriod : Using this parameter you can determine that the last pivot is based on Pivot period.
Pivot : You need to determine the period of the zigzag indicator. This factor is the most important parameter in pattern recognition.
ABXAmin : Minimum retracement of "AB" line compared to "XA" line.
ABXAmax : Maximum retracement of "AB" line compared to "XA" line.
BCABmin : Minimum retracement of "BC" line compared to "AB" line.
BCABmax : Maximum retracement of "BC" line compared to "AB" line.
CDBCmin : Minimum retracement of "CD" line compared to "BC" line.
CDBCmax : Maximum retracement of "CD" line compared to "BC" line.
CDXAmin : Minimum retracement of "CD" line compared to "XA" line.
CDXAmax : Maximum retracement of "CD" line compared to "XA" line.
🟣 Function Outputs
This library has two outputs. The first output is related to the alert of the formation of a new pattern. And the second output is related to the formation of the candlestick pattern and you can draw it using the "plotshape" tool.
Candle Confirmation Logic :
Example :
import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP
PP = input.int(3, 'ZigZag Pivot Period')
ShowBull = input.bool(true, 'Show Bullish Pattern')
ShowBear = input.bool(true, 'Show Bearish Pattern')
ColorBull = input.color(#0609bb, 'Color Bullish Pattern')
ColorBear = input.color(#0609bb, 'Color Bearish Pattern')
LineWidth = input.int(1 , 'Width Line')
LabelSize = input.string(size.small , 'Label size' , options = )
ShVF = input.bool(false , 'Show Valid Format')
FLPC = input.bool(false , 'Show Formation Last Pivot Confirm')
FLPCPeriod =input.int(2, 'Period of Formation Last Pivot')
//Call function
= HP.XABCD('Bullish Bat', 'Bullish', ShowBull, ColorBull , LineWidth, LabelSize ,ShVF, FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
= HP.XABCD('Bearish Bat', 'Bearish', ShowBear, ColorBear , LineWidth, LabelSize ,ShVF, FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
//Alert
if BearAlert
alert('Bearish Harmonic')
if BullAlert
alert('Bulish Harmonic')
//CandleStick Confirm
plotshape(BearCandleConfirm, style = shape.arrowdown, color = color.red)
plotshape(BullCandleConfirm, style = shape.arrowup, color = color.green, location = location.belowbar )
MarketAnalysisLibrary "MarketAnalysis"
A collection of frequently used market analysis functions in my scripts.
bullFibRet(priceLow, priceHigh, fibLevel)
Calculates a bullish fibonacci retracement value.
Parameters:
priceLow (float) : (float) The lowest price point.
priceHigh (float) : (float) The highest price point.
fibLevel (float) : (float) The fibonacci level to calculate.
Returns: The fibonacci value of the given retracement level.
bearFibRet(priceLow, priceHigh, fibLevel)
Calculates a bearish fibonacci retracement value.
Parameters:
priceLow (float) : (float) The lowest price point.
priceHigh (float) : (float) The highest price point.
fibLevel (float) : (float) The fibonacci level to calculate.
Returns: The fibonacci value of the given retracement level.
bullFibExt(priceLow, priceHigh, thirdPivot, fibLevel)
Calculates a bullish fibonacci extension value.
Parameters:
priceLow (float) : (float) The lowest price point.
priceHigh (float) : (float) The highest price point.
thirdPivot (float) : (float) The third price point.
fibLevel (float) : (float) The fibonacci level to calculate.
Returns: The fibonacci value of the given extension level.
bearFibExt(priceLow, priceHigh, thirdPivot, fibLevel)
Calculates a bearish fibonacci extension value.
Parameters:
priceLow (float) : (float) The lowest price point.
priceHigh (float) : (float) The highest price point.
thirdPivot (float) : (float) The third price point.
fibLevel (float) : (float) The fibonacci level to calculate.
Returns: The fibonacci value of the given extension level.
Thuvien_publishLibrary "Thuvien_publish"
Thư viện build Strategy
entry_volume_func(risk, entry, sl)
Hàm tính khối lượng vào lệnh
Parameters:
risk (float)
entry (float)
sl (float)
Returns: entry_volume: trả về khối lượng cần vào
tp_sl_func(sl, entry, rr)
Tính TP/SL theo RR cho trước
Parameters:
sl (float)
entry (float)
rr (float)
Returns: Trả về giá trị Take profit
CryptoLibrary "Crypto"
This Library includes functions related to crytocurrencies and their blockchain
btcBlockReward(t)
Delivers the BTC block reward for a specific date/time
Parameters:
t (int) : Time of the current candle
Returns: blockRewardBtc
MathTransformLibrary "MathTransform"
Auxiliary functions for transforming data using mathematical and statistical methods
scaler_zscore(x, lookback_window)
Calculates Z-Score normalization of a series.
Parameters:
x (float) : : floating point series to normalize
lookback_window (int) : : lookback period for calculating mean and standard deviation
Returns: Z-Score normalized series
scaler_min_max(x, lookback_window, min_val, max_val, empiric_min, empiric_max, empiric_mid)
Performs Min-Max scaling of a series within a given window, user-defined bounds, and optional midpoint
Parameters:
x (float) : : floating point series to transform
lookback_window (int) : : int : optional lookback window size to consider for scaling.
min_val (float) : : float : minimum value of the scaled range. Default is 0.0.
max_val (float) : : float : maximum value of the scaled range. Default is 1.0.
empiric_min (float) : : float : user-defined minimum value of the input data. This means that the output could exceed the `min_val` bound if there is data in `x` lesser than `empiric_min`. If na, it's calculated from `x` and `lookback_window`.
empiric_max (float) : : float : user-defined maximum value of the input data. This means that the output could exceed the `max_val` bound if there is data in `x` greater than `empiric_max`. If na, it's calculated from `x` and `lookback_window`.
empiric_mid (float) : : float : user-defined midpoint value of the input data. If na, it's calculated from `empiric_min` and `empiric_max`.
Returns: rescaled series
log(x, base)
Applies logarithmic transformation to a value, base can be user-defined.
Parameters:
x (float) : : floating point value to transform
base (float) : : logarithmic base, must be greater than 0
Returns: logarithm of the value to the given base, if x <= 0, returns logarithm of 1 to the given base
exp(x, base)
Applies exponential transformation to a value, base can be user-defined.
Parameters:
x (float) : : floating point value to transform
base (float) : : base of the exponentiation, must be greater than 0
Returns: the result of raising the base to the power of the value
power(x, exponent)
Applies power transformation to a value, exponent can be user-defined.
Parameters:
x (float) : : floating point value to transform
exponent (float) : : exponent for the transformation
Returns: the value raised to the given exponent, preserving the sign of the original value
tanh(x, scale)
The hyperbolic tangent is the ratio of the hyperbolic sine and hyperbolic cosine. It limits an output to a range of −1 to 1.
Parameters:
x (float) : : floating point series
scale (float)
sigmoid(x, scale, offset)
Applies the sigmoid function to a series.
Parameters:
x (float) : : floating point series to transform
scale (float) : : scaling factor for the sigmoid function
offset (float) : : offset for the sigmoid function
Returns: transformed series using the sigmoid function
sigmoid_double(x, scale, offset)
Applies a double sigmoid function to a series, handling positive and negative values differently.
Parameters:
x (float) : : floating point series to transform
scale (float) : : scaling factor for the sigmoid function
offset (float) : : offset for the sigmoid function
Returns: transformed series using the double sigmoid function
logistic_decay(a, b, c, t)
Calculates logistic decay based on given parameters.
Parameters:
a (float) : : parameter affecting the steepness of the curve
b (float) : : parameter affecting the direction of the decay
c (float) : : the upper bound of the function's output
t (float) : : time variable
Returns: value of the logistic decay function at time t
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.
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.
Useful_lib_publicLibrary "Useful_lib_public"
Useful functions
CountBarsOfDay()
count bars for one for the diffrent time frames
Returns: number of bars for one day
LastBarsOfDay()
Index number for the las bar for one day
Returns: TRUE is that the last bar from day
isTuesday()
TRUE is tuesday
Returns: TRUE is tuesday else FALSE
Rsi(src, len)
RSI calulation
Parameters:
src (float) : RSI Source
len (simple int) : RSI Length
Returns: RSI Value
CalcIndex(netPos, weeks)
Index calulation
Parameters:
netPos (float) : Source
weeks (simple int) : Length
Returns: "COT Index"
RsiStock(src, len, smoothK)
TRUE is tuesday
Parameters:
src (float)
len (simple int)
smoothK (int)
Returns: RSI Stochastik
Offset()
Use Offset for Day time frame
Returns: Offset
PercentChange(Data, LastData)
Calc different in Percent
Parameters:
Data (float)
LastData (float)
Returns: Change in percent
strategy_helpersThis library is designed to aid traders and developers in calculating risk metrics efficiently across different asset types like equities, futures, and forex. It includes comprehensive functions that calculate the number of units or contracts to trade, the value at risk, and the total value of the position based on provided entry prices, stop levels, and risk percentages. Whether you're managing a portfolio or developing trading strategies, this library provides essential tools for risk management. Functions also automatically select the appropriate risk calculation method based on asset type, calculate leverage levels, and determine potential liquidation points for leveraged positions. Perfect for enhancing the precision and effectiveness of your trading strategies.
Library "strategy_helpers"
Provides tools for calculating risk metrics across different types of trading strategies including equities, futures, and forex. Functions allow for precise control over risk management by calculating the number of units or contracts to trade, the value at risk, and the total position value based on entry prices, stop levels, and desired risk percentage. Additional utilities include automatic risk calculation based on asset type, leverage level calculations, and determination of liquidation levels for leveraged trades.
calculate_risk(entry, stop_level, stop_range, capital, risk_percent, trade_direction, whole_number_buy)
Calculates risk metrics for equity trades based on entry, stop level, and risk percent
Parameters:
entry (float) : The price at which the position is entered. Use close if you arent adding to a position. Use the original entry price if you are adding to a position.
stop_level (float) : The price level where the stop loss is placed
stop_range (float) : The price range from entry to stop level
capital (float) : The total capital available for trading
risk_percent (float) : The percentage of capital risked on the trade. 100% is represented by 100.
trade_direction (bool) : True for long trades, false for short trades
whole_number_buy (bool) : True to adjust the quantity to whole numbers
Returns: A tuple containing the number of units to trade, the value at risk, and the total value of the position:
calculate_risk_futures(risk_capital, stop_range)
Calculates risk metrics for futures trades based on the risk capital and stop range
Parameters:
risk_capital (float) : The capital allocated for the trade
stop_range (float) : The price range from entry to stop level
Returns: A tuple containing the number of contracts to trade, the value at risk, and the total value of the position:
calculate_risk_forex(entry, stop_level, stop_range, capital, risk_percent, trade_direction)
Calculates risk metrics for forex trades based on entry, stop level, and risk percent
Parameters:
entry (float) : The price at which the position is entered. Use close if you arent adding to a position. Use the original entry price if you are adding to a position.
stop_level (float) : The price level where the stop loss is placed
stop_range (float) : The price range from entry to stop level
capital (float) : The total capital available for trading
risk_percent (float) : The percentage of capital risked on the trade. 100% is represented by 100.
trade_direction (bool) : True for long trades, false for short trades
Returns: A tuple containing the number of lots to trade, the value at risk, and the total value of the position:
calculate_risk_auto(entry, stop_level, stop_range, capital, risk_percent, trade_direction, whole_number_buy)
Automatically selects the risk calculation method based on the asset type and calculates risk metrics
Parameters:
entry (float) : The price at which the position is entered. Use close if you arent adding to a position. Use the original entry price if you are adding to a position.
stop_level (float) : The price level where the stop loss is placed
stop_range (float) : The price range from entry to stop level
capital (float) : The total capital available for trading
risk_percent (float) : The percentage of capital risked on the trade. 100% is represented by 100.
trade_direction (bool) : True for long trades, false for short trades
whole_number_buy (bool) : True to adjust the quantity to whole numbers, applicable only for non-futures and non-forex trades
Returns: A tuple containing the number of units or contracts to trade, the value at risk, and the total value of the position:
leverage_level(account_equity, position_value)
Calculates the leverage level used based on account equity and position value
Parameters:
account_equity (float) : Total equity in the trading account
position_value (float) : Total value of the position taken
Returns: The leverage level used in the trade
calculate_liquidation_level(entry, leverage, trade_direction, maintenance_margine)
Calculates the liquidation price level for a leveraged trade
Parameters:
entry (float) : The price at which the position is entered
leverage (float) : The leverage level used in the trade
trade_direction (bool) : True for long trades, false for short trades
maintenance_margine (float) : The maintenance margin requirement, expressed as a percentage
Returns: The price level at which the position would be liquidated, or na if leverage is zero
mathLibrary "math"
It's a library of discrete aproximations of a price or Series float it uses Fourier Discrete transform, Laplace Discrete Original and Modified transform and Euler's Theoreum for Homogenus White noice operations. Calling functions without source value it automatically take close as the default source value.
Here is a picture of Laplace and Fourier approximated close prices from this library:
Copy this indicator and try it yourself:
import AutomatedTradingAlgorithms/math/1 as math
//@version=5
indicator("Close Price with Aproximations", shorttitle="Close and Aproximations", overlay=false)
// Sample input data (replace this with your own data)
inputData = close
// Plot Close Price
plot(inputData, color=color.blue, title="Close Price")
ltf32_result = math.LTF32(a=0.01)
plot(ltf32_result, color=color.green, title="LTF32 Aproximation")
fft_result = math.FFT()
plot(fft_result, color=color.red, title="Fourier Aproximation")
wavelet_result = math.Wavelet()
plot(wavelet_result, color=color.orange, title="Wavelet Aproximation")
wavelet_std_result = math.Wavelet_std()
plot(wavelet_std_result, color=color.yellow, title="Wavelet_std Aproximation")
DFT3(xval, _dir)
Discrete Fourier Transform with last 3 points
Parameters:
xval (float) : Source series
_dir (int) : Direction parameter
Returns: Aproxiated source value
DFT2(xval, _dir)
Discrete Fourier Transform with last 2 points
Parameters:
xval (float) : Source series
_dir (int) : Direction parameter
Returns: Aproxiated source value
FFT(xval)
Fast Fourier Transform once. It aproximates usig last 3 points.
Parameters:
xval (float) : Source series
Returns: Aproxiated source value
DFT32(xval)
Combined Discrete Fourier Transforms of DFT3 and DTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
Parameters:
xval (float) : Source series
Returns: Aproxiated source value
DTF32(xval)
Combined Discrete Fourier Transforms of DFT3 and DTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
Parameters:
xval (float) : Source series
Returns: Aproxiated source value
LFT3(xval, _dir, a)
Discrete Laplace Transform with last 3 points
Parameters:
xval (float) : Source series
_dir (int) : Direction parameter
a (float) : laplace coeficient
Returns: Aproxiated source value
LFT2(xval, _dir, a)
Discrete Laplace Transform with last 2 points
Parameters:
xval (float) : Source series
_dir (int) : Direction parameter
a (float) : laplace coeficient
Returns: Aproxiated source value
LFT(xval, a)
Fast Laplace Transform once. It aproximates usig last 3 points.
Parameters:
xval (float) : Source series
a (float) : laplace coeficient
Returns: Aproxiated source value
LFT32(xval, a)
Combined Discrete Laplace Transforms of LFT3 and LTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
Parameters:
xval (float) : Source series
a (float) : laplace coeficient
Returns: Aproxiated source value
LTF32(xval, a)
Combined Discrete Laplace Transforms of LFT3 and LTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
Parameters:
xval (float) : Source series
a (float) : laplace coeficient
Returns: Aproxiated source value
whitenoise(indic_, _devided, minEmaLength, maxEmaLength, src)
Ehler's Universal Oscillator with White Noise, without extra aproximated src.
It uses dinamic EMA to aproximate indicator and thus reducing noise.
Parameters:
indic_ (float) : Input series for the indicator values to be smoothed
_devided (int) : Divisor for oscillator calculations
minEmaLength (int) : Minimum EMA length
maxEmaLength (int) : Maximum EMA length
src (float) : Source series
Returns: Smoothed indicator value
whitenoise(indic_, dft1, _devided, minEmaLength, maxEmaLength, src)
Ehler's Universal Oscillator with White Noise and DFT1.
It uses src and sproxiated src (dft1) to clearly define white noice.
It uses dinamic EMA to aproximate indicator and thus reducing noise.
Parameters:
indic_ (float) : Input series for the indicator values to be smoothed
dft1 (float) : Aproximated src value for white noice calculation
_devided (int) : Divisor for oscillator calculations
minEmaLength (int) : Minimum EMA length
maxEmaLength (int) : Maximum EMA length
src (float) : Source series
Returns: Smoothed indicator value
smooth(dft1, indic__, _devided, minEmaLength, maxEmaLength, src)
Smoothing source value with help of indicator series and aproximated source value
It uses src and sproxiated src (dft1) to clearly define white noice.
It uses dinamic EMA to aproximate src and thus reducing noise.
Parameters:
dft1 (float) : Value to be smoothed.
indic__ (float) : Optional input for indicator to help smooth dft1 (default is FFT)
_devided (int) : Divisor for smoothing calculations
minEmaLength (int) : Minimum EMA length
maxEmaLength (int) : Maximum EMA length
src (float) : Source series
Returns: Smoothed source (src) series
smooth(indic__, _devided, minEmaLength, maxEmaLength, src)
Smoothing source value with help of indicator series
It uses dinamic EMA to aproximate src and thus reducing noise.
Parameters:
indic__ (float) : Optional input for indicator to help smooth dft1 (default is FFT)
_devided (int) : Divisor for smoothing calculations
minEmaLength (int) : Minimum EMA length
maxEmaLength (int) : Maximum EMA length
src (float) : Source series
Returns: Smoothed src series
vzo_ema(src, len)
Volume Zone Oscillator with EMA smoothing
Parameters:
src (float) : Source series
len (simple int) : Length parameter for EMA
Returns: VZO value
vzo_sma(src, len)
Volume Zone Oscillator with SMA smoothing
Parameters:
src (float) : Source series
len (int) : Length parameter for SMA
Returns: VZO value
vzo_wma(src, len)
Volume Zone Oscillator with WMA smoothing
Parameters:
src (float) : Source series
len (int) : Length parameter for WMA
Returns: VZO value
alma2(series, windowsize, offset, sigma)
Arnaud Legoux Moving Average 2 accepts sigma as series float
Parameters:
series (float) : Input series
windowsize (int) : Size of the moving average window
offset (float) : Offset parameter
sigma (float) : Sigma parameter
Returns: ALMA value
Wavelet(src, len, offset, sigma)
Aproxiates srt using Discrete wavelet transform.
Parameters:
src (float) : Source series
len (int) : Length parameter for ALMA
offset (simple float)
sigma (simple float)
Returns: Wavelet-transformed series
Wavelet_std(src, len, offset, mag)
Aproxiates srt using Discrete wavelet transform with standard deviation as a magnitude.
Parameters:
src (float) : Source series
len (int) : Length parameter for ALMA
offset (float) : Offset parameter for ALMA
mag (int) : Magnitude parameter for standard deviation
Returns: Wavelet-transformed series
LaplaceTransform(xval, N, a)
Original Laplace Transform over N set of close prices
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
Returns: Aproxiated source value
NLaplaceTransform(xval, N, a, repeat)
Y repetirions on Original Laplace Transform over N set of close prices, each time N-k set of close prices
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
repeat (int) : number of repetitions
Returns: Aproxiated source value
LaplaceTransformsum(xval, N, a, b)
Sum of 2 exponent coeficient of Laplace Transform over N set of close prices
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
b (float) : second laplace coeficient
Returns: Aproxiated source value
NLaplaceTransformdiff(xval, N, a, b, repeat)
Difference of 2 exponent coeficient of Laplace Transform over N set of close prices
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
b (float) : second laplace coeficient
repeat (int) : number of repetitions
Returns: Aproxiated source value
N_divLaplaceTransformdiff(xval, N, a, b, repeat)
N repetitions of Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, with dynamic rotation
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
b (float) : second laplace coeficient
repeat (int) : number of repetitions
Returns: Aproxiated source value
LaplaceTransformdiff(xval, N, a, b)
Difference of 2 exponent coeficient of Laplace Transform over N set of close prices
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
b (float) : second laplace coeficient
Returns: Aproxiated source value
NLaplaceTransformdiffFrom2(xval, N, a, b, repeat)
N repetitions of Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, second element has for 1 higher exponent factor
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
b (float) : second laplace coeficient
repeat (int) : number of repetitions
Returns: Aproxiated source value
N_divLaplaceTransformdiffFrom2(xval, N, a, b, repeat)
N repetitions of Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, second element has for 1 higher exponent factor, dynamic rotation
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
b (float) : second laplace coeficient
repeat (int) : number of repetitions
Returns: Aproxiated source value
LaplaceTransformdiffFrom2(xval, N, a, b)
Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, second element has for 1 higher exponent factor
Parameters:
xval (float) : series to aproximate
N (int) : number of close prices in calculations
a (float) : laplace coeficient
b (float) : second laplace coeficient
Returns: Aproxiated source value
Order Block Refiner [TradingFinder]🔵 Introduction
The "Refinement" feature allows you to adjust the width of the order block according to your strategy. There are two modes, "Aggressive" and "Defensive," in the "Order Block Refine". The difference between "Aggressive" and "Defensive" lies in the width of the order block.
For risk-averse traders, the "Defensive" mode is suitable as it provides a lower loss limit and a greater reward-to-risk ratio. For risk-taking traders, the "Aggressive" mode is more appropriate. These traders prefer to enter trades at higher prices, and this mode, which has a wider order block width, is more suitable for this group of individuals.
Important :
One of the advantages of using this library is increased code accuracy. Not only does it have the capability to create order blocks, but you can also simply define the condition for order block creation (true/false) and "bar_index," and you'll find the primary range without applying any filters.
🟣 Order Block Refinement Algorithm
The order block ranges are filtered in two stages. In the first stage, the "Open," "High," "Low," and "Close" of the current order block candle, its two or three previous candles, and one subsequent candle (if available) are examined. In this stage, minimum and maximum distances are calculated, and logical range filters are applied.
In the second stage, two modes, "Aggressive" and "Defensive," are calculated.
For the "Defensive" mode, the width of these ranges is compared with the "ATR" (Average True Range) of period 55, and if they are smaller than "ATR" or 1 to more than 4 times "ATR," the width of the range is reduced from 0 to 80 percent.
For the "Aggressive" mode, you get the same output as the first filter, which usually has a wider width than the "Defensive" mode.
• Order Block Refiner : Off
• Order Block Refiner : On / "Aggressive Mode"
• Order Block Refiner : On / "Defensive Mode"
🔵 How to Use
OBRefiner(string OBType, string OBRefine, string RefineMethod, bool TriggerCondition, int Index) =>
Parameters:
• OBType (string)
• OBRefine (string)
• RefineMethod (string)
• TriggerCondition (bool)
• Index (int)
To add "Order Block Refiner Library", you must first add the following code to your script.
import TFlab/OrderBlockRefiner_TradingFinder/1
OBType : This parameter receives 2 inputs. If the order block you want to "Refine" is of type demand, you should enter "Demand," and if it's of type supply, you should enter "Supply."
OBRefine : Set to "On" if you want the "Refine" operation to be performed. Otherwise, set to "Off."
RefineMethod : This input receives 2 modes, "Aggressive" and "Defensive." You can switch between these modes according to your needs.
TriggerCondition : Enter the condition with which the order block is formed in this parameter.
Index : Enter the "bar_index" of the candle where the order block is formed in this parameter.
🟣 Function Outputs
This function has 6 outputs: "bar_index" at the beginning of the "Distal" line, "bar_index+1" at the end of the "Distal" line, "Price" at the "Distal" line, "bar_index" at the beginning of the "Proximal" line, "bar_index+1" at the end of the "Proximal" line, and "Price" at the "Proximal" line, which can be used to draw order blocks.
Sample :
= Refiner.OBRefiner('Demand', 'Off', 'Aggressive',BuMChMain_Trigger, BuMChMain_Index)
if BuMChMain_Trigger
BuMChHlineMain := line.new(BuMChMain_Xp1 , BuMChMain_Yp12 , bar_index , BuMChMain_Yp12, color = color.black , style = line.style_dotted)
BuMChLlineMain := line.new(BuMChMain_Xd1 , BuMChMain_Yd12 , bar_index , BuMChMain_Yd12, color = color.black , style = line.style_dotted)
BuMChFilineMain := linefill.new(BuMChHlineMain ,BuMChLlineMain , color = color.rgb(76, 175, 80 , 75 ) )