FAKKA_MACDTFC on 6 timeframes for macd
Shows when the majority of MACD across multiple timeframes is supportive
Indicadores e estratégias
Stochastic and RSI DZStoch and RSI combined. I use it on timeframe 15M.
Parameters can be edited as needed.
For example on Stoch I use : K Lenght = 21, K Smoothing = 5, and D Smoothing 5
On RSI - Smoothing Lenght = 20
Double Bottom & Breakout Strategy (With Alerts)trategy helps traders identify potential bullish breakouts based on multiple technical indicators. It detects a double bottom pattern, higher highs & higher lows, and an EMA crossover before confirming a breakout with increasing volume.
📊 Key Components
1️⃣ 📉 Double Bottom Formation
Detects a double bottom pattern by identifying two lows within a set period (10 & 20 bars).
If the second low is slightly higher than the first, it suggests potential accumulation before a breakout.
2️⃣ 📈 Higher High & Higher Low Confirmation
Checks if the current high is greater than the previous highest high (past 2 bars).
Confirms a higher low to ensure price is forming a bullish structure.
3️⃣ 📊 EMA Crossover for Trend Confirmation
Uses 4 Exponential Moving Averages (EMAs):
✅ 200 EMA (Long-term Trend) – Key support/resistance level.
✅ 189 EMA (Support Level) – Close to 200 EMA for additional confirmation.
✅ 20 EMA (Short-term Trend) – Captures early bullish momentum.
✅ 9 EMA (Fastest EMA) – Confirms rapid trend shifts.
A bullish EMA crossover happens when 9 EMA & 20 EMA cross above the 189 EMA, signaling trend strength.
4️⃣ 📊 Breakout with Rising Volume
Confirms breakout only if the price breaks above the highest high of the last 5 bars.
Volume must be 1.5x greater than the 20-bar moving average of volume (sma(volume, 20) * 1.5).
This ensures strong buyer participation.
5️⃣ 🔔 Buy Signal + Alerts
If all conditions are met, a BUY signal is plotted on the chart.
Sound alert triggered using alertcondition() so traders receive notifications.
Weekly MA SuiteThe Weekly MA Suite is a multi-layered moving average indicator designed for traders and investors who analyze market trends across weekly and long-term timeframes. It combines three critical trend layers—short-term (1W EMA/VWMA), mid-term (30W EMA/VWMA), and long-term (200W HMA)—providing clear insights into market momentum, structure, and cycle trends.
This indicator is ideal for:
✅ Swing traders looking for weekly momentum shifts
✅ Position traders tracking multi-week to multi-month trends
✅ Long-term investors monitoring macro market cycles
Each layer has customizable colors, transparency, and visibility toggles, ensuring traders can tailor the indicator to their specific needs.
📊 Breakdown of Components
🔹 Short-Term Trend (1W EMA/VWMA Ribbon – Top Layer)
Purpose: Captures weekly momentum and volume dynamics
• 1W EMA (Exponential Moving Average) reacts quickly to price changes
• 1W VWMA (Volume-Weighted Moving Average) accounts for volume to confirm trend strength
• Ribbon fill highlights the divergence between price-based momentum (EMA) and volume-weighted trends (VWMA), making trend shifts easier to spot
Usage:
• If the 1W EMA is above the 1W VWMA, momentum is strong and price is trending higher with support from volume
• If the EMA crosses below the VWMA, it may indicate weakening trend strength or distribution
• A widening ribbon suggests increasing momentum, while a narrowing ribbon signals potential consolidation or reversal
🔸 Mid-Term Trend (30W EMA/VWMA Ribbon – Middle Layer)
Purpose: Provides insight into the broader market structure over multiple months
• 30W EMA represents the dominant trend direction over roughly half a year
• 30W VWMA smooths this trend while weighting price by trading volume
• Ribbon fill allows for a visual representation of how volume impacts trend direction
Usage:
• A bullish trend is confirmed when price remains above the 30W EMA, with the ribbon widening in an uptrend
• A bearish shift occurs when the 30W EMA crosses below the 30W VWMA, signaling weakening demand
• If the ribbon narrows or twists frequently, the market may be in a choppy, range-bound phase
🔻 Long-Term Trend (200W HMA – Background Layer)
Purpose: Identifies major market cycles and deep trend shifts
• The 200W Hull Moving Average (HMA) is a long-term smoothing tool that reduces lag while maintaining trend clarity
• Unlike traditional moving averages, the HMA reacts faster to trend changes without excessive noise
Usage:
• When price is above the 200W HMA, the broader trend remains bullish, even during short-term corrections
• A cross below the 200W HMA may indicate a macro downtrend or deep market cycle shift
• Long-term investors can use this as a dynamic support or resistance zone
🎯 How to Use the Weekly MA Suite for Trading
📅 Identifying Market Phases
• In strong uptrends, the 1W EMA and 30W EMA will be aligned above their VWMA counterparts, with price well above the 200W HMA
• In sideways markets, the ribbons will frequently narrow or cross, signaling indecision
• In bear markets, price will typically trade below the 30W EMA, with the 200W HMA acting as a long-term resistance
📈 Entry and Exit Strategies
• A bullish trade setup occurs when the 1W EMA crosses above the 1W VWMA while the 30W EMA holds above the 30W VWMA, confirming multi-timeframe momentum
• A bearish setup is confirmed when the 1W EMA crosses below the 1W VWMA and price is also trending below the 30W EMA
• The 200W HMA can be used as a trend filter—staying long when price is above it and avoiding longs when price is below
🚦 Customizing for Your Trading Style
• Scalpers can focus on the 1W ribbon for faster trend shifts
• Swing traders can use the 30W ribbon for trend-following entries and exits
• Long-term investors should watch price action relative to the 200W HMA for market cycle positioning
🔧 Final Thoughts
The Weekly MA Suite simplifies multi-timeframe analysis by layering key moving averages in an intuitive and structured format. By combining short, medium, and long-term trend indicators, traders can confidently navigate market conditions and improve decision-making. Whether trading weekly trends or monitoring multi-year cycles, this tool provides a clear visual framework to enhance market insights.
PLN IndexThe "PLN Index" is a custom indicator developed for TradingView using Pine Script (version 6). It tracks the relative strength of the Polish Zloty (PLN) against a basket of four major currencies: the U.S. Dollar (USD), Swiss Franc (CHF), Euro (EUR), and British Pound (GBP), with each currency contributing an equal weight of 25%. Modeled after the Polish Zloty Index (PLN_I) concept, this indicator offers traders a tool to monitor PLN’s performance across various forex market conditions.
How It Works
The indicator fetches closing prices for the currency pairs USDPLN, CHFPLN, EURPLN, and GBPPLN from TradingView’s data provider (FX_IDC). These pairs represent the amount of PLN needed to purchase one unit of each respective foreign currency. To measure PLN’s strength, the script inverts these rates (e.g., PLNUSD = 1/USDPLN) and calculates the geometric mean of the resulting values using the formula geom_mean = (PLNUSD * PLNCHF * PLNEUR * PLNGBP)^(0.25). The result is then normalized to a base value of 100 at the first bar with complete data, allowing users to observe relative changes in PLN’s value over time. A rising index indicates PLN appreciation, while a falling index suggests depreciation against the basket.
Key Features
Data Inputs: Retrieves closing prices for USDPLN, CHFPLN, EURPLN, and GBPPLN on the selected timeframe.
Calculation: Computes the geometric mean of the inverted exchange rates and normalizes it to 100 based on the first valid bar.
Visualization: Plots the index as a blue line with a linewidth of 2 on a separate chart pane (non-overlay).
Robust Normalization: Normalizes the index using the first bar where all data is available, improving reliability across different timeframes.
Usage
The PLN Index is useful for:
Evaluating the Polish Zloty’s strength or weakness relative to a balanced currency basket.
Identifying long-term trends or short-term shifts in PLN’s value for forex trading or economic analysis.
Supporting technical analysis when paired with additional indicators, such as moving averages or oscillators.
Limitations
Data Dependency: The indicator relies on the availability of historical data for all four currency pairs. Missing data (e.g., on higher timeframes like D1 or W1) may prevent accurate plotting.
Relative Normalization: Unlike the official PLN_I, which uses a fixed historical base date (e.g., January 2, 1984), this indicator normalizes to 100 at the first valid bar, making it a relative rather than absolute measure.
Potential Data Gaps: On higher timeframes, inconsistencies or limited historical data from the FX_IDC provider may result in incomplete index values.
Notes
This version of the PLN Index includes an improved normalization method that sets the base value (100) at the first bar with valid data, enhancing its adaptability compared to earlier iterations. It performs best on timeframes up to H4, where data availability is generally consistent. For higher timeframes, users should verify data completeness to ensure reliable results.
12/21 ema 4x and 16x48/84/192/336 EMA. Plots the 12/21 ema on 4x and 16x scale.
This indicator displays 12 and 21 period EMAs, scaled to 4x and 16x the current chart's timeframe. This allows you to visualize higher timeframe 12/21 EMAs directly on your current chart, such as showing the 1-hour and 4-hour equivalent 12/21 EMAs on a 15-minute chart.
pr_functionsLibrary "pr_functions"
TODO: add library description here
sema(src, length)
TODO: add function description here
Parameters:
src (float)
length (simple int)
Returns: TODO: add what function returns
Utility function for smooth EMA calculation
update_array(arr, value)
Parameters:
arr (array)
value (float)
is_uptrend(arr)
Parameters:
arr (array)
is_downtrend(arr)
Parameters:
arr (array)
is_ema_valid(ema)
Parameters:
ema (float)
Rsi & Ema Optimization Buy-Sell Signal Cuneyt UgurThis indicator is a beta version indicator that aims to generate trading signals by optimizing the RSI (Relative Strength Index) and EMA (Exponential Moving Average) indicators.
Short and long exponential moving averages catch the breaks by following the trends of the bottom and top values of price movements in a certain period, cleared of contradictions. In addition, for RSI, it optimizes the bottom and top points of the RSI and creates buy and sell signals where there are parallels with the price breakdowns.
Recommendation for use: It is recommended to use it for at least 1 hour.d: At least 1 hour.
MTF Sentiment ProMTF Sentiment Pro - Advanced Multi-Timeframe Analysis
Purpose & Methodology
MTF Sentiment Pro provides traders with comprehensive market sentiment analysis across multiple timeframes. This indicator's unique innovation is its weighted scoring system that evaluates both technical indicators and volume metrics to determine market sentiment across customizable timeframes.
Unlike simple indicator overlays or basic multi-timeframe tools, this indicator:
1. Calculates sentiment using a proprietary weighted formula across 7 different timeframes
2. Incorporates volume confirmation to validate price movements (a critical element often overlooked)
3. Provides clear visualization of sentiment alignment between lower and higher timeframes
4. Uses majority-rule algorithms for overall sentiment determination (2/3 rule for LTF, 3/4 rule for HTF)
Technical Components & Integration
Each timeframe's sentiment score is derived from a combination of:
- **EMA**: Evaluates trend direction and price position relative to moving average
- **RSI**: Measures momentum with sensitivity to the 50-level for trend determination
- **MACD**: Assesses trend strength and momentum through histogram analysis
- **Bollinger Bands**: Determines price volatility and position relative to the mean
- **VWAP**: Provides volume-adjusted price reference
- **OBV**: Confirms price moves with cumulative volume analysis
What makes this combination powerful is how these components are integrated:
- Each indicator contributes a weighted value to the overall sentiment score
- User-definable weights allow customization based on strategy preferences
- Volume confirmation adds a critical dimension beyond basic price-only indicators
- Multi-timeframe analysis helps identify alignment/divergence across time horizons
Trading Applications & Limitations
This indicator works best for:
- Trend confirmation across multiple timeframes
- Identifying potential reversal zones where LTF and HTF sentiments diverge
- Entry/exit timing when paired with your primary strategy rules
- Market structure analysis across different time horizons
Note: While this indicator provides comprehensive sentiment analysis, it should be used as part of a complete trading strategy with proper risk management. No indicator can predict market movements with certainty.
Usage Instructions
1. Select appropriate timeframes for your trading style or use one of the included presets
2. Adjust indicator weights to match your analytical preferences
3. Look for timeframe alignment/divergence to identify potential opportunities
4. Use the overall LTF and HTF sentiment readings for broader market context
This indicator was developed to solve the challenge of efficiently analyzing sentiment across multiple timeframes while incorporating volume confirmation - something that would otherwise require multiple indicators and manual correlation.
Machine Learning: Lorentzian Classification/ ====================
// ==== Background ====
// ====================
// When using Machine Learning algorithms like K-Nearest Neighbors, choosing an
// appropriate distance metric is essential. Euclidean Distance is often used as
// the default distance metric, but it may not always be the best choice. This is
// because market data is often significantly impacted by proximity to significant
// world events such as FOMC Meetings and Black Swan events. These major economic
// events can contribute to a warping effect analogous a massive object's
// gravitational warping of Space-Time. In financial markets, this warping effect
// operates on a continuum, which can analogously be referred to as "Price-Time".
// To help to better account for this warping effect, Lorentzian Distance can be
// used as an alternative distance metric to Euclidean Distance. The geometry of
// Lorentzian Space can be difficult to visualize at first, and one of the best
// ways to intuitively understand it is through an example involving 2 feature
// dimensions (z=2). For purposes of this example, let's assume these two features
// are Relative Strength Index (RSI) and the Average Directional Index (ADX). In
// reality, the optimal number of features is in the range of 3-8, but for the sake
// of simplicity, we will use only 2 features in this example.
// Fundamental Assumptions:
// (1) We can calculate RSI and ADX for a given chart.
// (2) For simplicity, values for RSI and ADX are assumed to adhere to a Gaussian
// distribution in the range of 0 to 100.
// (3) The most recent RSI and ADX value can be considered the origin of a coordinate
// system with ADX on the x-axis and RSI on the y-axis.
// Distances in Euclidean Space:
// Measuring the Euclidean Distances of historical values with the most recent point
// at the origin will yield a distribution that resembles Figure 1 (below).
//
// |
// |
// |
// ...:::....
// .:.:::••••••:::•::..
// .:•:.:•••::::••::••....::.
// ....:••••:••••••••::••:...:•.
// ...:.::::::•••:::•••:•••::.:•..
// ::•:.:•:•••••••:.:•::::::...:..
// |--------.:•••..•••••••:••:...:::•:•:..:..----------
// 0 :•:....:•••••::.:::•••::••:.....
// ::....:.:••••••••:•••::••::..:.
// .:...:••:::••••••••::•••....:
// ::....:.....:•::•••:::::..
// ..:..::••..::::..:•:..
// .::..:::.....:
// |
// |
// |
// |
// _|_ 0
//
// Figure 1: Neighborhood in Euclidean Space
// Distances in The Space:
// However, the same set of historical values measured using The Distance will
// yield a different distribution that resembles Figure 2 (below).
//
//
// ::.. | ..:::
// ..... | ......
// .••••::. | :••••••.
// .:•••••:. | :::••••••.
// .•••••:... | .::.••••••.
// .::•••••::.. | :..••••••..
// .:•••••••::.........::••••••:..
// ..::::••••.•••••••.•••••••:.
// ...:•••••••.•••••••••::.
// .:..••.••••••.••••..
// |---------------.:•••••••••••••••••.---------------
// 0 .:•:•••.••••••.•••••••.
// .••••••••••••••••••••••••:.
// .:••••••••••::..::.::••••••••:.
// .::••••••::. | .::•••:::.
// .:••••••.. | :••••••••.
// .:••••:... | ..•••••••:.
// ..:••::.. | :.•••••••.
// .:•.... | ...::.:••.
// ...:.. | :...:••.
// :::. | ..::
// _|_ 0
//
// Figure 2: Neighborhood in the Space
// Observations:
// (1) In the Space, the shortest distance between two points is not
// necessarily a straight line, but rather, a geodesic curve.
// (2) The warping effect of Lorentzian distance reduces the overall influence
// of outliers and noise.
// (3) The Distance becomes increasingly different from Euclidean Distance
// as the number of nearest neighbors used for comparison increases.
Elite PivotsThis Script, called " Elite Pivots ," helps traders by drawing their key pivot, resistance, and support levels on their charts.
Users can set custom price levels for five resistances (R1–R5), one pivot (P), and five supports (S1–S5). The script then draws horizontal lines with configurable colors, styles, and labels for each level.
It also monitors if the price crosses any of these levels during a specified trading session, marking crossed levels with a target emoji (🎯).
This visual cue allows traders to quickly identify when important price levels are breached, which can be useful for timing trades and managing risk.
Ultimator's RSI Smoother 3.0This indicator uses two RSI timeframes that are smoothed out by applying a SMA to the RSI lines. It's goal is to pinpoint optimal bottoms and tops on a general basis for all timeframes by marking them on the smoothed RSI lines as different colored dots for visual effect.
When the conditions are met at a low RSI for both lines, it creates a dot on the upper line to indicate a possible bottom.
When the conditions are met at high RSI for both lines, it creates a dot on the lower line to indicate a possible top.
This indicator is meant for any timeframe, and the RSI lengths as well as smoothing lengths are opened as user inputs to allows users to fine tune the conditions to their needs.
Opening Range BoxIndicator Name: Opening Range Box with Extensions
Author: YanivBull
Description:
The Opening Range Box with Extensions is a powerful tool designed to visualize the trading range established during the first 30 minutes of a market session, a critical period for setting the day's trend. This indicator plots a box representing the high and low prices formed within this opening range, with dashed extension lines projecting these levels forward throughout the session.
Its primary purpose is to identify the boundaries of the initial trend at the start of trading. When these boundaries are breached, it serves as a trigger for potential trading opportunities: a breakout above the box high signals a possible long entry, while a breakdown below the box low indicates a potential short entry. The indicator also includes historical boxes for up to 5 previous days (configurable), allowing traders to analyze past opening ranges and their extensions for context and pattern recognition.
Key Features:
Customizable session start time (hour and minute) to adapt to various markets (e.g., NYSE, DAX, etc.).
Displays the current session's opening range box in blue and historical boxes in gray.
Plots dashed extension lines from the high and low of each box, limited to 500 bars or the end of the trading day.
Adjustable number of historical days (1-20, default 5).
Usage:
Set the Session Start Hour and Session Start Minute according to your market's opening time (relative to your chart's timezone, e.g., UTC+2). Watch for price action around the box boundaries—breakouts above the high or below the low can be used as signals for initiating long or short trades, respectively. Combine with other technical analysis tools for confirmation.
This indicator is ideal for day traders looking to capitalize on early session momentum and breakout strategies.
Quad Rotation Stochastic (Offset Panels)Based on Day Trading Radio (DTR) concept for Quad Rotation of 4 stochastics
Named SessionsShows London, New York and Tokyo sessions (and optionally Sydney).
Beginner-friendly - shows names of sessions, not just colors
Marks low and high of session
Shows if session is currently open
Session names can be customized
Session label is placed above or below depending on price move during session, visually indicating the trend (also works during open session)
Is displayed only on timeframes below 4H
How it works
Session trend is calculated simply by subtracting the session's opening price from the session's closing price (or current price if session is open).
If there is a gap before the session, the previous close is used instead of the first candle's open price.
Advanced Session Profile Predictor with ArrowsIndicator Description: Advanced Session Profile Predictor with Arrows
Overview
The Advanced Session Profile Predictor with Arrows is a powerful indicator designed to analyze price action across three major trading sessions—Asia, London, and New York—and provide actionable trading insights. Built on session-based profiling and enhanced with Traders Dynamic Index (TDI) and momentum-driven arrows, this indicator helps traders identify potential market profiles and key entry points for long and short positions. It combines visual session highlighting, dynamic profile labels, and momentum signals to offer a comprehensive trading tool.
Key Features
Session Visualization:
Highlights the Asia (00:00-08:00 UTC, yellow), London (08:00-16:00 UTC, red), and New York (13:00-21:00 UTC, blue) sessions with customizable time zones (UTC, Europe/London, America/New_York).
Tracks high, low, open, and close prices for each session, resetting daily.
Profile Prediction:
Analyzes price behavior in the Asia and London sessions to predict one of four market profiles during the London session:
Profile 1: Trend Continuation: Strong trend from Asia continues into London. Long if price breaks asien_high (uptrend) or short if it breaks asien_low (downtrend).
Profile 2: NY Manipulation: Asia trends, London consolidates. Long at asien_high or london_high (uptrend), short at london_low (downtrend), with New York breakout potential.
Profile 3: London+NY Manipulation: London manipulates asien_high, potential reversal in NY. Short at asien_close, long at asien_high.
Profile 4: Consolidation+Continuation: London manipulates asien_low, continuation in NY. Short at asien_low, long at asien_close.
Displays the current profile and entry conditions in three compact labels (Profile, Short, Long) near the latest price.
Dynamic Entry Conditions:
Labels show "IF price hits LONG/SHORT" for levels yet to be reached, updating based on the current price (close).
Indicates "Ingen Long/Short (over/under )" if the price has already passed the target, ensuring relevance across sessions.
Momentum Arrows (TDI Integration):
Incorporates Traders Dynamic Index (TDI) with customizable RSI period (default 21), band length (34), fast MA (2), and slow MA (7).
Adds momentum (12-period) to generate:
Green Up Arrows: When TDI fast MA exceeds the upper band (>68) with rising momentum, signaling bullish strength (above bar).
Red Down Arrows: When TDI fast MA falls below the lower band (<32) with falling momentum, signaling bearish strength (below bar).
Arrows complement session profiles, providing additional confirmation for entries.
High/Low Lines:
Plots session highs and lows (yellow for Asia, red for London, blue for New York) as crosses for easy reference.
How to Use
Setup: Add the indicator to your chart and adjust the time zone and session times if needed (default: UTC). Customize TDI and momentum settings under "Traders Dynamic Index Settings" for your preferred sensitivity.
Trading:
Watch the labels in the top-right corner for the current profile and entry conditions (e.g., "IF price hits 1.2000 LONG (A/L/NY)").
Use green up arrows as bullish confirmation and red down arrows as bearish confirmation alongside profile signals.
Monitor session high/low lines to track key levels visually.
Profiles: Interpret the profile to anticipate market behavior:
Trend Continuation: Ride momentum with breaks of asien_high/asien_low.
NY Manipulation: Prepare for New York breakouts after London consolidation.
London+NY Manipulation: Look for reversals after false breaks.
Consolidation+Continuation: Trade continuation after consolidation ends.
Best Timeframes: Works on intraday timeframes (e.g., 15M, 1H) for session-based trading.
Settings
Time Zone: Choose your preferred session time zone (default: UTC).
Trend Threshold: Adjust sensitivity for trend detection (default: 1.5).
TDI Settings: Fine-tune RSI, bands, and MAs for arrow signals.
Momentum Length: Set momentum period (default: 12).
Beki cAn indicator combination of 3 things.
1 ) trend analysis
2 ) average price
3 ) price reversals
MACD, PSAR, Bollinger Bands, Stochastic RSI, VWAP, VWMA StrategyFor Long position, i have considered multiple indicators
Smart Scalping Momentum StrategyThe Smart Scalping Momentum Strategy is a powerful and well-optimized trading strategy designed for Forex, Crypto, and XAU/USD (Gold) markets. It focuses on high-probability entries based on price momentum, trend confirmation, and volatility adjustments. The strategy aims to maximize daily profits while maintaining a low-risk exposure by utilizing multiple technical indicators and strict risk management rules.
rzigzagLibrary "rzigzag"
Recursive Zigzag Using Matrix allows to create zigzags recursively on multiple levels. This is an old library converted to V6
zigzag(length, ohlc, numberOfPivots, offset)
calculates plain zigzag based on input
Parameters:
length (int) : Zigzag Length
ohlc (array) : Array containing ohlc values. Can also contain custom series
numberOfPivots (simple int) : Number of max pivots to be returned
offset (simple int) : Offset from current bar. Can be used for calculations based on confirmed bars
Returns: [matrix zigzagmatrix, bool flags]
iZigzag(length, h, l, numberOfPivots)
calculates plain zigzag based on input array
Parameters:
length (int) : Zigzag Length
h (array) : array containing high values of a series
l (array) : array containing low values of a series
numberOfPivots (simple int) : Number of max pivots to be returned
Returns: matrix zigzagmatrix
nextlevel(zigzagmatrix, numberOfPivots)
calculates next level zigzag based on present zigzag coordinates
Parameters:
zigzagmatrix (matrix) : Matrix containing zigzag pivots, bars, bar time, direction and level
numberOfPivots (simple int) : Number of max pivots to be returned
Returns: matrix zigzagmatrix
draw(zigzagmatrix, flags, lineColor, lineWidth, lineStyle, showLabel, xloc)
draws zigzag based on the zigzagmatrix input
Parameters:
zigzagmatrix (matrix) : Matrix containing zigzag pivots, bars, bar time, direction and level
flags (array) : Zigzag pivot flags
lineColor (color) : Zigzag line color
lineWidth (int) : Zigzag line width
lineStyle (string) : Zigzag line style
showLabel (bool) : Flag to indicate display pivot labels
xloc (string) : xloc preference for drawing lines/labels
Returns:
draw(length, ohlc, numberOfPivots, offset, lineColor, lineWidth, lineStyle, showLabel, xloc)
calculates and draws zigzag based on zigzag length and source input
Parameters:
length (int) : Zigzag Length
ohlc (array) : Array containing ohlc values. Can also contain custom series
numberOfPivots (simple int) : Number of max pivots to be returned
offset (simple int) : Offset from current bar. Can be used for calculations based on confirmed bars
lineColor (color) : Zigzag line color
lineWidth (int) : Zigzag line width
lineStyle (string) : Zigzag line style
showLabel (bool) : Flag to indicate display pivot labels
xloc (string) : xloc preference for drawing lines/labels
Returns: [matrix zigzagmatrix, array zigzaglines, array zigzaglabels, bool flags]
drawfresh(zigzagmatrix, zigzaglines, zigzaglabels, lineColor, lineWidth, lineStyle, showLabel, xloc)
draws fresh zigzag for all pivots in the input matrix.
Parameters:
zigzagmatrix (matrix) : Matrix containing zigzag pivots, bars, bar time, direction and level
zigzaglines (array) : array to which all newly created lines will be added
zigzaglabels (array) : array to which all newly created lables will be added
lineColor (color) : Zigzag line color
lineWidth (int) : Zigzag line width
lineStyle (string) : Zigzag line style
showLabel (bool) : Flag to indicate display pivot labels
xloc (string) : xloc preference for drawing lines/labels
Returns:
Seasonality Monthly v2.0//@version=6
indicator("Seasonality Monthly v2.0", overlay=false)
if not (timeframe.ismonthly or timeframe.isdaily)
alert("Switch to Daily or Monthly timeframe", alert.freq_once_per_bar)
// Input Settings
i_year_start = input(2000, "Start Year")
i_text_size = input.string(size.auto, "Text Size", )
// Function for calculating statistics
f_array_stats(array_) =>
count_pos_ = 0
count_neg_ = 0
count_ = 0
sum_ = 0.0
if not na(array_) and array.size(array_) > 0
for i_ = 0 to array.size(array_) - 1
elem_ = array.get(array_, i_)
if not na(elem_)
sum_ += elem_
count_ += 1
count_pos_ += elem_ > 0 ? 1 : 0
count_neg_ += elem_ < 0 ? 1 : 0
avg_ = count_ > 0 ? sum_ / count_ : 0.0
// Request historical data
year_ = request.security(syminfo.tickerid, "M", year(time_close), gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on)
month_ = request.security(syminfo.tickerid, "M", month(time_close), gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on)
chg_pct_ = request.security(syminfo.tickerid, "M", nz(close / close - 1), gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on)
// Initialize variables
var year_start_ = math.max(year_, i_year_start)
var no_years_ = year(timenow) - year_start_ + 1
var matrix data_ = matrix.new(no_years_, 13, na)
var table table_ = na
var text_color_ = color.white
var bg_color_ = color.gray
if year_ >= year_start_
cur_val_ = nz(matrix.get(data_, year_ - year_start_, month_ - 1))
matrix.set(data_, year_ - year_start_, month_ - 1, cur_val_ + chg_pct_)
if barstate.islast
table_ := table.new(position.middle_center, 13, no_years_ + 7, border_width = 1)
table.cell(table_, 0, 0, str.format("Seasonality Monthly Performance - {0}:{1}", syminfo.prefix, syminfo.ticker), text_color = text_color_, bgcolor = color.blue, text_size = i_text_size)
table.merge_cells(table_, 0, 0, 12, 0)
row = 1
// Header row
months_ ="Year", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
for col = 0 to 12
table.cell(table_, col, row, months_ , text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size)
// Data rows
for row_ = 0 to no_years_ - 1
table.cell(table_, 0, 2 + row_, str.tostring(row_ + year_start_), text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size)
for col_ = 0 to 11
val_ = nz(matrix.get(data_, row_, col_), 0.0)
val_color_ = val_ > 0.0 ? color.green : val_ < 0.0 ? color.red : color.gray
table.cell(table_, col_ + 1, 2 + row_, str.format("{0,number,###.##%}", val_), bgcolor = color.new(val_color_, 80), text_color = val_color_, text_size = i_text_size)
// Aggregates
row_ = no_years_ + 2
labels = "AVG", "SUM", "+ive", "WR"
for i = 0 to 3
table.cell(table_, 0, row_ + i, labels , text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size)
for col_ = 0 to 11
arr_ = matrix.col(data_, col_)
= f_array_stats(arr_)
val_color_ = sum_ > 0 ? color.green : sum_ < 0 ? color.red : color.gray
table.cell(table_, col_ + 1, row_, str.format("{0,number,###.##%}", avg_), bgcolor = color.new(val_color_, 50), text_color = val_color_, text_size = i_text_size)
table.cell(table_, col_ + 1, row_ + 1, str.format("{0,number,###.##%}", sum_), bgcolor = color.new(val_color_, 50), text_color = val_color_, text_size = i_text_size)
table.cell(table_, col_ + 1, row_ + 2, str.format("{0}/{1}", count_pos_, count_), bgcolor = color.new(val_color_, 50), text_color = color.new(color.white, 50), text_size = i_text_size)
table.cell(table_, col_ + 1, row_ + 3, str.format("{0,number,#.##%}", count_pos_ / count_), bgcolor = color.new(val_color_, 50), text_color = color.new(color.white, 50), text_size = i_text_size)