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
Indicators and strategies
InsertionSortLibrary "InsertionSort"
Library of sorting algorithm for binary insertion sort and related methods
method binary_insertion_sort(sortedArray, item, order)
binary insertion sort - inserts item into sorted array while maintaining sort order
Namespace types: array
Parameters:
sortedArray (array) : array which is assumed to be sorted in the requested order
item (float) : float|int item which needs to be inserted into sorted array
order (series ORDER) : Sort order - positive number means ascending order whereas negative number represents descending order
Returns: int index at which the item is inserted into sorted array
method binary_insertion_sort(sortedArray, item, order)
Namespace types: array
Parameters:
sortedArray (array)
item (int)
order (series ORDER)
MyTVBOTLibrary "MyTVBOT"
TODO: add library description here
buy_message(password, amount, order_name)
Make a buy Message for TradingHook.
Parameters:
password (string) : (string) password that you set in .env file.
amount (float) : (float) amount. If not set, your strategy qty will be sent.
order_name (string) : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
sell_message(password, percent, order_name)
Make a sell message for TradingHook.
Parameters:
password (string) : (string) password that you set in .env file.
percent (string) : (string) what percentage of your quantity you want to sell.
order_name (string) : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
entry_message(password, amount, leverage, order_name)
Make a Entry Message for TradingHook.
Parameters:
password (string) : (string) password that you set in .env file.
amount (float) : (float) amount. If not set, your strategy qty will be sent.
leverage (int) : (int) leverage. If not set, your leverage doesn't change.
order_name (string) : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
close_message(password, percent, amount, order_name)
Make a close message for TradingHook.
Parameters:
password (string) : (string) password that you set in .env file.
percent (string) : (string) what percentage of your quantity you want to close.
amount (float) : (float) quantity you want to close.
order_name (string) : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
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 )
MyLibrary001Library "MyLibrary001"
Library for calculating the number of bars in the last X trading days
BarsInLastXDays(numTradingDays)
BarsInLastXDays
@description Calculates the number of bars in the last X trading days
Parameters:
numTradingDays (int) : int Number of trading days to consider
Returns: tuple(float, float) A tuple with the number of bars and the bar duration
ObjectsLibrary "Objects"
A collection of frequently used objects functions in my scripts.
method getType(this)
Identifies an object's type.
Namespace types: series int, simple int, input int, const int
Parameters:
this (int) : Object to inspect.
Returns: A string representation of the type.
method getType(this)
Namespace types: series float, simple float, input float, const float
Parameters:
this (float)
method getType(this)
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
this (bool)
method getType(this)
Namespace types: series color, simple color, input color, const color
Parameters:
this (color)
method getType(this)
Namespace types: series string, simple string, input string, const string
Parameters:
this (string)
method getType(this)
Namespace types: series line
Parameters:
this (line)
method getType(this)
Namespace types: series linefill
Parameters:
this (linefill)
method getType(this)
Namespace types: series box
Parameters:
this (box)
method getType(this)
Namespace types: series polyline, series polyline, series polyline, series polyline
Parameters:
this (polyline)
method getType(this)
Namespace types: series label
Parameters:
this (label)
method getType(this)
Namespace types: series table
Parameters:
this (table)
method getType(this)
Namespace types: chart.point
Parameters:
this (chart.point)
CandleAnalysisLibrary "CandleAnalysis"
A collection of frequently used candle analysis functions in my scripts.
isBullish(barsBack)
Checks if a specific bar is bullish.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar is bullish, otherwise returns false.
isBearish(barsBack)
Checks if a specific bar is bearish.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar is bearish, otherwise returns false.
isBE(barsBack)
Checks if a specific bar is break even.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar is break even, otherwise returns false.
getBodySize(barsBack, inPriceChg)
Calculates a specific candle's body size.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
inPriceChg (bool) : (bool) True to return the body size as a price change value. The default is false (in points).
Returns: The candle's body size in points.
getTopWickSize(barsBack, inPriceChg)
Calculates a specific candle's top wick size.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
inPriceChg (bool) : (bool) True to return the wick size as a price change value. The default is false (in points).
Returns: The candle's top wick size in points.
getBottomWickSize(barsBack, inPriceChg)
Calculates a specific candle's bottom wick size.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
inPriceChg (bool) : (bool) True to return the wick size as a price change value. The default is false (in points).
Returns: The candle's bottom wick size in points.
getBodyPercent(barsBack)
Calculates a specific candle's body size as a percentage of its entire size including its wicks.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: The candle's body size percentage.
isHammer(fib, bullish, barsBack)
Checks if a specific bar is a hammer candle based on a given fibonacci level.
Parameters:
fib (float) : (float) The fibonacci level to base candle's body on. The default is 0.382.
bullish (bool) : (bool) True if the candle must to be green. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a hammer candle, otherwise returns false.
isShootingStar(fib, bearish, barsBack)
Checks if a specific bar is a shooting star candle based on a given fibonacci level.
Parameters:
fib (float) : (float) The fibonacci level to base candle's body on. The default is 0.382.
bearish (bool) : (bool) True if the candle must to be red. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a shooting star candle, otherwise returns false.
isDoji(wickSize, bodySize, barsBack)
Checks if a specific bar is a doji candle based on a given wick and body size.
Parameters:
wickSize (float) : (float) The maximum top wick size compared to the bottom and vice versa. The default is 1.5.
bodySize (float) : (bool) The maximum body size as a percentage compared to the entire candle size. The default is 5.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a doji candle.
isBullishEC(gapTolerance, rejectionWickSize, engulfWick, barsBack)
Checks if a specific bar is a bullish engulfing candle.
Parameters:
gapTolerance (int)
rejectionWickSize (int) : (int) The maximum top wick size compared to the body as a percentage. The default is 10.
engulfWick (bool) : (bool) True if the engulfed candle's wick requires to be engulfed as well. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a bullish engulfing candle.
isBearishEC(gapTolerance, rejectionWickSize, engulfWick, barsBack)
Checks if a specific bar is a bearish engulfing candle.
Parameters:
gapTolerance (int)
rejectionWickSize (int) : (int) The maximum bottom wick size compared to the body as a percentage. The default is 10.
engulfWick (bool) : (bool) True if the engulfed candle's wick requires to be engulfed as well. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a bearish engulfing candle.
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.
MarcosLibraryLibrary "MarcosLibrary"
A colection of frequently used 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.
isBullish(barsBack)
Checks if a specific bar is bullish.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar is bullish, otherwise returns false.
isBearish(barsBack)
Checks if a specific bar is bearish.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar is bearish, otherwise returns false.
isBE(barsBack)
Checks if a specific bar is break even.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar is break even, otherwise returns false.
getBodySize(barsBack, inPriceChg)
Calculates a specific candle's body size.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
inPriceChg (bool) : (bool) True to return the body size as a price change value. The default is false (in points).
Returns: The candle's body size in points.
getTopWickSize(barsBack, inPriceChg)
Calculates a specific candle's top wick size.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
inPriceChg (bool) : (bool) True to return the wick size as a price change value. The default is false (in points).
Returns: The candle's top wick size in points.
getBottomWickSize(barsBack, inPriceChg)
Calculates a specific candle's bottom wick size.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
inPriceChg (bool) : (bool) True to return the wick size as a price change value. The default is false (in points).
Returns: The candle's bottom wick size in points.
getBodyPercent(barsBack)
Calculates a specific candle's body size as a percentage of its entire size including its wicks.
Parameters:
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: The candle's body size percentage.
isHammer(fib, bullish, barsBack)
Checks if a specific bar is a hammer candle based on a given fibonacci level.
Parameters:
fib (float) : (float) The fibonacci level to base candle's body on. The default is 0.382.
bullish (bool) : (bool) True if the candle must to be green. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a hammer candle, otherwise returns false.
isShootingStar(fib, bearish, barsBack)
Checks if a specific bar is a shooting star candle based on a given fibonacci level.
Parameters:
fib (float) : (float) The fibonacci level to base candle's body on. The default is 0.382.
bearish (bool) : (bool) True if the candle must to be red. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a shooting star candle, otherwise returns false.
isDoji(wickSize, bodySize, barsBack)
Checks if a specific bar is a doji candle based on a given wick and body size.
Parameters:
wickSize (float) : (float) The maximum top wick size compared to the bottom and vice versa. The default is 1.5.
bodySize (float) : (bool) The maximum body size as a percentage compared to the entire candle size. The default is 5.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a doji candle.
isBullishEC(gapTolerance, rejectionWickSize, engulfWick, barsBack)
Checks if a specific bar is a bullish engulfing candle.
Parameters:
gapTolerance (int)
rejectionWickSize (int) : (int) The maximum top wick size compared to the body as a percentage. The default is 10.
engulfWick (bool) : (bool) True if the engulfed candle's wick requires to be engulfed as well. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a bullish engulfing candle.
isBearishEC(gapTolerance, rejectionWickSize, engulfWick, barsBack)
Checks if a specific bar is a bearish engulfing candle.
Parameters:
gapTolerance (int)
rejectionWickSize (int) : (int) The maximum bottom wick size compared to the body as a percentage. The default is 10.
engulfWick (bool) : (bool) True if the engulfed candle's wick requires to be engulfed as well. The default is false.
barsBack (int) : (int) The number of bars to look back. The default is 0 (current bar).
Returns: True if the bar matches the requirements of a bearish engulfing candle.
lib_datesLibrary "lib_dates"
TODO: add library description here
inDateRange(from, thru)
inDateRange: Checks if the time `t` is in range between `from` to `thru`
Parameters:
from (int)
thru (int)
Returns: bool: true if time is in range false otherwise
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
Dark & Light Theme [TradingFinder] Switching Colors Library🔵 Introduction
One of the challenges of script users is matching the colors used in indicators or strategies. By default, colors are chosen to display based on either the dark theme or the light theme.
In scripts with a large number of colors used, changing all colors to better display in dark mode or light mode can be a difficult and tedious process.
This library provides developers with the ability to adjust the colors used in their scripts based on the theme of the display.
🔵 Logic
To categorize the color spectrum, the range from 0 to 255 of all three main colors red, green and blue was divided into smaller ranges.
Blue color, which is more effective in darkening or lightening colors, is divided into 8 categories, red color into 5 categories, and green color into 3 categories, because it has little effect on darkening or brightening colors.
The combination of these categories creates 120 different modes for the color range, which leads to a more accurate identification of the color and its brightness, and helps to decide how to change it.
Except for these 120 modes, there are 2 other modes that are related to colors almost white or black, which makes a total of 122 modes.
🔵 How to Use
First, you can add the library to your code as shown in the example below.
import TFlab/Dark_Light_Theme_TradingFinder_Switching_Colors_Library/1 as SC
🟣 Parameters
SwitchingColorMode(Color, Mode) =>
Parameters:
Color (color)
Mode (string)
Color : In this parameter, enter the color you want to adjust based on light mode and dark mode.
Mode : Three modes "Off", "Light" and "Dark" are included in this parameter. "Light" mode is for color adjustment for use in "Light Mode".
"Dark" mode is for color adjustment for use in "Dark Mode" and "Off" mode turns off the color adjustment function and the input color to the function is the same as the output color.
🔵 Function Outputs
OriginalColor = input.color(color.red)
= SC.SwitchingColorMode(OriginalColor, Mode)
VandelayIndicatorLibLibrary "VandelayIndicatorLib"
Art Vandelay's Indicator library
STC_VIL(EEEEEE, BBBB, BBBBB)
Schaff Trend Cycle Calculations
Parameters:
EEEEEE (int) : = Slengt, BBBB = FALenght, BBBBB = SLOLenght
BBBB (simple int)
BBBBB (simple int)
Returns: Long : mAAAAA > mAAAAA - Short : mAAAAA < mAAAAA
stc(source, fast, slow, cycle, d1, d2)
Calculates the value of the Schaff Trend Cycle indicator.
Parameters:
source (float) : (series int/float) Series of values to process.
fast (simple int) : (simple int) Length for the MACD fast smoothing parameter calculation.
slow (simple int) : (simple int) Length for the MACD slow smoothing parameter calculation.
cycle (simple int) : (simple int) Number of bars for the Stochastic values (length).
d1 (simple int) : (simple int) Length for the initial %D smoothing parameter calculation.
d2 (simple int) : (simple int) Length for the final %D smoothing parameter calculation.
Returns: (float) The oscillator value.
ComplexLibrary "Complex"
This library includes user-defined complex type, and functions to perform basic arithmetic operations on complex numbers.
real(radius, angle)
Calculates the real part of a complex number based on its polar coordinates.
Parameters:
radius (float)
angle (float)
imag(radius, angle)
Calculates the imaginary part of a complex number based on its polar coordinates.
Parameters:
radius (float)
angle (float)
rds(real, imag)
Calculates the radius of a complex number based on its cartesian coordinates.
Parameters:
real (float)
imag (float)
ang(real, imag)
Calculates the angle of a complex number based on its cartesian coordinates.
Parameters:
real (float)
imag (float)
method realP(c)
Calculates the real part of a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
method imagP(c)
Calculates the imaginary part of a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
method rdsC(c)
Calculates the radius of a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
method angC(c)
Calculates the angle of a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
method toCart(c)
Converts a complex number from its polar representation to cartesian.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
method toPolar(c)
Converts a complex number from its cartesian representation to polar.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
method addC(c, z)
Calculates the addition of two complex numbers represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in cartesian coordinates.
z (complex) : Second complex number expressed in cartesian coordinates.
method addP(c, z)
Calculates the addition of two complex numbers represented in polar coordinates. Performing addition and subtraction operations in cartesian form of complex numbers is more efficient.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in polar coordinates.
z (complex) : Second complex number expressed in polar coordinates.
method subC(c, z)
Calculates the subtraction of two complex numbers represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in cartesian coordinates.
z (complex) : Second complex number expressed in cartesian coordinates.
method subP(c, z)
Calculates the subtraction of two complex numbers represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in polar coordinates.
z (complex) : Second complex number expressed in polar coordinates.
method multC(c, z)
Calculates the multiplication of two complex numbers represented in cartesian coordinates. Performing multiplication in polar form of complex numbers is more efficient.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in cartesian coordinates.
z (complex) : Second complex number expressed in cartesian coordinates.
method multP(c, z)
Calculates the multiplication of two complex numbers represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in polar coordinates.
z (complex) : Second complex number expressed in polar coordinates.
method powC(c, exp, shift)
Exponentiates a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
exp (float) : The exponent.
shift (float) : The phase shift of the operation. The shift is equal to 2kπ, where k is an integer number from zero to the denominator of the exponent (exclusive). Calculation of the shift value is not included in the function since it isn't always needed and for the purpose of efficiency. Use a for loop to obtain all possible results.
method powP(c, exp, shift)
Exponentiates a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
exp (float) : The exponent.
shift (float) : The phase shift of the operation. The shift is equal to 2kπ, where k is an integer number from zero to the denominator of the exponent (exclusive). Calculation of the shift value is not included in the function since it isn't always needed and for the purpose of efficiency. Use a for loop to obtain all possible results.
method invC(c)
Calculates the multiplicative inverse of a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex)
method invP(c)
Calculates the multiplicative inverse of a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex)
method negC(c)
Negates a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex)
method negP(c)
Negates a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex)
method con(c)
Calculates the conjugate of a complex number in either forms.
Namespace types: complex
Parameters:
c (complex)
method fAddC(c, d)
Calculates the addition of a complex number represented in cartesian coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
d (float)
Returns: The complex number resulted by the addition in cartesian form.
method fAddP(c, d)
Calculates the addition of a complex number represented in polar coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
d (float)
Returns: The complex number resulted by the addition in polar form.
method fMultC(c, d)
Calculates the multiplication of a complex number represented in cartesian coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
d (float)
Returns: The complex number resulted by the multiplication in cartesian form.
method fMultP(c, d)
Calculates the multiplication of a complex number represented in polar coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
d (float)
Returns: The complex number resulted by the multiplication in polar form.
complex
Complex number expressed in polar or cartesian coordinates.
Fields:
R (series float) : Real part or radius of the complex number.
J (series float) : Imaginary part or angle (phase) of the complex number.
iP (series bool) : This field is employed to keep track of the coordinates of the number. Note that the functions do not verify this field for the purpose of efficiency.
lib_session_gapsLibrary "lib_session_gaps"
simple lib to calculate the gaps between sessions
time_gap()
calculates the time gap between this and previous session (in case of irregular end of previous session, considering extended sessions)
Returns: the time gap between this and previous session in ms (time - time_close )
bar_gap()
calculates the bars missing between this and previous session (in case of irregular end of previous session, considering extended sessions)
Returns: the bars virtually missing between this and previous session (time gap / bar size in ms)
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
BinaryLibrary "Binary"
This library includes functions to convert between decimal and binary numeral formats, and logical and arithmetic operations on binary numbers.
method toBin(value)
Converts the provided boolean value into binary integers (0 or 1).
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
value (bool) : The boolean value to be converted.
Returns: The converted value in binary integers.
method dec2bin(value, iBits, fBits)
Converts a decimal number into its binary representation.
Namespace types: series float, simple float, input float, const float
Parameters:
value (float) : The decimal number to be converted.
iBits (int) : The number of binary digits allocated for the integer part.
fBits (int) : The number of binary digits allocated for the fractional part.
Returns: An array containing the binary digits for the integer part at the rightmost positions and the digits for the fractional part at the leftmost positions. The array indexes correspond to the bit positions.
method bin2dec(value, iBits, fBits)
Converts a binary number into its decimal representation.
Namespace types: array
Parameters:
value (array) : The binary number to be converted.
iBits (int) : The number of binary digits allocated for the integer part.
fBits (int) : The number of binary digits allocated for the fractional part.
Returns: The converted value in decimal format.
method lgcAnd(a, b)
Bitwise logical AND of two binary numbers. The result of ANDing two binary digits is 1 only if both digits are 1, otherwise, 0.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical AND of the inputs.
method lgcOr(a, b)
Bitwise logical OR of two binary numbers. The result of ORing two binary digits is 0 only if both digits are 0, otherwise, 1.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical OR of the inputs.
method lgcXor(a, b)
Bitwise logical XOR of two binary numbers. The result of XORing two binary digits is 1 only if ONE of the digits is 1, otherwise, 0.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical XOR of the inputs.
method lgcNand(a, b)
Bitwise logical NAND of two binary numbers. The result of NANDing two binary digits is 0 only if both digits are 1, otherwise, 1.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical NAND of the inputs.
method lgcNor(a, b)
Bitwise logical NOR of two binary numbers. The result of NORing two binary digits is 1 only if both digits are 0, otherwise, 0.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical NOR of the inputs.
method lgcNot(a)
Bitwise logical NOT of a binary number. The result of NOTing a binary digit is 0 if the digit is 1, or vice versa.
Namespace types: array
Parameters:
a (array) : A binary number.
Returns: An array containing the logical NOT of the input.
method lgc2sC(a)
2's complement of a binary number. The 2's complement of a binary number N with n digits is defined as 2^(n) - N.
Namespace types: array
Parameters:
a (array) : A binary number.
Returns: An array containing the 2's complement of the input.
method shift(value, direction, newBit)
Shifts a binary number in the specified direction by one position.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
newBit (int) : The bit to be inserted into the unoccupied slot.
Returns: A tuple of the shifted binary number and the serial output of the shift operation.
method multiShift(value, direction, newBits)
Shifts a binary number in the specified direction by multiple positions.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
newBits (array)
Returns: A tuple of the shifted binary number and the serial output of the shift operation.
method crclrShift(value, direction, count)
Circularly shifts a binary number in the specified direction by multiple positions. Each ejected bit is inserted from the opposite side.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
count (int) : The number of positions to be shifted by.
Returns: The shifted binary number.
method arithmeticShift(value, direction, count)
Performs arithmetic shift on a binary number in the specified direction by multiple positions. Every new bit is 0 if the shift is leftward, otherwise, it equals the sign bit.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
count (int) : The number of positions to be shifted by.
Returns: The shifted binary number.
method add(a, b, carry)
Performs arithmetic addition on two binary numbers.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
carry (int) : The input carry of the operation.
Returns: The result of the arithmetic addition of the inputs.
method sub(a, b, carry)
Performs arithmetic subtraction on two binary numbers.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number. The number to be subtracted.
carry (int) : The input carry of the operation.
Returns: The result of the arithmetic subtraction of the input b from the input a.
ChartUtilsLibrary "ChartUtils"
Library for chart utilities, including managing tables
initTable(rows, cols, bgcolor)
Initializes a table with specific dimensions and color
Parameters:
rows (int) : (int) Number of rows in the table
cols (int) : (int) Number of columns in the table
bgcolor (color) : (color) Background color of the table
Returns: (table) The initialized table
updateTable(tbl, is_price_below_avg, current_investment_USD, strategy_position_size, strategy_position_avg_price, strategy_openprofit, strategy_opentrades, isBullishRate, isBearishRate, mlRSIOverSold, mlRSIOverBought)
Updates the trading table
Parameters:
tbl (table) : (table) The table to update
is_price_below_avg (bool) : (bool) If the current price is below the average price
current_investment_USD (float) : (float) The current investment in USD
strategy_position_size (float) : (float) The size of the current position
strategy_position_avg_price (float) : (float) The average price of the current position
strategy_openprofit (float) : (float) The current open profit
strategy_opentrades (int) : (int) The number of open trades
isBullishRate (bool) : (bool) If the current rate is bullish
isBearishRate (bool) : (bool) If the current rate is bearish
mlRSIOverSold (bool) : (bool) If the ML RSI is oversold
mlRSIOverBought (bool) : (bool) If the ML RSI is overbought
updateTableNoPosition(tbl)
Updates the table when there is no position
Parameters:
tbl (table) : (table) The table to update
TradingUtilsLibrary "TradingUtils"
Utility library for common trading functions
calcVariation(price, threshold)
Calculates variation of a price based on a threshold
Parameters:
price (float) : (float) The price to be varied
threshold (float) : (float) The threshold for the variation
Returns: (float) The varied price
sendAlert(action, symbol, orderType, quantity, message)
Sends an alert message in JSON format
Parameters:
action (string) : (string) The action to be taken (e.g., "BUY", "SELL")
symbol (string) : (string) The trading symbol (e.g., "BTCUSDT")
orderType (string) : (string) The order type (e.g., "MARKET")
quantity (float) : (float) The quantity of the order
message (string) : (string) The message to be included in the alert
updateLine(condition, index, price, lineColor)
Updates or creates a line on the chart
Parameters:
condition (bool) : (bool) Condition to check if the line should be updated or created
index (int) : (int) The current bar index
price (float) : (float) The price value for the line
lineColor (color) : (color) The color of the line
Returns: (line) The updated or newly created line
JohtiLiquidityThis libraray will be provide the liquity points that's will be help to find exact point people going to take trades and it will the most important area
SessionBoxLibrary "SessionBox"
This library provides functions to manage and visualize session boxes and labels on chart. A session box is a visual representation of a trading session with properties like time, name, color and the ability to track the high and low price within that session.
SessionBox
SessionBox: stores session data and provides methods to manage that data and visualize it on the chart.
Fields:
session_time (series bool)
session_name (series string)
session_color (series color)
time_libraryLibrary "time_library"
This library provides utilities for working with time intervals in milliseconds, seconds, minutes, hours, days, and weeks. It includes functions to handle conditions based on time rather than bars.
ms(TIME)
ms - Converts a time period in string format to milliseconds.
Parameters:
TIME (string) : (series ) - The time period ("ms", "s", "m", "h", "d", "w").
Returns: (int) - The corresponding time period in milliseconds.
true_in(timestamp, period, multiplier)
true_in - Checks if the current time has reached a specific time after the given timestamp.
Parameters:
timestamp (int) : (series ) - The starting timestamp.
period (string) : (series |series ) - The period in string format ("ms", "s", "m", "h", "d", "w"), or as an integer in milliseconds.
multiplier (float) : (series ) - Multiplier to extend the period.
Returns: (bool) - True if current time is equal or past the end date calculated from timestamp and period.
true_in(timestamp, period, multiplier)
true_in - Checks if the current time has reached a specific time after the given timestamp.
Parameters:
timestamp (int) : (series ) - The starting timestamp.
period (int) : (series |series ) - The period in string format ("ms", "s", "m", "h", "d", "w"), or as an integer in milliseconds.
multiplier (float) : (series ) - Multiplier to extend the period.
Returns: (bool) - True if current time is equal or past the end date calculated from timestamp and period.
true_after(trigger, period, multiplier)
true_after - Returns true after a specified period multiplied by a multiplier has passed since a trigger was last true.
Parameters:
trigger (bool) : (series ) - The condition that triggers the timer.
period (string) : (series |series ) - The period in string format ("ms", "s", "m", "h", "d", "w"), or as an integer in milliseconds.
multiplier (float) : (series ) - Multiplier to extend the period.
Returns: (bool) - True if the specified time has passed since the last trigger.
true_after(trigger, ms, multiplier)
true_after - Returns true after a specified period multiplied by a multiplier has passed since a trigger was last true.
Parameters:
trigger (bool) : (series ) - The condition that triggers the timer.
ms (int)
multiplier (float) : (series ) - Multiplier to extend the period.
Returns: (bool) - True if the specified time has passed since the last trigger.
MS
MS - Holds common time intervals in milliseconds.
Fields:
ms (series int) : (int) - Milliseconds.
s (series int) : (int) - Seconds converted to milliseconds.
m (series int) : (int) - Minutes converted to milliseconds.
h (series int) : (int) - Hours converted to milliseconds.
d (series int) : (int) - Days converted to milliseconds.
w (series int) : (int) - Weeks converted to milliseconds.
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