Ultimate Oscillator (ULTOSC)The Ultimate Oscillator (ULTOSC) is a technical momentum indicator developed by Larry Williams that combines three different time periods to reduce the volatility and false signals common in single-period oscillators. By using a weighted average of three Stochastic-like calculations across short, medium, and long-term periods, the Ultimate Oscillator provides a more comprehensive view of market momentum while maintaining sensitivity to price changes.
The indicator addresses the common problem of oscillators being either too sensitive (generating many false signals) or too slow (missing opportunities). By incorporating multiple timeframes with decreasing weights for longer periods, ULTOSC attempts to capture both short-term momentum shifts and longer-term trend strength, making it particularly valuable for identifying divergences and potential reversal points.
## Core Concepts
* **Multi-timeframe analysis:** Combines three different periods (typically 7, 14, 28) to capture various momentum cycles
* **Weighted averaging:** Assigns higher weights to shorter periods for responsiveness while including longer periods for stability
* **Buying pressure focus:** Measures the relationship between closing price and the true range rather than just high-low range
* **Divergence detection:** Particularly effective at identifying momentum divergences that precede price reversals
* **Normalized scale:** Oscillates between 0 and 100, with clear overbought/oversold levels
## Common Settings and Parameters
| Parameter | Default | Function | When to Adjust |
|-----------|---------|----------|---------------|
| Fast Period | 7 | Short-term momentum calculation | Lower (5-6) for more sensitivity, higher (9-12) for smoother signals |
| Medium Period | 14 | Medium-term momentum calculation | Adjust based on typical swing duration in the market |
| Slow Period | 28 | Long-term momentum calculation | Higher values (35-42) for longer-term position trading |
| Fast Weight | 4.0 | Weight applied to fast period | Higher weight increases short-term sensitivity |
| Medium Weight | 2.0 | Weight applied to medium period | Adjust to balance medium-term influence |
| Slow Weight | 1.0 | Weight applied to slow period | Usually kept at 1.0 as the baseline weight |
**Pro Tip:** The classic 7/14/28 periods with 4/2/1 weights work well for most markets, but consider using 5/10/20 with adjusted weights for faster markets or 14/28/56 for longer-term analysis.
## Calculation and Mathematical Foundation
**Simplified explanation:**
The Ultimate Oscillator calculates three separate "buying pressure" ratios using different time periods, then combines them using weighted averaging. Buying pressure is defined as the close minus the true low, divided by the true range.
**Technical formula:**
```
BP = Close - Min(Low, Previous Close)
TR = Max(High, Previous Close) - Min(Low, Previous Close)
BP_Sum_Fast = Sum(BP, Fast Period)
TR_Sum_Fast = Sum(TR, Fast Period)
Raw_Fast = 100 × (BP_Sum_Fast / TR_Sum_Fast)
BP_Sum_Medium = Sum(BP, Medium Period)
TR_Sum_Medium = Sum(TR, Medium Period)
Raw_Medium = 100 × (BP_Sum_Medium / TR_Sum_Medium)
BP_Sum_Slow = Sum(BP, Slow Period)
TR_Sum_Slow = Sum(TR, Slow Period)
Raw_Slow = 100 × (BP_Sum_Slow / TR_Sum_Slow)
ULTOSC = 100 × / (Fast_Weight + Medium_Weight + Slow_Weight)
```
Where:
- BP = Buying Pressure
- TR = True Range
- Fast Period = 7, Medium Period = 14, Slow Period = 28 (defaults)
- Fast Weight = 4, Medium Weight = 2, Slow Weight = 1 (defaults)
> 🔍 **Technical Note:** The implementation uses efficient circular buffers for all three period calculations, maintaining O(1) time complexity per bar. The algorithm properly handles true range calculations including gaps and ensures accurate buying pressure measurements across all timeframes.
## Interpretation Details
ULTOSC provides several analytical perspectives:
* **Overbought/Oversold conditions:** Values above 70 suggest overbought conditions, below 30 suggest oversold conditions
* **Momentum direction:** Rising ULTOSC indicates increasing buying pressure, falling indicates increasing selling pressure
* **Divergence analysis:** Divergences between ULTOSC and price often precede significant reversals
* **Trend confirmation:** ULTOSC direction can confirm or question the prevailing price trend
* **Signal quality:** Extreme readings (>80 or <20) indicate strong momentum that may be unsustainable
* **Multiple timeframe consensus:** When all three underlying periods agree, signals are typically more reliable
## Trading Applications
**Primary Uses:**
- **Divergence trading:** Identify when momentum diverges from price for reversal signals
- **Overbought/oversold identification:** Find potential entry/exit points at extreme levels
- **Trend confirmation:** Validate breakouts and trend continuations
- **Momentum analysis:** Assess the strength of current price movements
**Advanced Strategies:**
- **Multi-divergence confirmation:** Look for divergences across multiple timeframes
- **Momentum breakouts:** Trade when ULTOSC breaks above/below key levels with volume
- **Swing trading entries:** Use oversold/overbought levels for swing position entries
- **Trend strength assessment:** Evaluate trend quality using momentum consistency
## Signal Combinations
**Strong Bullish Signals:**
- ULTOSC rises from oversold territory (<30) with positive price divergence
- ULTOSC breaks above 50 after forming a base near 30
- All three underlying periods show increasing buying pressure
**Strong Bearish Signals:**
- ULTOSC falls from overbought territory (>70) with negative price divergence
- ULTOSC breaks below 50 after forming a top near 70
- All three underlying periods show decreasing buying pressure
**Divergence Signals:**
- **Bullish divergence:** Price makes lower lows while ULTOSC makes higher lows
- **Bearish divergence:** Price makes higher highs while ULTOSC makes lower highs
- **Hidden bullish divergence:** Price makes higher lows while ULTOSC makes lower lows (trend continuation)
- **Hidden bearish divergence:** Price makes lower highs while ULTOSC makes higher highs (trend continuation)
## Comparison with Related Oscillators
| Indicator | Periods | Focus | Best Use Case |
|-----------|---------|-------|---------------|
| **Ultimate Oscillator** | 3 periods | Buying pressure | Divergence detection |
| **Stochastic** | 1-2 periods | Price position | Overbought/oversold |
| **RSI** | 1 period | Price momentum | Momentum analysis |
| **Williams %R** | 1 period | Price position | Short-term signals |
## Advanced Configurations
**Fast Trading Setup:**
- Fast: 5, Medium: 10, Slow: 20
- Weights: 4/2/1, Thresholds: 75/25
**Standard Setup:**
- Fast: 7, Medium: 14, Slow: 28
- Weights: 4/2/1, Thresholds: 70/30
**Conservative Setup:**
- Fast: 14, Medium: 28, Slow: 56
- Weights: 3/2/1, Thresholds: 65/35
**Divergence Focused:**
- Fast: 7, Medium: 14, Slow: 28
- Weights: 2/2/2, Thresholds: 70/30
## Market-Specific Adjustments
**Volatile Markets:**
- Use longer periods (10/20/40) to reduce noise
- Consider higher threshold levels (75/25)
- Focus on extreme readings for signal quality
**Trending Markets:**
- Emphasize divergence analysis over absolute levels
- Look for momentum confirmation rather than reversal signals
- Use hidden divergences for trend continuation
**Range-Bound Markets:**
- Standard overbought/oversold levels work well
- Trade reversals from extreme levels
- Combine with support/resistance analysis
## Limitations and Considerations
* **Lagging component:** Contains inherent lag due to multiple moving average calculations
* **Complex calculation:** More computationally intensive than single-period oscillators
* **Parameter sensitivity:** Performance varies significantly with different period/weight combinations
* **Market dependency:** Most effective in trending markets with clear momentum patterns
* **False divergences:** Not all divergences lead to significant price reversals
* **Whipsaw potential:** Can generate conflicting signals in choppy markets
## Best Practices
**Effective Usage:**
- Focus on divergences rather than absolute overbought/oversold levels
- Combine with trend analysis for context
- Use multiple timeframe analysis for confirmation
- Pay attention to the speed of momentum changes
**Common Mistakes:**
- Over-relying on overbought/oversold levels in strong trends
- Ignoring the underlying trend direction
- Using inappropriate period settings for the market being analyzed
- Trading every divergence without additional confirmation
**Signal Enhancement:**
- Combine with volume analysis for confirmation
- Use price action context (support/resistance levels)
- Consider market volatility when setting thresholds
- Look for convergence across multiple momentum indicators
## Historical Context and Development
The Ultimate Oscillator was developed by Larry Williams and introduced in his 1985 article "The Ultimate Oscillator" in Technical Analysis of Stocks and Commodities magazine. Williams designed it to address the limitations of single-period oscillators by:
- Reducing false signals through multi-timeframe analysis
- Maintaining sensitivity to short-term momentum changes
- Providing more reliable divergence signals
- Creating a more robust momentum measurement tool
The indicator has become a standard tool in technical analysis, particularly valued for its divergence detection capabilities and its balanced approach to momentum measurement.
## References
* Williams, L. R. (1985). The Ultimate Oscillator. Technical Analysis of Stocks and Commodities, 3(4).
* Williams, L. R. (1999). Long-Term Secrets to Short-Term Trading. Wiley Trading.
Penunjuk dan strategi
Standardization (Z-score)Standardization, often referred to as Z-score normalization, is a data preprocessing technique that rescales data to have a mean of 0 and a standard deviation of 1. The resulting values, known as Z-scores, indicate how many standard deviations an individual data point is from the mean of the dataset (or a rolling sample of it).
This indicator calculates and plots the Z-score for a given input series over a specified lookback period. It is a fundamental tool for statistical analysis, outlier detection, and preparing data for certain machine learning algorithms.
## Core Concepts
* **Standardization:** The process of transforming data to fit a standard normal distribution (or more generally, to have a mean of 0 and standard deviation of 1).
* **Z-score (Standard Score):** A dimensionless quantity that represents the number of standard deviations by which a data point deviates from the mean of its sample.
The formula for a Z-score is:
`Z = (x - μ) / σ`
Where:
* `x` is the individual data point (e.g., current value of the source series).
* `μ` (mu) is the mean of the sample (calculated over the lookback period).
* `σ` (sigma) is the standard deviation of the sample (calculated over the lookback period).
* **Mean (μ):** The average value of the data points in the sample.
* **Standard Deviation (σ):** A measure of the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean, while a high standard deviation indicates that the values are spread out over a wider range.
## Common Settings and Parameters
| Parameter | Type | Default | Function | When to Adjust |
| :-------------- | :----------- | :------ | :------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Source | series float | close | The input data series (e.g., price, volume, indicator values). | Choose the series you want to standardize. |
| Lookback Period | int | 20 | The number of bars (sample size) used for calculating the mean (μ) and standard deviation (σ). Min 2. | A larger period provides more stable estimates of μ and σ but will be less responsive to recent changes. A shorter period is more reactive. `minval` is 2 because `ta.stdev` requires it. |
**Pro Tip:** Z-scores are excellent for identifying anomalies or extreme values. For instance, applying Standardization to trading volume can help quickly spot days with unusually high or low activity relative to the recent norm (e.g., Z-score > 2 or < -2).
## Calculation and Mathematical Foundation
The Z-score is calculated for each bar as follows, using a rolling window defined by the `Lookback Period`:
1. **Calculate Mean (μ):** The simple moving average (`ta.sma`) of the `Source` data over the specified `Lookback Period` is calculated. This serves as the sample mean `μ`.
`μ = ta.sma(Source, Lookback Period)`
2. **Calculate Standard Deviation (σ):** The standard deviation (`ta.stdev`) of the `Source` data over the same `Lookback Period` is calculated. This serves as the sample standard deviation `σ`.
`σ = ta.stdev(Source, Lookback Period)`
3. **Calculate Z-score:**
* If `σ > 0`: The Z-score is calculated using the formula:
`Z = (Current Source Value - μ) / σ`
* If `σ = 0`: This implies all values in the lookback window are identical (and equal to the mean). In this case, the Z-score is defined as 0, as the current source value is also equal to the mean.
* If `σ` is `na` (e.g., insufficient data in the lookback period), the Z-score is `na`.
> 🔍 **Technical Note:**
> * The `Lookback Period` must be at least 2 for `ta.stdev` to compute a valid standard deviation.
> * The Z-score calculation uses the sample mean and sample standard deviation from the rolling lookback window.
## Interpreting the Z-score
* **Magnitude and Sign:**
* A Z-score of **0** means the data point is identical to the sample mean.
* A **positive Z-score** indicates the data point is above the sample mean. For example, Z = 1 means the point is 1 standard deviation above the mean.
* A **negative Z-score** indicates the data point is below the sample mean. For example, Z = -1 means the point is 1 standard deviation below the mean.
* **Typical Range:** For data that is approximately normally distributed (bell-shaped curve):
* About 68% of Z-scores fall between -1 and +1.
* About 95% of Z-scores fall between -2 and +2.
* About 99.7% of Z-scores fall between -3 and +3.
* **Outlier Detection:** Z-scores significantly outside the -2 to +2 range, and especially outside -3 to +3, are often considered outliers or extreme values relative to the recent historical data in the lookback window.
* **Volatility Indication:** When applied to price, large absolute Z-scores can indicate moments of high volatility or significant deviation from the recent price trend.
The indicator plots horizontal lines at ±1, ±2, and ±3 standard deviations to help visualize these common thresholds.
## Common Applications
1. **Outlier Detection:** Identifying data points that are unusual or extreme compared to the rest of the sample. This is a primary use in financial markets for spotting abnormal price moves, volume spikes, etc.
2. **Comparative Analysis:** Allows for comparison of scores from different distributions that might have different means and standard deviations. For example, comparing the Z-score of returns for two different assets.
3. **Feature Scaling in Machine Learning:** Standardizing features to have a mean of 0 and standard deviation of 1 is a common preprocessing step for many machine learning algorithms (e.g., SVMs, logistic regression, neural networks) to improve performance and convergence.
4. **Creating Normalized Oscillators:** The Z-score itself can be used as a bounded (though not strictly between -1 and +1) oscillator, indicating how far the current price has deviated from its moving average in terms of standard deviations.
5. **Statistical Process Control:** Used in quality control charts to monitor if a process is within expected statistical limits.
## Limitations and Considerations
* **Assumption of Normality for Probabilistic Interpretation:** While Z-scores can always be calculated, the probabilistic interpretations (e.g., "68% of data within ±1σ") strictly apply to normally distributed data. Financial data is often not perfectly normal (e.g., it can have fat tails).
* **Sensitivity of Mean and Standard Deviation to Outliers:** The sample mean (μ) and standard deviation (σ) used in the Z-score calculation can themselves be influenced by extreme outliers within the lookback period. This can sometimes mask or exaggerate the Z-score of other points.
* **Choice of Lookback Period:** The Z-score is highly dependent on the `Lookback Period`. A short period makes it very sensitive to recent fluctuations, while a long period makes it smoother and less responsive. The appropriate period depends on the analytical goal.
* **Stationarity:** For time series data, Z-scores are calculated based on a rolling window. This implicitly assumes some level of local stationarity (i.e., the mean and standard deviation are relatively stable within the window).
Mirpapa_Lib_StochasticLibrary "Mirpapa_Lib_Stochastic"
스토캐스틱 4Wave 계산 및 플롯을 위한 라이브러리
hma(src, len)
Hull Moving Average
Parameters:
src (float) : 소스 데이터
len (int) : 길이
Returns: HMA 값
ehma(src, len)
Exponential Hull Moving Average
Parameters:
src (float) : 소스 데이터
len (simple int) : 길이
Returns: EHMA 값
thma(src, len)
Triangular Hull Moving Average
Parameters:
src (float) : 소스 데이터
len (int) : 길이
Returns: THMA 값
ma(src, len, mode)
통합 이동평균 함수
Parameters:
src (float) : 소스 데이터
len (simple int) : 길이
mode (string) : 이동평균 타입 ("SMA", "EMA", "WMA", "RMA", "HMA", "EHMA", "THMA")
Returns: 선택된 이동평균 값
calcStochastic(periodK, smoothK, periodD, maMode, src)
스토캐스틱 %K, %D 계산
Parameters:
periodK (int) : %K 길이 (Stochastic 기간)
smoothK (simple int) : %K 스무딩
periodD (simple int) : %D 스무딩
maMode (string) : 이동평균 타입
src (float) : 소스 데이터 (기본값: close)
Returns:
getLineColor(d, baseColor, transp)
라인 색상 계산
Parameters:
d (float) : %D 값
baseColor (color) : 기본 색상
transp (int) : 투명도
Returns: 계산된 색상
getFillColor(d, baseColor, transUp, transDown)
Fill 색상 계산
Parameters:
d (float) : %D 값
baseColor (color) : 기본 색상
transUp (int) : 상승 투명도
transDown (int) : 하락 투명도
Returns: 계산된 fill 색상
isOverbought(d, level)
과매수 체크
Parameters:
d (float) : %D 값
level (float) : 과매수 레벨 (기본 80)
Returns: 과매수 여부
isOversold(d, level)
과매도 체크
Parameters:
d (float) : %D 값
level (float) : 과매도 레벨 (기본 20)
Returns: 과매도 여부
calcStochWithColors(periodK, smoothK, periodD, maMode, baseColor, src, transUp, transDown, lineTrans, levelHigh, levelLow)
스토캐스틱 완전 계산 (모든 데이터 반환)
Parameters:
periodK (int) : %K 길이
smoothK (simple int) : %K 스무딩
periodD (simple int) : %D 스무딩
maMode (string) : 이동평균 타입
baseColor (color) : 기본 색상
src (float) : 소스 데이터 (기본값: close)
transUp (int) : 상승 투명도
transDown (int) : 하락 투명도
lineTrans (int) : 라인 투명도
levelHigh (float) : 과매수 레벨
levelLow (float) : 과매도 레벨
Returns: StochData 구조체
calc_smma(src, len)
SMMA (Smoothed Moving Average) 계산
Parameters:
src (float) : 소스 데이터
len (simple int) : 길이
Returns: SMMA 값
calc_zlema(src, length)
ZLEMA (Zero Lag EMA) 계산
Parameters:
src (float) : 소스 데이터
length (simple int) : 길이
Returns: ZLEMA 값
checkMacdCross(lengthMA, lengthSignal, src)
MACD 크로스오버 체크
Parameters:
lengthMA (simple int) : MACD 길이
lengthSignal (int) : 시그널 길이
src (float) : 소스 (기본값: hlc3)
Returns:
StochData
스토캐스틱 데이터 구조체
Fields:
k (series float) : %K 값
d (series float) : %D 값
lineColor (series color) : 라인 색상
fillColor (series color) : Fill 색상
overbought (series bool) : 과매수 여부
oversold (series bool) : 과매도 여부
Multi-Session Viewer and AnalyzerFully customizable multi-session viewer that takes session analysis to the next level. It allows you to fully customize each session to your liking. Includes a feature that highlights certain periods of time on the chart and a Time Range Marker.
It helps you analyze the instrument that you trade and pinpoint which times are more volatile than others. It also helps you choose the best time to trade your instrument and align your life schedule with the market.
NZDUSD Example:
- 3 major sessions displayed.
- Although this is NZDUSD, Sydney is not the best time to trade this pair. Volatility picks up at Tokyo open.
- I have time to trade in the evening from 18:00 to 22:00 PST. I live in a different time zone, whereas market is based on EST. How does the pair behave during the time I am available to trade based on my time zone? Time Range Marker feature allows you to see this clearly on the chart (black lines).
- I have some time in the morning to trade during New York session, but there is no way I am waking up at 05:00 PST. 06:30 PST seems doable. Blue highlighted area is good time to trade during New York session based on what Bob said. It seem like this aligns with when I am available and when I am able to trade. Volatility is also at its peak.
- I am also available to trade between London close and Tokyo open on some days of the week, but... based on what I see, green highlighted area is clearly showing that I probably don't want to waste my time trading this pair from London close and until Tokyo open. I will use this time for something else rather than be stuck in a range.
Obj_XABCD_HarmonicLibrary "Obj_XABCD_Harmonic"
Harmonic XABCD Pattern object and associated methods. Easily validate, draw, and get information about harmonic patterns. See example code at the end of the script for details.
init_params(pct_error, pct_asym, types, w_e, w_p, w_d)
Create a harmonic parameters object (used by xabcd_harmonic object for pattern validation and scoring).
Parameters:
pct_error (float) : Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (float) : Allowed leg length/period asymmetry % (a leg is considered invalid if it is this % longer or shorter than the average length of the other legs)
types (array) : Array of pattern types to validate (1=Gartley, 2=Bat, 3=Butterfly, 4=Crab, 5=Shark, 6=Cypher)
w_e (float) : Weight of ratio % error (used in score calculation, dft = 1)
w_p (float) : Weight of PRZ confluence (used in score calculation, dft = 1)
w_d (float) : Weight of Point D / PRZ confluence (used in score calculation, dft = 1)
Returns: harmonic_params object instance. It is recommended to store and reuse this object for multiple xabcd_harmonic objects rather than creating new params objects unnecessarily.
init(x, a, b, c, d, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of points
If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your
own validation and scoring parameters, you can do so by passing a harmonic_params object (params).
Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp)
and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish
to re-initialize it (e.g. for re-validation and/or re-scoring).
Parameters:
x (point type from dlmysolutions/Pattern/1) : Point X
a (point type from dlmysolutions/Pattern/1) : Point A
b (point type from dlmysolutions/Pattern/1) : Point B
c (point type from dlmysolutions/Pattern/1) : Point C
d (point type from dlmysolutions/Pattern/1) : Point D
params (harmonic_params) : harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int) : Pattern type
p (xabcd_harmonic) : xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
init(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of x and y coordinate values.
If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your
own validation and scoring parameters, you can do so by passing a harmonic_params object (params).
Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp)
and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish
to re-initialize it (e.g. for re-validation and/or re-scoring).
Parameters:
xX (int) : Point X bar index (required)
xY (float) : Point X price/level (required)
aX (int) : Point A bar index (required)
aY (float) : Point A price/level (required)
bX (int) : Point B bar index (required)
bY (float) : Point B price/level (required)
cX (int) : Point C bar index (required)
cY (float) : Point C price/level (required)
dX (int) : Point D bar index
dY (float) : Point D price/level
params (harmonic_params) : harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int) : Pattern type
p (xabcd_harmonic) : xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
init(pattern, params, tp, p)
Initialize an xabcd_harmonic object instance from a given pattern
If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your
own validation and scoring parameters, you can do so by passing a harmonic_params object (params).
Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp)
and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish
to re-initialize it (e.g. for re-validation and/or re-scoring).
Parameters:
pattern (pattern type from dlmysolutions/Pattern/1) : Pattern
params (harmonic_params) : harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int) : Pattern type
p (xabcd_harmonic) : xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
method get_name(p)
Get the pattern name
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: Pattern name (string)
method get_symbol(p)
Get the pattern symbol
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: Pattern symbol (1 byte string)
method get_pid(p)
Get the Pattern ID. Patterns of the same type with the same coordinates will have the same Pattern ID.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: Pattern ID (string)
method set_target(p, target, target_lvl, calc_target)
Set value for a target. Use the calc_target parameter to automatically calculate the target for a specific harmonic ratio.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
target (int) : Target (1 or 2)
target_lvl (float) : Target price/level (required if calc_target is not specified)
calc_target (string) : Target to auto calculate (required if target is not specified)
Options:
Returns: Target price/level (float)
method erase_pattern(p)
Erase the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: p
method draw_pattern(p, clr)
Draw the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
clr (color)
Returns: Pattern lines
method erase_label(p)
Erase the pattern label
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: p
method draw_label(p, clr, txt_clr, txt, tooltip)
Draw the pattern label. Default text is the pattern name.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
clr (color) : Label color
txt_clr (color) : Text color
txt (string) : Label text
tooltip (string) : Tooltip text
Returns: Label
harmonic_params
Validation and scoring parameters for a Harmonic Pattern object (xabcd_harmonic)
Fields:
pct_error (series float) : Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (series float)
types (array)
w_e (series float)
w_p (series float)
w_d (series float)
xabcd_harmonic
Harmonic Pattern object
Fields:
bull (series bool) : Bullish pattern flag
tp (series int)
x (point type from dlmysolutions/Pattern/1)
a (point type from dlmysolutions/Pattern/1)
b (point type from dlmysolutions/Pattern/1)
c (point type from dlmysolutions/Pattern/1)
d (point type from dlmysolutions/Pattern/1)
r_xb (series float)
re_xb (series float)
r_ac (series float)
re_ac (series float)
r_bd (series float)
re_bd (series float)
r_xd (series float)
re_xd (series float)
score (series float)
score_eAvg (series float)
score_prz (series float)
score_eD (series float)
prz_bN (series float)
prz_bF (series float)
prz_xN (series float)
prz_xF (series float)
t1Hit (series bool) : Target 1 flag
t1 (series float)
t2Hit (series bool)
t2 (series float)
sHit (series bool) : Stop flag
stop (series float) : Stop level
entry (series float) : Entry level
eHit (series bool)
e (point type from dlmysolutions/Pattern/1)
invalid_d (series bool)
pLines (array)
pLabel (series label)
pid (series string)
params (harmonic_params)
PatternLibrary "Pattern"
Pattern object definitions and functions. Easily draw and keep track of patterns, legs, and points.
Supported pattern types:
Type Leg validation # legs
"xabcd" Direction 3 or 4 (point D not required)
"zigzag" Direction >= 2
"free" None >= 2
Summary of exported types and associated methods/functions:
type point A point on the chart (x,y)
draw_label() Draw a point label
erase_label() Erase a point label
type leg A pattern leg (i.e. point A to point B)
leg_init() Initialize/instantiate a leg
draw() Draw a leg
erase() Erase a leg
leg_getLineTerms() Get the slope and y-intercept of a leg
leg_getPrice() Get price (Y) at a given bar index (X) within a leg
type pattern A pattern (set of at least 2 connected legs)
pattern_init() Initialize/instantiate a pattern
draw() Draw a pattern
erase() Erase a pattern
*See bottom of the script for example usage*
erase_label(this)
Delete the point label
Parameters:
this (point) : Point
Returns: Void
draw_label(this, position, clr, transp, txt_clr, txt, tooltip, size)
Draw the point label
Parameters:
this (point) : Point
position (string)
clr (color)
transp (float)
txt_clr (color)
txt (string)
tooltip (string)
size (string)
Returns: line
leg_init(a, b, prev, next, line)
Initialize a pattern leg
Parameters:
a (point) : Point A (required)
b (point) : Point B (required)
prev (leg) : Previous leg
next (leg) : Next leg
line (line) : Line
Returns: New instance of leg object
erase(this)
Delete the pattern leg
Parameters:
this (leg) : Leg
Returns: Void
erase(this)
Delete the pattern lines
Parameters:
this (pattern) : Pattern
Returns: Void
draw(this, clr, style, transp, width)
Draw the pattern leg
Parameters:
this (leg) : Leg
clr (color) : Color
style (string) : Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float) : Transparency
width (int) : Width
Returns: line
draw(this, clr, style, transp, width)
Draw the pattern
Parameters:
this (pattern) : Pattern
clr (color) : Color
style (string) : Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float) : Transparency
width (int) : Width
Returns: line
leg_getLineTerms(this)
Get the slope and y-intercept of a leg
Parameters:
this (leg) : Leg
Returns:
leg_getPrice(this, index)
Get the price (Y) at a given bar index (X) within the leg
Parameters:
this (leg) : Leg
index (int) : Bar index
Returns: Price (float)
pattern_init(legs, tp, name, subType, pid)
Initialize a pattern object from a given set of legs
Parameters:
legs (array) : Array of pattern legs (required)
tp (string) : Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string) : Pattern name
subType (string) : Pattern subtype
pid (string) : Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
pattern_init(points, tp, name, subType, pid)
Initialize a pattern object from a given set of points
Parameters:
points (array)
tp (string) : Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string) : Pattern name
subType (string) : Pattern subtype
pid (string) : Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
point
A point on the chart (x,y)
Fields:
x (series int) : Bar index (x coordinate)
y (series float)
label (series label)
leg
A pattern leg (point A to point B)
Fields:
a (point) : Point A
b (point)
deltaX (series int)
deltaY (series float)
prev (leg)
next (leg)
retrace (series float)
line (series line)
pattern
A pattern (set of at least 2 connected legs)
Fields:
legs (array)
type (series string)
subType (series string)
name (series string)
pid (series string)
DrawLibrary "Draw"
Draw patterns, lines, labels, shapes etc.
pat_colors(bull, buLn, beLn, ltxt)
Parameters:
bull (bool)
buLn (color)
beLn (color)
ltxt (color)
size(size)
Parameters:
size (string)
label_style(style)
Parameters:
style (string)
line_style(style)
Parameters:
style (string)
font_size(size)
Parameters:
size (string)
xabcd(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, iE, bull, bu, be)
Draw XABCD pattern
Parameters:
xX (int)
xY (float)
aX (int)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dX (int)
dY (float)
iE (float)
bull (bool)
bu (color)
be (color)
xabcd_inProgress(bull, type, tLimit, entry, stop, t1, t2, bcNt, bcFt, xaNt, xaFt, xX, xY, aY, bX, bY, cY, dX, dY, cBu, cBe, lTxt)
draw PRZ, entry, stop, targets, and projected reversal paths for XABCD pattern
Parameters:
bull (bool)
type (int)
tLimit (int)
entry (float)
stop (float)
t1 (float)
t2 (float)
bcNt (float)
bcFt (float)
xaNt (float)
xaFt (float)
xX (int)
xY (float)
aY (float)
bX (int)
bY (float)
cY (float)
dX (int)
dY (float)
cBu (color)
cBe (color)
lTxt (color)
xabcd_incInProgress(bull, type, tLimit, entry, xX, xY, aY, bX, bY, cX, cY, dY, cBu, cBe, lTxt)
Parameters:
bull (bool)
type (int)
tLimit (int)
entry (float)
xX (int)
xY (float)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dY (float)
cBu (color)
cBe (color)
lTxt (color)
xabcd_inProgress2(bull, tLimit, entry, stop, t1, t2, xadl, bcdl, xcdl, xX, xY, bX, bY, dX, dY, cBu, cBe, lTxt)
draw PRZ, entry, stop, targets, and projected reversal paths for XABCD pattern
Parameters:
bull (bool)
tLimit (int)
entry (float)
stop (float)
t1 (float)
t2 (float)
xadl (float)
bcdl (float)
xcdl (float)
xX (int)
xY (float)
bX (int)
bY (float)
dX (int)
dY (float)
cBu (color)
cBe (color)
lTxt (color)
eHitLbl(x, e, dX, dY, bull, lOnly)
Draw entry hit label
Parameters:
x (int)
e (float)
dX (int)
dY (float)
bull (bool)
lOnly (bool)
tHitLbl(x, tgt, eX, eY, bull)
Draw target hit label
Parameters:
x (int)
tgt (float)
eX (int)
eY (float)
bull (bool)
sHitLbl(x, s, eX, eY, bull)
Draw stop hit label
Parameters:
x (int)
s (float)
eX (int)
eY (float)
bull (bool)
level(y, x, type, length, extend, padding, b_style, colr, txt_color, txt, txt_loc, txt_size)
Draw a level (box)
Parameters:
y (float)
x (int)
type (int)
length (int)
extend (string)
padding (float)
b_style (string)
colr (color)
txt_color (color)
txt (string)
txt_loc (string)
txt_size (string)
incTtTxt(tp, name, xbr, xbre, acr, acre, bcN, bcF, xaN, xaF, score, e)
Parameters:
tp (int)
name (string)
xbr (float)
xbre (float)
acr (float)
acre (float)
bcN (float)
bcF (float)
xaN (float)
xaF (float)
score (float)
e (float)
TALibrary "TA"
General technical analysis functions
div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW)
Test for bullish divergence
Parameters:
pS (float) : Price series (float)
iS (float) : Indicator series (float)
cp_length_after (simple int) : Bars after current (divergent) pivot low to be considered a valid pivot (optional int)
cp_length_before (simple int) : Bars before current (divergent) pivot low to be considered a valid pivot (optional int)
pivot_length (simple int) : Bars before and after prior pivot low to be considered valid pivot (optional int)
lookback (simple int) : Bars back to search for prior pivot low (optional int)
lookback_pivs (simple int) : Pivots back to search for prior pivot low (optional int)
no_broken (simple bool) : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW (simple float) : Weight of change in price, used in degree of divergence calculation (optional float)
iW (simple float) : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW (simple float) : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW (simple float) : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
div_bear(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW)
Test for bearish divergence
Parameters:
pS (float) : Price series (float)
iS (float) : Indicator series (float)
cp_length_after (simple int) : Bars after current (divergent) pivot high to be considered a valid pivot (optional int)
cp_length_before (simple int) : Bars before current (divergent) pivot highto be considered a valid pivot (optional int)
pivot_length (simple int) : Bars before and after prior pivot high to be considered valid pivot (optional int)
lookback (simple int) : Bars back to search for prior pivot high (optional int)
lookback_pivs (simple int) : Pivots back to search for prior pivot high (optional int)
no_broken (simple bool) : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW (simple float) : Weight of change in price, used in degree of divergence calculation (optional float)
iW (simple float) : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW (simple float) : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW (simple float) : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
test_cd(cd, bc, xa, xc, ad, pErr, p_types)
Validate CD leg of XABCD
Parameters:
cd (float)
bc (float)
xa (float)
xc (float)
ad (float)
pErr (float)
p_types (array)
pat_xabcd_testSym(xax, abx, bcx, cdx, pAsym)
Validate ΔX symmetry of XABCD pattern
Parameters:
xax (int)
abx (int)
bcx (int)
cdx (int)
pAsym (float)
harmonic_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, pErr, pAsym, gart, bat, bfly, crab, shark, cyph)
Validate harmonic XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
dX (int) : X coordinate of point D (int)
dY (float) : Y coordinate of point D (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
gart (bool) : Flag to validate Gartley pattern (bool)
bat (bool) : Flag to validate Bat pattern (bool)
bfly (bool) : Flag to validate Butterfly pattern (bool)
crab (bool) : Flag to validate Crab pattern (bool)
shark (bool) : Flag to validate Shark pattern (bool)
cyph (bool) : Flag to validate Cypher pattern (bool)
Returns:
flag = true if valid harmonic
t1 = true if valid gartley
t2 = true if valid bat
t3 = true if valid butterfly
t4 = true if valid crab
t5 = true if valid shark
t6 = true if valid cypher
harmonic_xabcd_validateIncomplete(xX, xY, aX, aY, bX, bY, cX, cY, pErr, pAsym, gart, bat, bfly, crab, shark, cyph)
Validate the first 3 legs of a harmonic XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
gart (bool) : Flag to validate Gartley pattern (bool)
bat (bool) : Flag to validate Bat pattern (bool)
bfly (bool) : Flag to validate Butterfly pattern (bool)
crab (bool) : Flag to validate Crab pattern (bool)
shark (bool) : Flag to validate Shark pattern (bool)
cyph (bool) : Flag to validate Cypher pattern (bool)
Returns:
flag = true if valid harmonic
t1 = true if valid gartley
t2 = true if valid bat
t3 = true if valid butterfly
t4 = true if valid crab
t5 = true if valid shark
t6 = true if valid cypher
harmonic_xabcd_prz(type, xY, aY, bY, cY)
Get the potential reversal zone (PRZ) levels of a harmonic XABCD pattern
Parameters:
type (int) : Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab, 5 = Shark, 6 = Cypher)
xY (float) : Y coordinate of point X (float)
aY (float) : Y coordinate of point A (float)
bY (float) : Y coordinate of point B (float)
cY (float) : Y coordinate of point C (float)
Returns:
bc_u = nearest BC retracement/extension level (nearest to point C)
bc_l = farthest BC retracement/extension level (nearest to point C)
xa_u = nearest XA retracement/extension level (or the only XA level, if applicable)
xa_l = farthest XA retracement/extension level (or na if not applicable)
harmonic_xabcd_przClosest(l1, l2, l3, l4)
Get the confluent PRZ levels (i.e. the two closest PRZ levels)
Order of arguments does not matter
Parameters:
l1 (float) : level 1 (float)
l2 (float) : level 2 (float)
l3 (float) : level 3 (float)
l4 (float) : level 4 (optional, float)
Returns:
lL = lower confluent PRZ level
lH = higher confluent PRZ level
harmonic_xabcd_przRange(l1, l2, l3, l4)
Get upper and lower PRZ levels
Parameters:
l1 (float)
l2 (float)
l3 (float)
l4 (float)
harmonic_xabcd_eD(cpl1, cpl2, xY, aY, dY)
Measure closeness of D to either of the two closest PRZ levels, relative to height of the XA leg
Parameters:
cpl1 (float)
cpl2 (float)
xY (float)
aY (float)
dY (float)
harmonic_xabcd_przScore(xY, aY, l1, l2, l3, l4)
Measure the closeness of the two closest PRZ levels, relative to the height of the XA leg
Parameters:
xY (float)
aY (float)
l1 (float)
l2 (float)
l3 (float)
l4 (float)
harmonic_xabcd_rAndE(type, l, l1, l2)
Get the ratio of two pattern legs, and the percent error from the theoretical harmonic ratio
Order of arguments does not matter
Parameters:
type (int) : Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab)
l (string) : Leg ID ("xab", "abc", "bcd", or "xad") (string)
l1 (float) : Line 1 height (float)
l2 (float) : Line 2 height (float)
Returns:
harmonic_xabcd_eAvg(xbre, acre, bdre, xdre, xcdre)
Get the avg retracement ratio % error
Parameters:
xbre (float)
acre (float)
bdre (float)
xdre (float)
xcdre (float)
pat_xabcd_asym(xX, aX, bX, cX, dX)
Get the avg asymmetry %
Parameters:
xX (int)
aX (int)
bX (int)
cX (int)
dX (int)
harmonic_xabcd_entry(t, tp, xY, aY, bY, cY, dY, e_afterC, e_lvlc, e_afterD, e_lvldPct)
Get potential entry levels for a harmonic XABCD pattern
Parameters:
t (bool)
tp (int)
xY (float)
aY (float)
bY (float)
cY (float)
dY (float)
e_afterC (bool)
e_lvlc (string)
e_afterD (bool)
e_lvldPct (float)
xabcd_entryHit(t, afterC, afterD, dX, e_afterC, e_afterD, dValBars)
Determine if entry level was reached. Assumes pattern is active/not timed out.
Parameters:
t (bool)
afterC (float)
afterD (float)
dX (int)
e_afterC (bool)
e_afterD (bool)
dValBars (int)
pat_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, xab, abc, bcd, xad, xcd, pErr, pAsym)
Validate custom XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
dX (int) : X coordinate of point D (int)
dY (float) : Y coordinate of point D (float)
xab (float)
abc (float)
bcd (float)
xad (float)
xcd (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
Returns: TRUE if pattern is valid
pat_xabcd_validateIncomplete(xX, xY, aX, aY, bX, bY, cX, cY, xab, abc, pErr, pAsym)
Validate the first 3 legs of a custom XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
xab (float)
abc (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
Returns: TRUE if first 3 legs are valid
pat_xabcd_prz(xY, aY, bY, cY, xad, bcd, xcd)
Get the potential reversal zone (PRZ) levels of a custom XABCD pattern
Parameters:
xY (float) : Y coordinate of point X (float)
aY (float) : Y coordinate of point A (float)
bY (float) : Y coordinate of point B (float)
cY (float) : Y coordinate of point C (float)
xad (float)
bcd (float)
xcd (float)
Returns:
pat_xabcd_avgDev(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY)
Get the average deviation of an XABCD pattern
Parameters:
xX (int)
xY (float)
aX (int)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dX (int)
dY (float)
harmonic_xabcd_score(tp, xX, xY, aX, aY, bX, bY, cX, cY, dX, dY)
Get score values for a pattern
Parameters:
tp (int)
xX (int)
xY (float)
aX (int)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dX (int)
dY (float)
harmonic_xabcd_scoreTot(asym, eavg, przscore, eD, tp, w_a, w_e, w_p, w_d)
Get total weighted score value for a pattern
Parameters:
asym (float)
eavg (float)
przscore (float)
eD (float)
tp (int)
w_a (float)
w_e (float)
w_p (float)
w_d (float)
harmonic_xabcd_targets(xY, aY, bY, cY, dY, tgt1, tgt2, tgt3)
Get target level
Parameters:
xY (float)
aY (float)
bY (float)
cY (float)
dY (float)
tgt1 (string)
tgt2 (string)
tgt3 (string)
harmonic_xabcd_stop(stop, stopPct, bull, xY, dY, upper, lower, t1, eY)
Get stop level
Parameters:
stop (string)
stopPct (float)
bull (bool)
xY (float)
dY (float)
upper (float)
lower (float)
t1 (float)
eY (float)
harmonic_xabcd_fibDispTxt(tp)
Get fib ratio display text
Parameters:
tp (int)
harmonic_xabcd_symbol(tp)
Get pattern symbol
Parameters:
tp (int)
pat_xabcd(x_is_low, pivot_length, source, conf_length, incomplete)
Determine if an XABCD pattern has just completed (i.e. point D is on the previous bar)
Parameters:
x_is_low (bool) : Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true)
pivot_length (int) : Number of bars before and after a valid pivot (int, dft = 5)
source (float) : Source series (float, dft = na, will use high and low series)
conf_length (int) : Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1)
incomplete (bool) : Flag to return an incomplete XABC pattern (bool, dft = false)
Returns:
flag = true if valid XABCD pattern completed on previous bar
xx = X coordinate of point X (int)
xy = Y coordinate of point X (float)
ax = X coordinate of point A (int)
ay = Y coordinate of point A (float)
bx = X coordinate of point B (int)
by = Y coordinate of point B (float)
cx = X coordinate of point C (int)
cy = Y coordinate of point C (float)
dx = X coordinate of point D (int)
dy = Y coordinate of point D (float)
pat_xabcdIncomplete(x_is_low, pivot_length, source, conf_length)
Determine if an XABCD pattern is in progress (point C was just confirmed)
Parameters:
x_is_low (bool) : Flag to determine if point X is a low pivot, i.e. bullish M pattern (bool, dft = true)
pivot_length (int) : Number of bars before and after a valid pivot (int, dft = 5)
source (float) : Source series (float, dft = na, will use high and low series)
conf_length (int) : Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1)
Returns:
flag = true if valid XABC pattern completed on bar_index
xx = X coordinate of point X (int)
xy = Y coordinate of point X (float)
ax = X coordinate of point A (int)
ay = Y coordinate of point A (float)
bx = X coordinate of point B (int)
by = Y coordinate of point B (float)
cx = X coordinate of point C (int)
cy = Y coordinate of point C (float)
dx = X coordinate of point D (int)
dy = Y coordinate of point D (float)
success(eX, stop, t1, t2)
Determine if trade is successful
Parameters:
eX (int) : Entry bar index (int)
stop (float) : Stop level (float)
t1 (float) : Target 1 level (float)
t2 (float) : Target 2 level (float)
Returns:
tradeClosed(eX, eY, stop, t1h, t2h, t1, t2)
Determine if Target or Stop was hit on the current bar
Parameters:
eX (int)
eY (float)
stop (float)
t1h (bool)
t2h (bool)
t1 (float)
t2 (float)
TrigLibrary "Trig"
Trigonometric functions
rt_get_angleAlpha(a, b, c, deg)
Get angle α of a right triangle, given the lengths of its sides
Parameters:
a (float) : length of leg a (float)
b (float) : length of leg b (float)
c (float) : length of hypotenuse (float)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle α in radians (or degrees if deg == true)
rt_get_angleAlphaFromLine(x1, y1, x2, y2, l, deg)
Get angle α of a right triangle formed by the given line
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, and y2 agruments are not specified)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle α in radians (or degrees if deg == true)
rt_get_angleBeta(a, b, c, deg)
Get angle β of a right triangle, given the lengths of its sides
Parameters:
a (float) : length of leg a (float)
b (float) : length of leg b (float)
c (float) : length of hypotenuse (float)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle β in radians (or degrees if deg == true)
rt_get_angleBetaFromLine(x1, y1, x2, y2, l, deg)
Get angle β of a right triangle formed by the given line
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, and y2 agruments are not specified)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle β in radians (or degrees if deg == true)
AlgebraLibrary "Algebra"
line_fromXy(x1, y1, x2, y2)
Get line slope and y-intercept from coordinates
Parameters:
x1 (int) : x coordinate 1 (int - bar index)
y1 (float) : y coordinate 1 (float - price/value)
x2 (int) : x coordinate 2 (int - bar index)
y2 (float) : y coordinate 2 (float - price/value)
Returns: of line
line_getPrice(x, slope, yInt)
Get price at X coordinate, given line slope and y-intercept
Parameters:
x (int) : x coordinate to solve for y (int - bar index)
slope (float) : slope of line (float)
yInt (float) : y-intercept of line (float)
Returns: y (price/value)
line_getPrice_fromXy(x, x1, y1, x2, y2)
Get price at X coordinate, given two points on a line
Parameters:
x (int) : x coordinate to solve for y (int - bar index)
x1 (int) : x coordinate 1 (int - bar index)
y1 (float) : y coordinate 1 (float - price/value)
x2 (int) : x coordinate 2 (int - bar index)
y2 (float) : y coordinate 2 (float - price/value)
Returns: y (price/value)
line_getRtSides(x1, y1, x2, y2, l)
Get length of sides of a right triangle formed by a given line
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, y2 agruments are not specified)
Returns:
line_length(x1, y1, x2, y2, l)
Get length of line, given a line object or two sets of coordinates
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, y2 agruments are not specified)
Returns: length of line (float)
FibonacciLibrary "Fibonacci"
General Fibonacci functions. Get fib numbers, ratios, etc.
fib_derived(f, precision)
Get the precise Fibonacci ratio, to the specified number of decimal places
Parameters:
f (float) : Fibonacci ratio (string, in form #.###)
precision (simple int) : Number of decimal places (optional int, dft = 16, max = 32)
Returns: Precise Fibonacci ratio (float)
* Deprecated (use fib_precise() instead), but keeping it here for science / experimenting with derivations
fib_precise(f, precision)
Get the precise Fibonacci ratio, to the specified number of decimal places
Parameters:
f (float) : Fibonacci ratio (string, in form #.###)
precision (simple int) : Number of decimal places (optional int, dft = 16, max = 16)
Returns: Precise Fibonacci ratio (float)
fib_from_string(r)
Get fib ratio value from string
Parameters:
r (string) : Fib ratio string (e.g. ".618")
Returns: Fibonacci ratio value (float)
fib_n(n)
Calculate the Nth number in the Fibonacci sequence
Parameters:
n (int) : Index/number in sequence (int)
Returns: Fibonacci number (int)
UtilitiesLibrary "Utilities"
General utilities
print_series(s, skip_na, position, show_index, from_index, to_index)
Print series values
Parameters:
s (string) : Series (string)
skip_na (simple bool) : Flag to skip na values (optional bool, dft = false)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
show_index (simple bool) : Flag to show series indices (optional bool, dft = true)
from_index (int) : First index to print (optional int, dft = 0)
to_index (int) : Last index to print (optional int, dft = last_bar_index)
Returns: Table object, if series was printed
print(v, position, at_index)
Print value
Parameters:
v (string) : Value (string)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
print(v, position, at_index)
Print value
Parameters:
v (int) : Value (int)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
print(v, position, at_index)
Print value
Parameters:
v (float) : Value (float)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
print(v, position, at_index)
Print value
Parameters:
v (bool) : Value (bool)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
boolToIntArr(a)
return array of offsets (int) of true values
Parameters:
a (array)
intToBoolArr(a, n)
Parameters:
a (array)
n (int)
ارتداد من القاع فلتر ارتداد من القاع مع ملاحظة انه يعمل كتنبيه في القائمة
Bottom bounce filter, note that it works as an alert in the menu
EV/FCFThis script in the 6 version of Pine brings you the most accurate multiple of "fundamental valuation" in my opinion. EV/FCF gives you a real metric of how profitable is the company in this exact moment and also if the company is overvaluated or undervaluated.
Macros Kill Zones Fusionadas (:20 - :40) / :50 - :10)//@version=6
indicator("Macros Kill Zones Fusionadas (:20 - :40) / :50 - :10)", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=500)
// =======================
// === CONFIGURACIÓN ===
showLines = input.bool(true, "Mostrar líneas verticales")
showShading = input.bool(false, "Sombreado opcional")
shadeColor = input.color(color.new(color.gray, 85), "Color sombreado")
lineColor = color.new(color.gray, 50)
lineWidth = input.int(1, "Grosor líneas", 1, 3)
lookbackBars = input.int(200, "Lookback", 20, 2000)
// Calcular extremos del gráfico
ht = ta.highest(high, lookbackBars)
lt = ta.lowest(low, lookbackBars)
yTop = ht * 1.02
yBot = lt * 0.98
// Hora local en minutos
local_min = hour * 60 + minute
// =======================
// === MACROS ACTIVAS POR DEFECTO ===
m0 = input.bool(false,"12:20am a 12:40am")
m1 = input.bool(false,"1:20am a 1:40am")
m2 = input.bool(true, "2:20am a 2:40am")
m3 = input.bool(true, "3:20am a 3:40am")
m4 = input.bool(true, "4:20am a 4:40am")
m5 = input.bool(false,"5:20am a 5:40am")
m6 = input.bool(false,"6:20am a 6:40am")
m7 = input.bool(true, "7:20am a 7:40am")
m8 = input.bool(true, "8:20am a 8:40am")
m9 = input.bool(true, "9:20am a 9:40am")
m10 = input.bool(true, "10:20am a 10:40am")
m11 = input.bool(false,"11:20am a 11:40am")
m12 = input.bool(false,"12:20pm a 12:40pm")
m13 = input.bool(false,"1:20pm a 1:40pm")
m14 = input.bool(false,"2:20pm a 2:40pm")
m15 = input.bool(false,"3:20pm a 3:40pm")
m16 = input.bool(false,"4:20pm a 4:40pm")
m17 = input.bool(false,"5:20pm a 5:40pm")
m18 = input.bool(false,"6:20pm a 6:40pm")
m19 = input.bool(false,"7:20pm a 7:40pm")
m20 = input.bool(false,"8:20pm a 8:40pm")
m21 = input.bool(false,"9:20pm a 9:40pm")
m22 = input.bool(false,"10:20pm a 10:40pm")
m23 = input.bool(false,"11:20pm a 11:40pm")
// =======================
// === FUNCIÓN DE DIBUJO AJUSTADA ===
f_drawLines(on, startHour) =>
startMin = startHour * 60 + 20
endMin = startHour * 60 + 40
inRange = local_min >= startMin and local_min <= endMin // incluir minuto :40
if on and showLines
if local_min == startMin or local_min == endMin // dibujar línea exacta inicio y fin
line.new(bar_index, yTop, bar_index, yBot, xloc=xloc.bar_index, color=lineColor, width=lineWidth)
inRange
// =======================
// === CHEQUEO DE MACROS ACTIVAS ===
in_any_macro = f_drawLines(m0,0) or f_drawLines(m1,1) or f_drawLines(m2,2) or f_drawLines(m3,3) or
f_drawLines(m4,4) or f_drawLines(m5,5) or f_drawLines(m6,6) or f_drawLines(m7,7) or
f_drawLines(m8,8) or f_drawLines(m9,9) or f_drawLines(m10,10) or f_drawLines(m11,11) or
f_drawLines(m12,12) or f_drawLines(m13,13) or f_drawLines(m14,14) or f_drawLines(m15,15) or
f_drawLines(m16,16) or f_drawLines(m17,17) or f_drawLines(m18,18) or f_drawLines(m19,19) or
f_drawLines(m20,20) or f_drawLines(m21,21) or f_drawLines(m22,22) or f_drawLines(m23,23)
// =======================
// === SOMBREADO OPCIONAL ===
bgcolor(showShading and in_any_macro ? shadeColor : na)
// =======================
// === INDICADOR 2: Macro :50 - :10 ===
// =======================
//#region
var line EXT = array.new_line()
var label LBL = array.new_label()
oneDayMS = 86400000
oneBarMS = time_close - time
noColor = color.new(#ffffff, 100)
// Ajuste de línea sobre vela
one = ta.highest(timeframe.in_seconds("15") / timeframe.in_seconds(timeframe.period)) + syminfo.mintick * 10
y_btm_Line1 = one
y_top_Line1 = one + syminfo.mintick * 5
//#region
_macroC = input.color(color.new(color.gray, 60), title="Macro Color", inline='main')
_mode = input.string("On Chart", title="", inline='main', options= )
_showL = input.bool(true, title="Macro Label?", inline='sh')
_mTxt = input.bool(true, title="Show Time?", inline='sh')
_extt = input.bool(false, title="Macro Projections?", inline='sh')
_bgm = input.color(color.new(#4caf50, 70), title="Macro Color", inline='bc')
//#endregion
//#region
time_isMacro(int H_start, int M_start, int H_end, int M_end) =>
h = hour(time, "America/New_York")
m = minute(time, "America/New_York")
h == H_start ? (H_start != H_end ? m >= M_start : m >= M_start and m < M_end) : (h > H_start ? (h == H_end ? m < M_end : h < H_end) : false)
_controlMacroLine(line _lines, label _lbl, bool _time) =>
if _time
_lbl.last().set_x(math.round(math.avg(_lines.get(_lines.size() - 2).get_x1(), time)))
if high > _lines.last().get_y2() - syminfo.mintick * 10
_lines.get(_lines.size() - 2).set_y2(high + (syminfo.mintick * 10))
_lines.last().set_y1(high + (syminfo.mintick * 10))
_lines.last().set_y2(high + (syminfo.mintick * 10))
LBL.last().set_y(high + (syminfo.mintick * 10))
if na(_lines.last().get_x2()) or _lines.last().get_x2() == time
_lines.last().set_x2(time + oneBarMS)
method memoryCleanLine(line A) =>
if A.size() > 300
for i = 0 to 3
A.shift().delete()
method memoryCleanLabel(label A) =>
if A.size() > 100
A.shift().delete()
macroOC(line LINES, bool _time, string _kzTime, bool _friday) =>
dly = _friday ? oneDayMS * 3 : oneDayMS
_txt = _mTxt ? _kzTime : ""
if not _time and _time
_vline1 = line.new(time, y_btm_Line1, time, y_top_Line1, xloc=xloc.bar_time, color=_macroC, width=1)
LINES.push(_vline1)
_hline = line.new(time, y_top_Line1, time + oneBarMS, y_top_Line1, xloc=xloc.bar_time, color=_macroC, width=1)
LINES.push(_hline)
if _extt
EXT.push(line.new(time, high, time, _vline1.get_y2(), xloc=xloc.bar_time, color=_macroC, style=line.style_dotted))
if _mode == "On Chart"
LBL.push(label.new(time,
LINES.get(LINES.size() - 2).get_y2(),
_showL ? _txt : "",
xloc=xloc.bar_time,
style=label.style_label_down,
color=noColor,
textcolor=_macroC,
size=size.small))
if _time and not _time and LINES.size() > 0
_vline2 = line.new(time, y_btm_Line1, time, y_top_Line1, xloc=xloc.bar_time, color=_macroC, width=1)
LBL.last().set_x(math.round(math.avg(LINES.get(LINES.size() - 2).get_x1(), time)))
if y_top_Line1 > LINES.get(LINES.size() - 2).get_y2()
LINES.get(LINES.size() - 2).set_y2(y_top_Line1)
LINES.last().set_y1(y_top_Line1)
LINES.last().set_y2(y_top_Line1)
LBL.last().set_y(y_top_Line1)
else if y_top_Line1 < LINES.get(LINES.size() - 2).get_y2()
_vline2.set_y2(LINES.get(LINES.size() - 2).get_y2())
if _extt
EXT.push(line.new(time, high, time, _vline2.get_y2(), xloc=xloc.bar_time, color=_macroC, style=line.style_dotted))
LINES.push(_vline2)
if LINES.size() > 0 and LBL.size() > 0
_controlMacroLine(LINES, LBL, _time)
//#endregion
//#region
// Declaración de los 24 intervalos cronológicos
var line _LINES1 = array.new_line()
var line _LINES2 = array.new_line()
var line _LINES3 = array.new_line()
var line _LINES4 = array.new_line()
var line _LINES5 = array.new_line()
var line _LINES6 = array.new_line()
var line _LINES7 = array.new_line()
var line _LINES8 = array.new_line()
var line _LINES9 = array.new_line()
var line _LINES10 = array.new_line()
var line _LINES11 = array.new_line()
var line _LINES12 = array.new_line()
var line _LINES13 = array.new_line()
var line _LINES14 = array.new_line()
var line _LINES15 = array.new_line()
var line _LINES16 = array.new_line()
var line _LINES17 = array.new_line()
var line _LINES18 = array.new_line()
var line _LINES19 = array.new_line()
var line _LINES20 = array.new_line()
var line _LINES21 = array.new_line()
var line _LINES22 = array.new_line()
var line _LINES23 = array.new_line()
var line _LINES24 = array.new_line()
// Inputs de activación
show1 = input.bool(false, title="00:50 - 01:10")
show2 = input.bool(false, title="01:50 - 02:10")
show3 = input.bool(true, title="02:50 - 03:10")
show4 = input.bool(true, title="03:50 - 04:10")
show5 = input.bool(false, title="04:50 - 05:10")
show6 = input.bool(false, title="05:50 - 06:10")
show7 = input.bool(false, title="06:50 - 07:10")
show8 = input.bool(true, title="07:50 - 08:10")
show9 = input.bool(true, title="08:50 - 09:10")
show10 = input.bool(true, title="09:50 - 10:10")
show11 = input.bool(false, title="10:50 - 11:10")
show12 = input.bool(false, title="11:50 - 12:10")
show13 = input.bool(false, title="12:50 - 13:10")
show14 = input.bool(false, title="13:50 - 14:10")
show15 = input.bool(false, title="14:50 - 15:10")
show16 = input.bool(false, title="15:50 - 16:10")
show17 = input.bool(false, title="16:50 - 17:10")
show18 = input.bool(false, title="17:50 - 18:10")
show19 = input.bool(false, title="18:50 - 19:10")
show20 = input.bool(false, title="19:50 - 20:10")
show21 = input.bool(false, title="20:50 - 21:10")
show22 = input.bool(false, title="21:50 - 22:10")
show23 = input.bool(false, title="22:50 - 23:10")
show24 = input.bool(false, title="23:50 - 00:10")
// Tiempos
time1 = time_isMacro(0,50,1,10)
time2 = time_isMacro(1,50,2,10)
time3 = time_isMacro(2,50,3,10)
time4 = time_isMacro(3,50,4,10)
time5 = time_isMacro(4,50,5,10)
time6 = time_isMacro(5,50,6,10)
time7 = time_isMacro(6,50,7,10)
time8 = time_isMacro(7,50,8,10)
time9 = time_isMacro(8,50,9,10)
time10 = time_isMacro(9,50,10,10)
time11 = time_isMacro(10,50,11,10)
time12 = time_isMacro(11,50,12,10)
time13 = time_isMacro(12,50,13,10)
time14 = time_isMacro(13,50,14,10)
time15 = time_isMacro(14,50,15,10)
time16 = time_isMacro(15,50,16,10)
time17 = time_isMacro(16,50,17,10)
time18 = time_isMacro(17,50,18,10)
time19 = time_isMacro(18,50,19,10)
time20 = time_isMacro(19,50,20,10)
time21 = time_isMacro(20,50,21,10)
time22 = time_isMacro(21,50,22,10)
time23 = time_isMacro(22,50,23,10)
time24 = time_isMacro(23,50,0,10)
//#region
plotMacro(_show, _LINES, _time, _lbl) =>
if _show
macroOC(_LINES, _time, _lbl, dayofweek(time) == dayofweek.friday and syminfo.type != 'crypto')
plotMacro(show1, _LINES1, time1, "00:50 - 01:10")
plotMacro(show2, _LINES2, time2, "01:50 - 02:10")
plotMacro(show3, _LINES3, time3, "02:50 - 03:10")
plotMacro(show4, _LINES4, time4, "03:50 - 04:10")
plotMacro(show5, _LINES5, time5, "04:50 - 05:10")
plotMacro(show6, _LINES6, time6, "05:50 - 06:10")
plotMacro(show7, _LINES7, time7, "06:50 - 07:10")
plotMacro(show8, _LINES8, time8, "07:50 - 08:10")
plotMacro(show9, _LINES9, time9, "08:50 - 09:10")
plotMacro(show10, _LINES10, time10, "09:50 - 10:10")
plotMacro(show11, _LINES11, time11, "10:50 - 11:10")
plotMacro(show12, _LINES12, time12, "11:50 - 12:10")
plotMacro(show13, _LINES13, time13, "12:50 - 13:10")
plotMacro(show14, _LINES14, time14, "13:50 - 14:10")
plotMacro(show15, _LINES15, time15, "14:50 - 15:10")
plotMacro(show16, _LINES16, time16, "15:50 - 16:10")
plotMacro(show17, _LINES17, time17, "16:50 - 17:10")
plotMacro(show18, _LINES18, time18, "17:50 - 18:10")
plotMacro(show19, _LINES19, time19, "18:50 - 19:10")
plotMacro(show20, _LINES20, time20, "19:50 - 20:10")
plotMacro(show21, _LINES21, time21, "20:50 - 21:10")
plotMacro(show22, _LINES22, time22, "21:50 - 22:10")
plotMacro(show23, _LINES23, time23, "22:50 - 23:10")
plotMacro(show24, _LINES24, time24, "23:50 - 00:10")
//#endregion
//#region
_LINES1.memoryCleanLine()
_LINES2.memoryCleanLine()
_LINES3.memoryCleanLine()
_LINES4.memoryCleanLine()
_LINES5.memoryCleanLine()
_LINES6.memoryCleanLine()
_LINES7.memoryCleanLine()
_LINES8.memoryCleanLine()
_LINES9.memoryCleanLine()
_LINES10.memoryCleanLine()
_LINES11.memoryCleanLine()
_LINES12.memoryCleanLine()
_LINES13.memoryCleanLine()
_LINES14.memoryCleanLine()
_LINES15.memoryCleanLine()
_LINES16.memoryCleanLine()
_LINES17.memoryCleanLine()
_LINES18.memoryCleanLine()
_LINES19.memoryCleanLine()
_LINES20.memoryCleanLine()
_LINES21.memoryCleanLine()
_LINES22.memoryCleanLine()
_LINES23.memoryCleanLine()
_LINES24.memoryCleanLine()
EXT.memoryCleanLine()
LBL.memoryCleanLabel()
//#endregion
ATRThis script displays the Average True Range (ATR) value and the ATR as a percentage of the current closing price directly on the main chart as a clean table, with no lines or plots. It allows users to easily monitor both absolute volatility and its relative magnitude, making comparisons across different assets intuitive. The display position is customizable, offering flexibility for personal chart layouts. Ideal for traders seeking quick volatility insights, risk management guidance, or portfolio-wide comparisons.
Quantum Portfolio vs NASDAQ (Base: May 2, 2021)This custom Pine Script indicator tracks and compares the cumulative performance of a multi-asset “Quantum Portfolio” against the NASDAQ 100 benchmark, rebased to a common starting point on May 2, 2021.
Both series are normalized to a base value of 100 on that date, allowing direct visual comparison of percentage growth or decline over time.
Thematic Portfolio: Quantum Computing & Core TechThis indicator tracks the aggregated performance of a curated thematic portfolio representing the Quantum Computing & Core Technology sector.
It combines leading equities and ETFs with predefined weights to reflect a diversified exposure across quantum hardware, AI infrastructure, and semiconductor backbones.
Composition:
Stocks: Rigetti (RGTI), IonQ (IONQ), D-Wave (QBTS), Palantir (PLTR), Intel (INTC), Arqit (ARQQ)
ETFs: BUG, QTUM, SOXX, IHAK
Methodology:
Each component’s normalized performance is weighted according to its strategic importance within the theme (R&D intensity, infrastructure leverage, and hardware dependence). The indicator dynamically aggregates the weighted series to visualize the cumulative return of the quantum computing ecosystem versus traditional benchmarks.
Intended use:
Compare thematic returns vs. S&P 500 or NASDAQ
Identify macro inflection points in the quantum tech narrative
Backtest thematic exposure strategies or structure twin-win / delta-one certificates
Note: This script is for analytical and educational purposes only and does not constitute financial advice.
MCDX - Smart Money FlowThis version will compile cleanly in TradingView and replicate the stacked red/yellow/green MCDX-style panel from your screenshot.
Asia Session High/Low 23:00-00:15This indicator shows highs and lows 1 hour before Asia session and the first 15min of Asia session.
Trendline Breakout Strategy Strategy should place entries & exits so that it can be backtested (use strategy.entry and strategy.exit with explicit stop and limit prices). Include an option for fixed percent position sizing and an option for fixed contract size. Draw the trendline on the chart (with option to hide/show) and add labels that show: bias (Bull/Bear), trendline slope, entry price, SL, TP and the reason (e.g., "Trendline Breakout"). Provide user inputs for: EMA length (default 200), lookback for pivot detection, pivot sensitivity (left/right bars), quantity mode (percent / contracts), risk percent or fixed size, enable/disable backtest prints, and enable alerts. Avoid repainting: use confirmed pivot logic (pivot detection must use completed bars) and only take entry after breakout confirmed on close. Document any limitations (for example, trendline using two highest/highest bars inside lookback is approximate). Add clear comments, helpful variable names, and include example alertcondition lines for entry and exit signals.
Triple EMA (5, 8, 13) + Confirmed Alerts with SoundThis indicator uses three Exponential Moving Averages (EMA 5, 8, and 13) to generate buy and sell signals when the EMAs are properly aligned and not touching. Signals are confirmed on candle close and can trigger customizable sound alerts directly from the TradingView alert panel.
Advanced Currency StrengthThis indicator shows the strength of currency based on its movement. Ossiclator.






















