analysis
analysis
Modules:
| Name | Description |
|---|---|
movement |
|
patterns |
|
utils |
|
Functions:
| Name | Description |
|---|---|
bars_since |
Bars Since Analysis |
change |
Change Analysis |
cross |
Cross Analysis |
crossover |
Crossover Analysis |
crossunder |
Crossunder Analysis |
doji |
Doji Pattern |
dojistar |
Dojistar Pattern |
falling |
Falling Analysis |
falling_count |
Falling Count Analysis |
hammer |
Hammer Pattern |
highest |
Highest Reading Analysis |
highestbar |
Highest Bar Offset Analysis |
inverted_hammer |
Inverted Hammer Pattern |
lowest |
Lowest Reading Analysis |
lowestbar |
Lowest Bar Offset Analysis |
mean_falling |
Mean Falling Analysis |
mean_rising |
Mean Rising Analysis |
percent_change |
Percent Change Analysis |
rising |
Rising Analysis |
rising_count |
Rising Count Analysis |
value_range |
Value Range Analysis |
value_when |
Value When Analysis |
bars_since
bars_since(
candles: Indicator | Hexital | list[Candle],
indicator: str,
value: float | int | bool = True,
index: int = -1,
) -> int | None
Bars Since Analysis
Returns how many bars ago the given indicator last matched value.
A return value of 0 means the current bar matches. If no match exists,
returns None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The indicator series to scan. |
required |
value
|
float | int | bool
|
The value to match against. Defaults to |
True
|
index
|
int
|
The index to start the backward scan from. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The number of bars since the most recent matching value, |
int | None
|
or |
Source code in hexital/analysis/movement.py
change
change(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 1,
index: int = -1,
) -> float | int | None
Change Analysis
Returns the difference between the current reading and the reading
length bars back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The indicator series to compare. |
required |
length
|
int
|
How many bars back to compare against. Defaults to 1. |
1
|
index
|
int
|
The index to evaluate from. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
float | int | None
|
float | int | None: The current reading minus the reading |
float | int | None
|
or |
Source code in hexital/analysis/movement.py
cross
cross(
candles: Indicator | Hexital | list[Candle],
indicator: str,
indicator_cmp: str,
length: int = 1,
index: int = -1,
) -> bool
Cross Analysis
Determines whether the indicator reading has crossed the indicator_cmp reading
within a specified range of candles. The cross can occur in either direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The primary indicator to evaluate. |
required |
indicator_cmp
|
str
|
The secondary indicator to compare against. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 1. (compares the latest with the previous). |
1
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in hexital/analysis/movement.py
crossover
crossover(
candles: Indicator | Hexital | list[Candle],
indicator: str,
indicator_cmp: str,
length: int = 1,
index: int = -1,
) -> bool
Crossover Analysis
Determines whether the indicator reading has crossed over the indicator_cmp reading
within a specified range of candles. A crossover occurs when indicator transitions from below
to above indicator_cmp within the given range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The primary indicator to evaluate. |
required |
indicator_cmp
|
str
|
The secondary indicator to compare against. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 1.
If |
1
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
bool
|
otherwise |
Source code in hexital/analysis/movement.py
crossunder
crossunder(
candles: Indicator | Hexital | list[Candle],
indicator: str,
indicator_cmp: str,
length: int = 1,
index: int = -1,
) -> bool
Crossunder Analysis
Determines whether the indicator reading has crossed under the indicator_cmp reading
within a specified range of candles. A crossunder occurs when indicator transitions from above
to below indicator_cmp within the given range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The primary indicator to evaluate. |
required |
indicator_cmp
|
str
|
The secondary indicator to compare against. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 1.
If |
1
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
bool
|
otherwise |
Source code in hexital/analysis/movement.py
doji
Doji Pattern A candle body is Doji when it's shorter than 10% of the average of the n(10) previous candles' high-low range.
Source: https://github.com/TA-Lib/ta-lib
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Optional[int]
|
Candles to use to find Doji Candle |
required |
lookback
|
Optional[int]
|
Lookback allows detecting an Doji candles N back. Defaults to None. |
None
|
index
|
Optional[int]
|
Index of Candle to check. Defaults to None/Latest. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if given Candle/Candle range is Doji |
Source code in hexital/analysis/patterns.py
dojistar
Dojistar Pattern A Dojistar is either bearish or bullish, and is detected when we have a larger then average candle followed by a candle candle shorter than 10% of the average of the n(10) of the average and then the candle gaps up or down. A trend is required to find which direction.
Source: https://github.com/TA-Lib/ta-lib Args: candles (Optional[int]): Candles to use to find Dojistar Candle lookback (Optional[int]): Lookback allows detecting an Dojistar candles N back. Defaults to None. index (Optional[int]): Index of Candle to check. Defaults to None/Latest.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if given Candle/Candle range is Doji star |
Source code in hexital/analysis/patterns.py
falling
falling(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 1,
index: int = -1,
) -> bool
Falling Analysis
Determines whether the indicator consistently falling across a specified range of candles.
By default, it checks if the current indicator value is lower than the previous one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 1. (compares the latest with the previous). |
1
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in hexital/analysis/movement.py
falling_count
falling_count(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 100,
index: int = -1,
) -> int
Falling Count Analysis
Counts consecutive falling bars ending at index, up to length
comparisons back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The indicator series to evaluate. |
required |
length
|
int
|
Maximum number of backward comparisons to check. Defaults to 100. |
100
|
index
|
int
|
The index to evaluate from. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of consecutive falling comparisons ending at |
Source code in hexital/analysis/movement.py
hammer
hammer(
candles: list[Candle], lookback: int | None = None, index: int | None = None
) -> bool | int
Hammer Pattern A Hammer is detected when the Candle's open and close values are considered shorter than 10% of the average of the n(10) candles. However the low is larger than the average.
Source: https://github.com/TA-Lib/ta-lib Args: candles (Optional[int]): Candles to use to find Hammer Candle lookback (Optional[int]): Lookback allows detecting an Hammer candles N back. Defaults to None. index (Optional[int]): Index of Candle to check. Defaults to None/Latest.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool | int
|
True if given Candle/Candle range is Hammer |
Source code in hexital/analysis/patterns.py
highest
highest(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 4,
index: int = -1,
) -> float | None
Highest Reading Analysis
Determines the highest value of the specified indicator over a given number of candles.
By default, includes the latest candle and evaluates up to the previous four candles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 4. |
4
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
float | None
|
float | None: The highest reading for the specified |
float | None
|
or |
Source code in hexital/analysis/movement.py
highestbar
highestbar(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 4,
index: int = -1,
) -> int | None
Highest Bar Offset Analysis
Determines the offset (distance) to the candle with the highest reading of the specified indicator
within a given range. By default, includes the latest candle and evaluates up to the previous four candles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 4. |
4
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The offset to the candle with the highest reading, relative to the starting index, |
int | None
|
or |
Source code in hexital/analysis/movement.py
inverted_hammer
inverted_hammer(
candles: list[Candle], lookback: int | None = None, index: int | None = None
) -> bool | int
Inverted Hammer Pattern An Inverted Hammer is detected when the Candle's open and close values are considered shorter than 10% of the average of the n(10) candles. However the high is larger than the average.
Source: https://github.com/TA-Lib/ta-lib Args: candles (Optional[int]): Candles to use to find Inverted Hammer Candle lookback (Optional[int]): Lookback allows detecting an InvertedHammer candles N back. Defaults to None. index (Optional[int]): Index of Candle to check. Defaults to None/Latest.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool | int
|
True if given Candle/Candle range is Inverted Hammer |
Source code in hexital/analysis/patterns.py
lowest
lowest(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 4,
index: int = -1,
) -> float | None
Lowest Reading Analysis
Determines the lowest value of the specified indicator over a given number of candles.
By default, includes the latest candle and evaluates up to the previous four candles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 4. |
4
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
float | None
|
float | None: The lowest reading for the specified |
float | None
|
or |
Source code in hexital/analysis/movement.py
lowestbar
lowestbar(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 4,
index: int = -1,
) -> int | None
Lowest Bar Offset Analysis
Determines the offset (distance) to the candle with the lowest reading of the specified indicator
within a given range. By default, includes the latest candle and evaluates up to the previous four candles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 4. |
4
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The offset to the candle with the lowest reading, relative to the starting index, |
int | None
|
or |
Source code in hexital/analysis/movement.py
mean_falling
mean_falling(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 4,
index: int = -1,
) -> bool
Mean Falling Analysis
Evaluates whether the indicator is, on average, falling across a specified range of candles.
By default, it checks if the current indicator value is lower than the average of the previous four readings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 4. |
4
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in hexital/analysis/movement.py
mean_rising
mean_rising(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 4,
index: int = -1,
) -> bool
Mean Rising Analysis
Evaluates whether the indicator is, on average, rising across a specified range of candles.
By default, it checks if the current indicator value is higher than the average of the previous four readings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 4. |
4
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in hexital/analysis/movement.py
percent_change
percent_change(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 1,
index: int = -1,
) -> float | None
Percent Change Analysis
Returns the percentage change between the current reading and the reading
length bars back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The indicator series to compare. |
required |
length
|
int
|
How many bars back to compare against. Defaults to 1. |
1
|
index
|
int
|
The index to evaluate from. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
float | None
|
float | None: The percentage change from the reading |
float | None
|
current reading, or |
Source code in hexital/analysis/movement.py
rising
rising(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 1,
index: int = -1,
) -> bool
Rising Analysis
Determines whether the indicator consistently rises across a specified range of candles.
By default, it checks if the current indicator value is greater than the previous one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 1. (compares the latest with the previous). |
1
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in hexital/analysis/movement.py
rising_count
rising_count(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 100,
index: int = -1,
) -> int
Rising Count Analysis
Counts consecutive rising bars ending at index, up to length
comparisons back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The indicator series to evaluate. |
required |
length
|
int
|
Maximum number of backward comparisons to check. Defaults to 100. |
100
|
index
|
int
|
The index to evaluate from. Defaults to -1 (latest candle). |
-1
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of consecutive rising comparisons ending at |
Source code in hexital/analysis/movement.py
value_range
value_range(
candles: Indicator | Hexital | list[Candle],
indicator: str,
length: int = 4,
index: int = -1,
) -> float | None
Value Range Analysis
Calculates the difference between the minimum and maximum values for the given indicator
within a specified range of candles. Includes the latest candle by default. If the specified
length exceeds the available candles, it will evaluate all candles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
indicator
|
str
|
The name of the indicator to evaluate. |
required |
length
|
int
|
The number of candles to include in the range. Defaults to 4. |
4
|
index
|
int
|
The index to start the evaluation. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
float | None
|
float | None: The difference between the minimum and maximum indicator values in the range, |
float | None
|
or |
Source code in hexital/analysis/movement.py
value_when
value_when(
candles: Indicator | Hexital | list[Candle],
condition_indicator: str,
indicator: str,
value: float | int | bool = True,
occurrence: int = 0,
index: int = -1,
) -> float | dict | None
Value When Analysis
Returns the indicator reading from the nth most recent bar where
condition_indicator matched value. occurrence=0 means the latest match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candles
|
Indicator | Hexital | List[Candle]
|
The data source containing the indicators. |
required |
condition_indicator
|
str
|
The indicator series used as the condition. |
required |
indicator
|
str
|
The indicator reading to return when the condition matches. |
required |
value
|
float | int | bool
|
The value the condition indicator must equal.
Defaults to |
True
|
occurrence
|
int
|
Which matching occurrence to return, where |
0
|
index
|
int
|
The index to start the backward scan from. Defaults to -1 (latest candle). |
-1
|
Returns:
| Type | Description |
|---|---|
float | dict | None
|
float | dict | None: The reading of |
float | dict | None
|
or |