Micha Stocks Custom WatermarkThis Pine Script v5 indicator adds a customizable watermark to TradingView charts, displaying key stock information while allowing for flexible positioning and formatting.
📌 Features & Functionality:
✅ Custom Positioning:
• Fixed to the top-left corner.
• Adjustable spacing ensures the text is properly aligned.
✅ Displayed Information (Configurable):
• Company Name & Market Cap (Optional: Shows dynamically calculated market cap)
• Stock Ticker & Timeframe
• Industry & Sector
✅ Customization Options:
• Font Size: Huge, Large, Normal, Small
• Text Color & Transparency: Adjustable
• Proper Left Alignment for a clean, structured display
• Vertical Offset Tweaks to move text down for better visibility
✅ Optimized Table Layout:
• Uses table.new() for persistent placement.
• Added an empty row to fine-tune positioning, ensuring the watermark doesn’t overlap key chart areas.
🔧 Use Case:
Designed for traders who want a clear, customizable stock watermark to enhance their charting experience without obstructing price action.
Padrões gráficos
Fibonacci Retracement/ExtensionThis Pine Script code implements Fibonacci retracement and extension levels based on a ZigZag pattern. Below is a breakdown of its functionality:
Overview
The script calculates Fibonacci retracement and extension levels by identifying swing highs and swing lows using the ZigZag algorithm. It then plots these levels on the chart for trend analysis.
1. ZigZag Length Input
Defines the ZigZag length, which determines the sensitivity of peak and trough identification.
2. Fibonacci Retracement Calculation
Computes Fibonacci retracement levels using swing highs and lows.
Uses pre-defined Fibonacci ratios (0.236, 0.382, 0.5, 0.618, 0.786, 1.0).
Adjusts line positions dynamically as the trend evolves.
3. Fibonacci Extension Calculation
Identifies Fibonacci extension levels for future price targets.
Uses previous ZigZag patterns to estimate potential price movements.
4. Trend and Fibonacci Configuration
Allows the user to configure Fibonacci trend analysis.
TrendSw: Sets the trend direction (1 = Bullish, -1 = Bearish, 0 = None).
ZigZagleg: Determines the countback value for retracement calculations.
Percentage Retracement from ATH█ OVERVIEW
The Percentage Retracement from ATH indicator is a dynamic trading utility designed to help traders gauge market pullbacks from the peak price. By calculating key retracement levels based on the All-Time High (ATH) and user‑defined percentage inputs, it offers clear visual cues to assist in identifying potential support and resistance zones.
█ KEY FEATURES
Custom Date — Use a custom start date so the indicator only considers specified price action.
Retracement Calculation — Determines ATH and calculates levels based on user‑defined percentages (0% to –100%).
Visual Customisation — Plots configurable horizontal lines and labels showing retracement percentages and prices.
Time Filtering — Uses time filtering to base levels on the desired data period.
█ PURPOSE
Assist traders in visualising the depth of price retracements from recent or historical peaks.
Identify critical zones where the market may find support or resistance after reaching an ATH.
Facilitate more informed entry and exit decisions by clearly demarcating retracement levels on the chart.
█ IDEAL USERS
Swing Traders — Looking to exploit pullbacks following strong upward moves.
Technical Analysts — Interested in pinpointing key retracement levels as potential reversal or continuation points.
Price Action Traders — Focused on the nuances of market peaks and subsequent corrections.
Strategy Developers — Keen to backtest and refine approaches centred on retracement dynamics.
SMT Divergence [TakingProphets]The SMT (Smart Money Technique) Divergence indicator identifies potential market manipulation and smart money footprints by comparing price action between correlated instruments. It uses a dual-detection system to catch both frequent local SMTs and larger structural SMTs:
• Primary detection uses a shorter lookback period (default 5) to identify common SMT patterns
• Secondary detection uses a longer lookback period (default 8) to catch larger structural SMTs
• Automatically filters significant moves to prevent noise
• Labels are placed clearly outside of price action for better visibility
• Toggle between showing all SMTs or only significant liquidity sweeps
Compare any two instruments to spot divergences in their price action. Particularly useful for:
- Futures vs Spot markets
- Related currency pairs
- Index vs its components
- Any correlated instruments
Default settings are optimized for intraday trading but can be adjusted for different timeframes.
Note: This indicator works best when comparing closely correlated instruments and should be used alongside other technical analysis tools.
Drawdown Visualisation█ OVERVIEW
The Drawdown Visualisation indicator calculates and displays the instrument’s drawdown (in percent) relative to its all‐time high (ATH) from a user‐defined start date. It provides customisable options for label appearance, threshold lines (0%, –50%, –100%), and can plot historic drawdown levels via pivot detection.
█ USAGE
This indicator should be used with the Percentage Retracement from ATH indicator.
█ KEY FEATURES
Custom Date Settings — Use a custom start date so that only specified price action is considered.
Retracement Level Calculation — Determines ATH and computes multiple retracement levels using percentages from 0% to –100%.
Visual Signals and Customisation — Plots configurable horizontal lines and labels that display retracement percentages and prices.
Time Filtering — Bases calculations on data from the desired time period.
Historic Drawdowns — Display historical drawdowns
█ PURPOSE
Assist traders in visualising the depth of price retracements from recent or historical peaks.
Identify critical zones where the market may find support or resistance after reaching an ATH.
Facilitate more informed entry and exit decisions by clearly demarcating retracement levels on the chart.
█ IDEAL USERS
Swing Traders — Looking to exploit pullbacks following strong upward moves.
Technical Analysts — Interested in pinpointing key retracement levels as potential reversal or continuation points.
Price Action Traders — Focused on the nuances of market peaks and subsequent corrections.
Strategy Developers — Keen to backtest and refine approaches centred on retracement dynamics.
Made by Karan targetcandlestick basis target .this also includes my strategy about 4 years of experiences.
RoGr75 - EMA 50/8 Cross With Buy/Sell Signals RoGr75 - EMA 50/8 Cross With Buy/Sell Signals
---
**Overview:**
This script is designed to generate **Buy** and **Sell** signals based on the crossover and crossunder of two Exponential Moving Averages (EMAs): **EMA 8** (green line) and **EMA 50** (blue line). The signals are plotted at a user-defined distance from the candles, ensuring clear visibility and adaptability to market volatility.
---
**Key Features:**
1. **EMA Cross Signals**:
- A **Buy Signal** is generated when the **EMA 8** crosses above the **EMA 50**.
- A **Sell Signal** is generated when the **EMA 8** crosses below the **EMA 50**.
2. **Variable Signal Distance**:
- The distance of the Buy and Sell signals from the candles is controlled by a **user-defined input** (`signal_distance`).
- The distance is calculated using the **Average True Range (ATR)** to adapt to market volatility.
3. **Customizable Parameters**:
- `signal_distance`: Adjust the distance of the signals from the candles (default: 2.0).
- ATR period: Fixed at 14 but can be modified in the script.
4. **Visual Enhancements**:
- Buy signals are displayed as green labels below the candles.
- Sell signals are displayed as red labels above the candles.
- Optional background highlighting for Buy and Sell signals.
---
**How It Works:**
- The script calculates the **EMA 8** and **EMA 50** and plots them on the chart.
- When a crossover or crossunder occurs, a label is placed at a distance determined by the formula:
- **Buy Signal Position**: `low - (signal_distance * ATR(14))`
- **Sell Signal Position**: `high + (signal_distance * ATR(14))`
- The signals are clearly visible and adapt to the volatility of the asset.
---
**Input Parameters:**
- `signal_distance` (type: input float): Controls the distance of the Buy and Sell signals from the candles. Default value is `2.0`.
---
**Usage:**
1. Add the script to your chart in TradingView.
2. Adjust the `signal_distance` input to set the desired distance of the signals from the candles.
3. Monitor the Buy and Sell signals generated by the script for potential trading opportunities.
---
**Example:**
- If `signal_distance` is set to `2.0`, the Buy signal will appear **2x ATR** below the candle's low, and the Sell signal will appear **2x ATR** above the candle's high.
---
**Customization:**
- Modify the ATR period or replace it with a fixed value for static distance.
- Adjust the colors, styles, and sizes of the labels and EMAs to suit your preferences.
---
**Ideal For:**
- Traders looking for a simple and effective EMA crossover strategy.
- Users who want customizable signal placement for better visibility.
- Those who prefer volatility-adjusted signal distances.
---
**Note:**
This script is for educational and informational purposes only. Always backtest and validate strategies before using them in live trading.
John Bob-Trading-BotDeveloped by Ayebale John Bob with the help of his bestie, this innovative strategy combines advanced Smart Money Concepts with practical risk management tools to help traders identify and capitalize on key market moves.
Key Features:
Smart Money Concepts & Fair Value Gaps (FVG):
The strategy monitors price action for fair value gaps, which are visualized as extremely faint horizontal lines on the chart. These FVGs signal potential areas where institutional traders might have entered or exited positions.
Dynamic Entry Signals:
Buy signals are triggered when the price crosses above the 50-bar lowest low or when a bullish FVG is detected. Conversely, sell signals are generated when the price falls below the 50-bar highest high or a bearish FVG is identified. Each signal is visually marked on the chart with clear buy (green) and sell (red) labels.
Multi-Level Order Execution:
Once an entry signal occurs, the strategy places five separate orders, each with its own take-profit (TP) level. The TP levels are calculated dynamically using the Average True Range (ATR) and a set of predefined multipliers. This allows traders to scale out of positions as the market moves favorably.
Dynamic Risk Management:
A stop-loss is automatically set at a distance determined by the ATR, ensuring that risk is managed in accordance with current market volatility.
Real-Time Trade Information Table:
In the bottom-right corner of the chart, a trade information table displays essential details about the current trade:
Side: Displays "BUY NOW" (with a dark green background) for long entries or "SELL NOW" (with a dark red background) for short entries.
Entry Price & Stop-Loss: Shows the entry price (highlighted in green) and the corresponding stop-loss level (highlighted in red).
Take-Profit Levels: Lists the five TP levels, each of which turns green once the market price reaches that target.
Timer: A live timer in minutes counts from the moment the current trade trigger started, helping traders track the duration of their active trades.
Visual Progress Bar:
A histogram-style progress bar is plotted on the chart, visually representing the percentage gain (or loss) relative to the entry price.
This strategy was meticulously designed to incorporate both technical analysis and smart risk management, offering a robust trading solution that adapts to changing market conditions. Whether you're a seasoned trader or just starting out, the AyebaleJohnBob Trading Bot equips you with the tools and visual cues needed to make well-informed trading decisions. Enjoy a seamless blend of strategy and style—crafted with passion by Ayebale John Bob and his bestie!
Cripto🟢🟠Veterano v1.0"Cripto🟢🟠Veterano v1.0 es un indicador que te ayuda a identificar entradas y salidas en el mercado de criptomonedas. usando estadísticas e inteligencia artificial.
Solo funciona en temporalidades de 5 minutos. El usuario solo debe esperar las entradas y tomarlas, basándose en señales precisas de soporte, resistencia, RSI y EMAs. Además, el indicador se actualizará a medida que pasa el tiempo.
Si deseas hacer una donación, esta es la dirección de TRON EN USDT:
TVdQYjPr11j3PLSTx7KQcCH4abRFqPLEUE
CONFIGURACIÓN:
Vela Izquierda y Derecha: 73
Extensión de Soporte y Resistencia: 20
Número Máximo de Soporte y Resistencia: 3
Colores:
Rectángulo (0.20): Rosado
Rectángulo (-0120): Rosado
Condiciones:
Caída Extrema: Caída extrema
Cambio de Texto: Subida extrema
Colores de Caída y Subida Extrema: Gris
EMA:
Período de EMA 1: 200
Desactivar las demás EMAs
AyebaleJohnBob-Trading-BotAyebale John Bob - Trading-Bot Overview:
This trading strategy is designed to automate trades based on the "Smart Money Concepts" and "Fair Value Gaps" (FVG). The bot leverages multiple technical indicators and logic to execute buy and sell trades with dynamic stop-loss and take-profit (TP) levels.
Key Features:
User Inputs:
Bull & Bear Colors: Customizable colors for bullish and bearish trends.
Fair Value Gap (FVG) Color: Customizable color for visualizing FVG zones.
ATR Multiplier: Defines the sensitivity of stop-loss calculations based on Average True Range (ATR).
Take-Profit Multipliers: A set of five multipliers that scale take-profit levels dynamically.
Trade Signals:
Buy Signal: Generated when the price crosses above a certain low or when a bullish Fair Value Gap (FVG) is detected.
Sell Signal: Triggered when the price crosses below a high or when a bearish FVG is identified.
Stop-Loss & Take-Profit Logic:
Stop-loss levels are calculated using ATR and the specified multiplier.
Take-profit levels are dynamically determined based on the ATR multipliers, with five different levels for each trade.
Trade Execution:
The strategy allows for five simultaneous buy or sell entries, with each having its own take-profit and stop-loss levels.
The bot operates continuously, without any session restrictions, allowing trades at any time.
Visual Indicators:
Entry Signals: Visual shapes (green for buy and red for sell) appear on the chart to indicate entry points.
Progress Bar: A real-time progress bar is plotted, tracking the percentage gain/loss from the entry price.
Trade Information Table:
A dynamic table is used to display important trade information, including entry price, take-profit levels, and stop-loss. This table updates for each new trade (buy or sell), and shows real-time trade progress.
Risk Management:
The stop-loss is dynamically adjusted based on the ATR calculation, ensuring that the bot adapts to changing market volatility.
Take-profit levels are spread across five increments, offering multiple opportunities for profit capture.
Summary:
The Ayebale John Bob - Trading-Bot is designed to implement a sophisticated strategy that combines smart money concepts, fair value gap analysis, and robust risk management. It provides real-time trade information, progress tracking, and a flexible approach to stop-loss and take-profit strategies. The bot is ideal for traders looking to automate trades and visually track their progress directly on the chart.
RoGr75 Adaptive EMA CrossDescription:
The RoGr75 Adaptive EMA Cross indicator dynamically combines exponential moving averages (EMAs) with ATR-based volatility buffers to generate buy and sell signals across multiple timeframes. This script uses customizable settings for short and long EMAs, ATR, and volume filters, ensuring that signals are both volatility-adjusted and timeframe-aware. It includes features such as adaptive buffers, distinct price level filters for buying and selling, and a reset mechanism to prevent redundant signals. Additionally, the indicator manages signal labels efficiently to keep your chart uncluttered.
Warning:
This script is provided for testing and educational purposes only. It is not intended as financial advice, and past performance does not guarantee future results. Use at your own risk. Always conduct your own research before making any trading decisions.
Higher Timeframe Input: Choose a specific timeframe for the indicator’s calculations; leave blank to use the chart’s current timeframe.
Signal Distance: Sets the distance of signal labels from the candles as a multiple of the ATR.
Exact Value Offset: Adjusts the secondary marker’s position for precision on the chart.
ATR Length: Defines the period used to calculate the Average True Range for volatility measurement.
EMA Lengths: Specify the periods for the short and long exponential moving averages.
Buy/Sell Buffer ATR Multipliers: Dynamically adjust the trigger distance beyond the EMA crossovers based on volatility.
Price Level Filter: Activates a filter so that buy signals only occur above a set price and sell signals only occur below that price (0 disables the filter).
Volume Filter: Optionally requires current volume to exceed a set multiple of a 20-period average for signal confirmation.
Reset Period: Resets the last signal memory after a specified number of bars to avoid suppressing valid repeat signals.
EMA Colors & Line Width: Customize the appearance of the short and long EMAs.
Label Colors & Styles: Choose colors, text colors, and styles for the buy and sell signal labels.
Background Highlighting: Optionally colors the background when a buy or sell signal occurs.
Label Management: Automatically removes the oldest labels when a set maximum is reached to keep the chart clean.
Alerts: Predefined conditions allow you to set TradingView alerts when buy or sell signals are generated.
Warning: This indicator is for testing purposes only and is not financial advice. Use it at your own risk.
EMA Study Script for Price Action Traders, v2JR_EMA Research Tool Documentation
Version 2 Enhancements
Version 2 of the JR_EMA Research Tool introduces several powerful features that make it particularly valuable for studying price action around Exponential Moving Averages (EMAs). The key improvements focus on tracking and analyzing price-EMA interactions:
1. Cross Detection and Counting
- Implements flags for crossing bars that instantly identify when price crosses above or below the EMA
- Maintains running counts of closes above and below the EMA
- This feature helps students understand the persistence of trends and the frequency of EMA interactions
2. Bar Number Tracking
- Records the specific bar number when EMA crosses occur
- Stores the previous crossing bar number for reference
- Enables precise measurement of time between crosses, helping identify typical trend durations
3. Variable Reset Management
- Implements sophisticated reset logic for all counting variables
- Ensures accuracy when analyzing multiple trading sessions
- Critical for maintaining clean data when studying patterns across different timeframes
4. Cross Direction Tracking
- Monitors the direction of the last EMA cross
- Helps students identify the current trend context
- Essential for understanding trend continuation vs reversal scenarios
Educational Applications
Price-EMA Relationship Studies
The tool provides multiple ways to study how price interacts with EMAs:
1. Visual Analysis
- Customizable EMA bands show typical price deviation ranges
- Color-coded fills help identify "normal" vs "extreme" price movements
- Three different band calculation methods offer varying perspectives on price volatility
2. Quantitative Analysis
- Real-time tracking of closes above/below EMA
- Running totals help identify persistent trends
- Cross counting helps understand typical trend duration
Research Configurations
EMA Configuration
- Adjustable EMA period for studying different trend timeframes
- Customizable EMA color for visual clarity
- Ideal for comparing different EMA periods' effectiveness
Bands Configuration
Three distinct calculation methods:
1. Full Average Bar Range (ABR)
- Uses the entire range of price movement
- Best for studying overall volatility
2. Body Average Bar Range
- Focuses on the body of the candle
- Excellent for studying conviction in price moves
3. Standard Deviation
- Traditional statistical approach
- Useful for comparing to other technical studies
Signal Configuration
- Optional signal plotting for entry/exit studies
- Helps identify potential trading opportunities
- Useful for backtesting strategy ideas
Using the Tool for Study
Basic Analysis Steps
1. Start with the default 20-period EMA
2. Observe how price interacts with the EMA line
3. Monitor the data window for quantitative insights
4. Use band settings to understand normal price behavior
Advanced Analysis
1. Pattern Recognition
- Use the cross counting system to identify typical pattern lengths
- Study the relationship between cross frequency and trend strength
- Compare different timeframes for fractal analysis
2. Volatility Studies
- Compare different band calculation methods
- Identify market regimes through band width changes
- Study the relationship between volatility and trend persistence
3. Trend Analysis
- Use the closing price count system to measure trend strength
- Study the relationship between trend duration and subsequent reversals
- Compare different EMA periods for optimal trend following
Best Practices for Research
1. Systematic Approach
- Start with longer timeframes and work down
- Document observations about price behavior in different market conditions
- Compare results across multiple symbols and timeframes
2. Data Collection
- Use the data window to record significant events
- Track the number of bars between crosses
- Note market conditions when signals appear
3. Optimization Studies
- Test different EMA periods for your market
- Compare band calculation methods for your trading style
- Document which settings work best in different market conditions
Technical Implementation Notes
This tool is particularly valuable for educational purposes because it combines visual and quantitative analysis in a single interface, allowing students to develop both intuitive and analytical understanding of price-EMA relationships.
Falling Wedge Strategy by Nitin//@version=6
strategy("Falling Wedge Strategy by Nitin", overlay=true, margin_long=100, margin_short=100)
// Input parameters
leftBars = input.int(5, "Left Bars for Pivot", minval=1, maxval=20)
rightBars = input.int(5, "Right Bars for Pivot", minval=1, maxval=20)
takeProfitPercent = input.float(20, "Take Profit %", minval=0.1, maxval=100)/100
stopLossPercent = input.float(2, "Stop Loss %", minval=0.1, maxval=100)/100
// Global variables
var float buyPrice = na
var line upperLine = na
var line lowerLine = na
// Detect pivot highs and lows
ph = ta.pivothigh(leftBars, rightBars)
pl = ta.pivotlow(leftBars, rightBars)
// Track last two pivot highs
var float highs = array.new_float()
var int highIndices = array.new_int()
if not na(ph)
array.unshift(highs, ph)
array.unshift(highIndices, bar_index )
if array.size(highs) > 2
array.pop(highs)
array.pop(highIndices)
// Track last two pivot lows
var float lows = array.new_float()
var int lowIndices = array.new_int()
if not na(pl)
array.unshift(lows, pl)
array.unshift(lowIndices, bar_index )
if array.size(lows) > 2
array.pop(lows)
array.pop(lowIndices)
// Calculate trendlines and signals
if array.size(highs) >= 2 and array.size(lows) >= 2
h1 = array.get(highs, 0)
h2 = array.get(highs, 1)
i1 = array.get(highIndices, 0)
i2 = array.get(highIndices, 1)
l1 = array.get(lows, 0)
l2 = array.get(lows, 1)
j1 = array.get(lowIndices, 0)
j2 = array.get(lowIndices, 1)
m_upper = (h1 - h2) / (i1 - i2)
m_lower = (l1 - l2) / (j1 - j2)
currentUpper = h2 + m_upper * (bar_index - i2)
currentLower = l2 + m_lower * (bar_index - j2)
if h1 < h2 and l1 < l2 and m_upper < m_lower and m_upper < 0 and m_lower < 0
line.delete(upperLine)
line.delete(lowerLine)
upperLine := line.new(i2, h2, i1, h1, extend=extend.right, color=color.blue)
lowerLine := line.new(j2, l2, j1, l1, extend=extend.right, color=color.orange)
// Buy signal on breakout
if ta.crossover(close, currentUpper)
strategy.entry("Buy", strategy.long)
buyPrice := close
strategy.exit("Take Profit/Stop Loss", "Buy", stop=buyPrice * (1 - stopLossPercent), limit=buyPrice * (1 + takeProfitPercent))
// Plotting
plotshape(strategy.position_size > 0 ? buyPrice : na, "Buy Price", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, text="BUY")
plot(strategy.position_size > 0 ? buyPrice * (1 - stopLossPercent) : na, "Stop Loss", color=color.red, linewidth=2)
plot(strategy.position_size > 0 ? buyPrice * (1 + takeProfitPercent) : na, "Take Profit", color=color.green, linewidth=2)
Buy Sell Signal//@version=5
indicator("Buy Sell Signal", overlay=true)
// Input settings
length = input(14, title="Moving Average Length")
maType = input.string("SMA", title="Moving Average Type", options= )
// Calculate Moving Average
ma = maType == "SMA" ? ta.sma(close, length) : ta.ema(close, length)
// Buy and Sell Signals
buySignal = ta.crossover(close, ma)
sellSignal = ta.crossunder(close, ma)
// Plot Buy and Sell Signals
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")
// Plot Moving Average
plot(ma, title="Moving Average", color=color.blue)
Reversal Opportunity📌 Indicator Description – Reversal Opportunity 🎯
🔍 General Overview
The Reversal Opportunity indicator is designed to identify ideal conditions for Reversal Trading, but it does not provide trade entry signals. Instead, it helps traders determine whether the market conditions are favorable for a potential reversal.
It is specifically designed for traders who execute Reversal trades (Long or Short) and want a clear indication of whether the market is currently suitable for such setups.
💡 What does this indicator do?
- Identifies strong momentum before a reversal (a sharp upward or downward move).
- Detects momentum slowdown (decreasing volume and smaller candles).
- Checks if the RSI is at an extreme level (above 70 or below 30), indicating potential overbought or oversold conditions.
- Displays a table at the top center of the screen with the following key data:
- Are the conditions for a reversal met?
- Is there a slowdown in momentum?
- Is RSI at an extreme level?
- Was there strong uptrend momentum before a possible Short Reversal?
- Was there strong downtrend momentum before a possible Long Reversal?
⚙️ How Does the Indicator Work?
The indicator displays a table in the center of the screen, updating every 5 candles to indicate whether the market conditions are ideal for a reversal trade.
📊 Main Status Row:
- ✔ Ideal Reversal Setup → Conditions for a reversal trade are met (not a trade recommendation).
- ✖ Not Ideal → Reversal conditions are not met; it may be better to wait.
📌 Key Criteria Displayed in the Table:
1. ⚠️ Momentum Slowdown
- Yes → Momentum is weakening (a good sign for reversal trades).
- No → The market is still moving strongly, and a reversal might not be ready yet.
2. 📈 RSI Extreme
- Yes → RSI is above 70 (overbought) or below 30 (oversold), indicating a potential reversal.
- No → RSI is still in a normal range, suggesting that waiting for further confirmation might be wise.
3. 📊 Uptrend Momentum Before Reversal
- Yes → There was a strong uptrend over multiple consecutive candles, potentially setting up for a Short Reversal.
- No → No strong upward momentum was detected, meaning conditions for a Short Reversal may not be ideal.
4. 📉 Downtrend Momentum Before Reversal
- Yes → There was a strong downtrend over multiple consecutive candles, potentially setting up for a Long Reversal.
- No → No strong downward momentum was detected, meaning conditions for a Long Reversal may not be ideal.
🛠️ How to Use the Indicator?
- If "✔ Ideal Reversal Setup" appears, there is a high probability of a market reversal – use your personal entry strategy for further confirmation.
- If Momentum Slowdown = Yes, RSI Extreme = Yes, and strong momentum occurred beforehand, this is an ideal setup for a reversal trade.
- If any conditions are missing ("No"), it may be better to wait for further confirmation instead of entering too early.
- The indicator does NOT provide trade entries! Use your existing trading system for confirmation before entering a trade.
👥 Who Is This Indicator For?
- Reversal traders (entering against the current trend after a strong move).
- Intraday traders looking for reversal trades at extreme market levels.
- Technical traders who rely on Price Action and Volume for trade setups.
⚠️ Disclaimer:
This indicator does not recommend trade entries but provides insight into market conditions. The trader is responsible for risk management and decision-making.
It is best used in combination with additional confirmations such as reversal candles, Order Flow, Bookmap, or Volume Profile to improve accuracy.
🚀 The indicator is ready to use – add it to TradingView and get instant feedback on whether the market is ideal for a Reversal trade!
Smart Money Concepts [Nitin]//@version=5
indicator("Smart Money Concepts ", "Smart Money Concepts "
, overlay = true
, max_labels_count = 500
, max_lines_count = 500
, max_boxes_count = 500
, max_bars_back = 500)
//-----------------------------------------------------------------------------{
//Constants
//-----------------------------------------------------------------------------{
color TRANSP_CSS = #ffffff00
//Tooltips
string MODE_TOOLTIP = 'Allows to display historical Structure or only the recent ones'
string STYLE_TOOLTIP = 'Indicator color theme'
string COLOR_CANDLES_TOOLTIP = 'Display additional candles with a color reflecting the current trend detected by structure'
string SHOW_INTERNAL = 'Display internal market structure'
string CONFLUENCE_FILTER = 'Filter non significant internal structure breakouts'
string SHOW_SWING = 'Display swing market Structure'
string SHOW_SWING_POINTS = 'Display swing point as labels on the chart'
string SHOW_SWHL_POINTS = 'Highlight most recent strong and weak high/low points on the chart'
string INTERNAL_OB = 'Display internal order blocks on the chart Number of internal order blocks to display on the chart'
string SWING_OB = 'Display swing order blocks on the chart Number of internal swing blocks to display on the chart'
string FILTER_OB = 'Method used to filter out volatile order blocks It is recommended to use the cumulative mean range method when a low amount of data is available'
string SHOW_EQHL = 'Display equal highs and equal lows on the chart'
string EQHL_BARS = 'Number of bars used to confirm equal highs and equal lows'
string EQHL_THRESHOLD = 'Sensitivity threshold in a range (0, 1) used for the detection of equal highs & lows Lower values will return fewer but more pertinent results'
string SHOW_FVG = 'Display fair values gaps on the chart'
string AUTO_FVG = 'Filter out non significant fair value gaps'
string FVG_TF = 'Fair value gaps timeframe'
string EXTEND_FVG = 'Determine how many bars to extend the Fair Value Gap boxes on chart'
string PED_ZONES = 'Display premium, discount, and equilibrium zones on chart'
//-----------------------------------------------------------------------------{
//Settings
//-----------------------------------------------------------------------------{
//General
//----------------------------------------{
mode = input.string('Historical'
, options =
, group = 'Smart Money Concepts'
, tooltip = MODE_TOOLTIP)
style = input.string('Colored'
, options =
, group = 'Smart Money Concepts'
, tooltip = STYLE_TOOLTIP)
show_trend = input(false, 'Color Candles'
, group = 'Smart Money Concepts'
, tooltip = COLOR_CANDLES_TOOLTIP)
//----------------------------------------}
//Internal Structure
//----------------------------------------{
show_internals = input(true, 'Show Internal Structure'
, group = 'Real Time Internal Structure'
, tooltip = SHOW_INTERNAL)
show_ibull = input.string('All', 'Bullish Structure'
, options =
, inline = 'ibull'
, group = 'Real Time Internal Structure')
swing_ibull_css = input(#089981, ''
, inline = 'ibull'
, group = 'Real Time Internal Structure')
//Bear Structure
show_ibear = input.string('All', 'Bearish Structure'
, options =
, inline = 'ibear'
, group = 'Real Time Internal Structure')
swing_ibear_css = input(#f23645, ''
, inline = 'ibear'
, group = 'Real Time Internal Structure')
ifilter_confluence = input(false, 'Confluence Filter'
, group = 'Real Time Internal Structure'
, tooltip = CONFLUENCE_FILTER)
//----------------------------------------}
//Swing Structure
//----------------------------------------{
show_Structure = input(true, 'Show Swing Structure'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING)
//Bull Structure
show_bull = input.string('All', 'Bullish Structure'
, options =
, inline = 'bull'
, group = 'Real Time Swing Structure')
swing_bull_css = input(#089981, ''
, inline = 'bull'
, group = 'Real Time Swing Structure')
//Bear Structure
show_bear = input.string('All', 'Bearish Structure'
, options =
, inline = 'bear'
, group = 'Real Time Swing Structure')
swing_bear_css = input(#f23645, ''
, inline = 'bear'
, group = 'Real Time Swing Structure')
//Swings
show_swings = input(false, 'Show Swings Points'
, inline = 'swings'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING_POINTS)
length = input.int(50, ''
, minval = 10
, inline = 'swings'
, group = 'Real Time Swing Structure')
show_hl_swings = input(true, 'Show Strong/Weak High/Low'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWHL_POINTS)
//----------------------------------------}
//Order Blocks
//----------------------------------------{
show_iob = input(true, 'Internal Order Blocks'
, inline = 'iob'
, group = 'Order Blocks'
, tooltip = INTERNAL_OB)
iob_showlast = input.int(5, ''
, minval = 1
, inline = 'iob'
, group = 'Order Blocks')
show_ob = input(false, 'Swing Order Blocks'
, inline = 'ob'
, group = 'Order Blocks'
, tooltip = SWING_OB)
ob_showlast = input.int(5, ''
, minval = 1
, inline = 'ob'
, group = 'Order Blocks')
ob_filter = input.string('Atr', 'Order Block Filter'
, options =
, group = 'Order Blocks'
, tooltip = FILTER_OB)
ibull_ob_css = input.color(color.new(#3179f5, 80), 'Internal Bullish OB'
, group = 'Order Blocks')
ibear_ob_css = input.color(color.new(#f77c80, 80), 'Internal Bearish OB'
, group = 'Order Blocks')
bull_ob_css = input.color(color.new(#1848cc, 80), 'Bullish OB'
, group = 'Order Blocks')
bear_ob_css = input.color(color.new(#b22833, 80), 'Bearish OB'
, group = 'Order Blocks')
//----------------------------------------}
//EQH/EQL
//----------------------------------------{
show_eq = input(true, 'Equal High/Low'
, group = 'EQH/EQL'
, tooltip = SHOW_EQHL)
eq_len = input.int(3, 'Bars Confirmation'
, minval = 1
, group = 'EQH/EQL'
, tooltip = EQHL_BARS)
eq_threshold = input.float(0.1, 'Threshold'
, minval = 0
, maxval = 0.5
, step = 0.1
, group = 'EQH/EQL'
, tooltip = EQHL_THRESHOLD)
//----------------------------------------}
//Fair Value Gaps
//----------------------------------------{
show_fvg = input(false, 'Fair Value Gaps'
, group = 'Fair Value Gaps'
, tooltip = SHOW_FVG)
fvg_auto = input(true, "Auto Threshold"
, group = 'Fair Value Gaps'
, tooltip = AUTO_FVG)
fvg_tf = input.timeframe('', "Timeframe"
, group = 'Fair Value Gaps'
, tooltip = FVG_TF)
bull_fvg_css = input.color(color.new(#00ff68, 70), 'Bullish FVG'
, group = 'Fair Value Gaps')
bear_fvg_css = input.color(color.new(#ff0008, 70), 'Bearish FVG'
, group = 'Fair Value Gaps')
fvg_extend = input.int(1, "Extend FVG"
, minval = 0
, group = 'Fair Value Gaps'
, tooltip = EXTEND_FVG)
//----------------------------------------}
//Previous day/week high/low
//----------------------------------------{
//Daily
show_pdhl = input(false, 'Daily'
, inline = 'daily'
, group = 'Highs & Lows MTF')
pdhl_style = input.string('⎯⎯⎯', ''
, options =
, inline = 'daily'
, group = 'Highs & Lows MTF')
pdhl_css = input(#2157f3, ''
, inline = 'daily'
, group = 'Highs & Lows MTF')
//Weekly
show_pwhl = input(false, 'Weekly'
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_style = input.string('⎯⎯⎯', ''
, options =
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_css = input(#2157f3, ''
, inline = 'weekly'
, group = 'Highs & Lows MTF')
//Monthly
show_pmhl = input(false, 'Monthly'
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_style = input.string('⎯⎯⎯', ''
, options =
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_css = input(#2157f3, ''
, inline = 'monthly'
, group = 'Highs & Lows MTF')
//----------------------------------------}
//Premium/Discount zones
//----------------------------------------{
show_sd = input(false, 'Premium/Discount Zones'
, group = 'Premium & Discount Zones'
, tooltip = PED_ZONES)
premium_css = input.color(#f23645, 'Premium Zone'
, group = 'Premium & Discount Zones')
eq_css = input.color(#b2b5be, 'Equilibrium Zone'
, group = 'Premium & Discount Zones')
discount_css = input.color(#089981, 'Discount Zone'
, group = 'Premium & Discount Zones')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index
atr = ta.atr(200)
cmean_range = ta.cum(high - low) / n
//HL Output function
hl() =>
//Get ohlc values function
get_ohlc()=> [close , open , high, low, high , low ]
//Display Structure function
display_Structure(x, y, txt, css, dashed, down, lbl_size)=>
structure_line = line.new(x, y, n, y
, color = css
, style = dashed ? line.style_dashed : line.style_solid)
structure_lbl = label.new(int(math.avg(x, n)), y, txt
, color = TRANSP_CSS
, textcolor = css
, style = down ? label.style_label_down : label.style_label_up
, size = lbl_size)
if mode == 'Present'
line.delete(structure_line )
label.delete(structure_lbl )
//Swings detection/measurements
swings(len)=>
var os = 0
upper = ta.highest(len)
lower = ta.lowest(len)
os := high > upper ? 0 : low < lower ? 1 : os
top = os == 0 and os != 0 ? high : 0
btm = os == 1 and os != 1 ? low : 0
//Order block coordinates function
ob_coord(use_max, loc, target_top, target_btm, target_left, target_type)=>
min = 99999999.
max = 0.
idx = 1
ob_threshold = ob_filter == 'Atr' ? atr : cmean_range
//Search for highest/lowest high within the structure interval and get range
if use_max
for i = 1 to (n - loc)-1
if (high - low ) < ob_threshold * 2
max := math.max(high , max)
min := max == high ? low : min
idx := max == high ? i : idx
else
for i = 1 to (n - loc)-1
if (high - low ) < ob_threshold * 2
min := math.min(low , min)
max := min == low ? high : max
idx := min == low ? i : idx
array.unshift(target_top, max)
array.unshift(target_btm, min)
array.unshift(target_left, time )
array.unshift(target_type, use_max ? -1 : 1)
//Set order blocks
display_ob(boxes, target_top, target_btm, target_left, target_type, show_last, swing, size)=>
for i = 0 to math.min(show_last-1, size-1)
get_box = array.get(boxes, i)
box.set_lefttop(get_box, array.get(target_left, i), array.get(target_top, i))
box.set_rightbottom(get_box, array.get(target_left, i), array.get(target_btm, i))
box.set_extend(get_box, extend.right)
color css = na
if swing
if style == 'Monochrome'
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
border_css = array.get(target_type, i) == 1 ? #b2b5be : #5d606b
box.set_border_color(get_box, border_css)
else
css := array.get(target_type, i) == 1 ? bull_ob_css : bear_ob_css
box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)
else
if style == 'Monochrome'
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
else
css := array.get(target_type, i) == 1 ? ibull_ob_css : ibear_ob_css
box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)
//Line Style function
get_line_style(style) =>
out = switch style
'⎯⎯⎯' => line.style_solid
'----' => line.style_dashed
'····' => line.style_dotted
//Set line/labels function for previous high/lows
phl(h, l, tf, css)=>
var line high_line = line.new(na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label high_lbl = label.new(na,na
, xloc = xloc.bar_time
, text = str.format('P{0}H', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
var line low_line = line.new(na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label low_lbl = label.new(na,na
, xloc = xloc.bar_time
, text = str.format('P{0}L', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
hy = ta.valuewhen(h != h , h, 1)
hx = ta.valuewhen(h == high, time, 1)
ly = ta.valuewhen(l != l , l, 1)
lx = ta.valuewhen(l == low, time, 1)
if barstate.islast
ext = time + (time - time )*20
//High
line.set_xy1(high_line, hx, hy)
line.set_xy2(high_line, ext, hy)
label.set_xy(high_lbl, ext, hy)
//Low
line.set_xy1(low_line, lx, ly)
line.set_xy2(low_line, ext, ly)
label.set_xy(low_lbl, ext, ly)
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
var trend = 0, var itrend = 0
var top_y = 0., var top_x = 0
var btm_y = 0., var btm_x = 0
var itop_y = 0., var itop_x = 0
var ibtm_y = 0., var ibtm_x = 0
var trail_up = high, var trail_dn = low
var trail_up_x = 0, var trail_dn_x = 0
var top_cross = true, var btm_cross = true
var itop_cross = true, var ibtm_cross = true
var txt_top = '', var txt_btm = ''
//Alerts
bull_choch_alert = false
bull_bos_alert = false
bear_choch_alert = false
bear_bos_alert = false
bull_ichoch_alert = false
bull_ibos_alert = false
bear_ichoch_alert = false
bear_ibos_alert = false
bull_iob_break = false
bear_iob_break = false
bull_ob_break = false
bear_ob_break = false
eqh_alert = false
eql_alert = false
//Structure colors
var bull_css = style == 'Monochrome' ? #b2b5be
: swing_bull_css
var bear_css = style == 'Monochrome' ? #b2b5be
: swing_bear_css
var ibull_css = style == 'Monochrome' ? #b2b5be
: swing_ibull_css
var ibear_css = style == 'Monochrome' ? #b2b5be
: swing_ibear_css
//Swings
= swings(length)
= swings(5)
//-----------------------------------------------------------------------------}
//Pivot High
//-----------------------------------------------------------------------------{
var line extend_top = na
var label extend_top_lbl = label.new(na, na
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.tiny)
if top
top_cross := true
txt_top := top > top_y ? 'HH' : 'LH'
if show_swings
top_lbl = label.new(n-length, top, txt_top
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.small)
if mode == 'Present'
label.delete(top_lbl )
//Extend recent top to last bar
line.delete(extend_top )
extend_top := line.new(n-length, top, n, top
, color = bear_css)
top_y := top
top_x := n - length
trail_up := top
trail_up_x := n - length
if itop
itop_cross := true
itop_y := itop
itop_x := n - 5
//Trailing maximum
trail_up := math.max(high, trail_up)
trail_up_x := trail_up == high ? n : trail_up_x
//Set top extension label/line
if barstate.islast and show_hl_swings
line.set_xy1(extend_top, trail_up_x, trail_up)
line.set_xy2(extend_top, n + 20, trail_up)
label.set_x(extend_top_lbl, n + 20)
label.set_y(extend_top_lbl, trail_up)
label.set_text(extend_top_lbl, trend < 0 ? 'Strong High' : 'Weak High')
//-----------------------------------------------------------------------------}
//Pivot Low
//-----------------------------------------------------------------------------{
var line extend_btm = na
var label extend_btm_lbl = label.new(na, na
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = size.tiny)
if btm
btm_cross := true
txt_btm := btm < btm_y ? 'LL' : 'HL'
if show_swings
btm_lbl = label.new(n - length, btm, txt_btm
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = size.small)
if mode == 'Present'
label.delete(btm_lbl )
//Extend recent btm to last bar
line.delete(extend_btm )
extend_btm := line.new(n - length, btm, n, btm
, color = bull_css)
btm_y := btm
btm_x := n-length
trail_dn := btm
trail_dn_x := n-length
if ibtm
ibtm_cross := true
ibtm_y := ibtm
ibtm_x := n - 5
//Trailing minimum
trail_dn := math.min(low, trail_dn)
trail_dn_x := trail_dn == low ? n : trail_dn_x
//Set btm extension label/line
if barstate.islast and show_hl_swings
line.set_xy1(extend_btm, trail_dn_x, trail_dn)
line.set_xy2(extend_btm, n + 20, trail_dn)
label.set_x(extend_btm_lbl, n + 20)
label.set_y(extend_btm_lbl, trail_dn)
label.set_text(extend_btm_lbl, trend > 0 ? 'Strong Low' : 'Weak Low')
//-----------------------------------------------------------------------------}
//Order Blocks Arrays
//-----------------------------------------------------------------------------{
var iob_top = array.new_float(0)
var iob_btm = array.new_float(0)
var iob_left = array.new_int(0)
var iob_type = array.new_int(0)
var ob_top = array.new_float(0)
var ob_btm = array.new_float(0)
var ob_left = array.new_int(0)
var ob_type = array.new_int(0)
//-----------------------------------------------------------------------------}
//Pivot High BOS/CHoCH
//-----------------------------------------------------------------------------{
//Filtering
var bull_concordant = true
if ifilter_confluence
bull_concordant := high - math.max(close, open) > math.min(close, open - low)
//Detect internal bullish Structure
if ta.crossover(close, itop_y) and itop_cross and top_y != itop_y and bull_concordant
bool choch = na
if itrend < 0
choch := true
bull_ichoch_alert := true
else
bull_ibos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_internals
if show_ibull == 'All' or (show_ibull == 'BOS' and not choch) or (show_ibull == 'CHoCH' and choch)
display_Structure(itop_x, itop_y, txt, ibull_css, true, true, size.tiny)
itop_cross := false
itrend := 1
//Internal Order Block
if show_iob
ob_coord(false, itop_x, iob_top, iob_btm, iob_left, iob_type)
//Detect bullish Structure
if ta.crossover(close, top_y) and top_cross
bool choch = na
if trend < 0
choch := true
bull_choch_alert := true
else
bull_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bull == 'All' or (show_bull == 'BOS' and not choch) or (show_bull == 'CHoCH' and choch)
display_Structure(top_x, top_y, txt, bull_css, false, true, size.small)
//Order Block
if show_ob
ob_coord(false, top_x, ob_top, ob_btm, ob_left, ob_type)
top_cross := false
trend := 1
//-----------------------------------------------------------------------------}
//Pivot Low BOS/CHoCH
//-----------------------------------------------------------------------------{
var bear_concordant = true
if ifilter_confluence
bear_concordant := high - math.max(close, open) < math.min(close, open - low)
//Detect internal bearish Structure
if ta.crossunder(close, ibtm_y) and ibtm_cross and btm_y != ibtm_y and bear_concordant
bool choch = false
if itrend > 0
choch := true
bear_ichoch_alert := true
else
bear_ibos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_internals
if show_ibear == 'All' or (show_ibear == 'BOS' and not choch) or (show_ibear == 'CHoCH' and choch)
display_Structure(ibtm_x, ibtm_y, txt, ibear_css, true, false, size.tiny)
ibtm_cross := false
itrend := -1
//Internal Order Block
if show_iob
ob_coord(true, ibtm_x, iob_top, iob_btm, iob_left, iob_type)
//Detect bearish Structure
if ta.crossunder(close, btm_y) and btm_cross
bool choch = na
if trend > 0
choch := true
bear_choch_alert := true
else
bear_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bear == 'All' or (show_bear == 'BOS' and not choch) or (show_bear == 'CHoCH' and choch)
display_Structure(btm_x, btm_y, txt, bear_css, false, false, size.small)
//Order Block
if show_ob
ob_coord(true, btm_x, ob_top, ob_btm, ob_left, ob_type)
btm_cross := false
trend := -1
//-----------------------------------------------------------------------------}
//Order Blocks
//-----------------------------------------------------------------------------{
//Set order blocks
var iob_boxes = array.new_box(0)
var ob_boxes = array.new_box(0)
//Delete internal order blocks box coordinates if top/bottom is broken
for element in iob_type
index = array.indexof(iob_type, element)
if close < array.get(iob_btm, index) and element == 1
array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bull_iob_break := true
else if close > array.get(iob_top, index) and element == -1
array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bear_iob_break := true
//Delete internal order blocks box coordinates if top/bottom is broken
for element in ob_type
index = array.indexof(ob_type, element)
if close < array.get(ob_btm, index) and element == 1
array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bull_ob_break := true
else if close > array.get(ob_top, index) and element == -1
array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bear_ob_break := true
iob_size = array.size(iob_type)
ob_size = array.size(ob_type)
if barstate.isfirst
if show_iob
for i = 0 to iob_showlast-1
array.push(iob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
if show_ob
for i = 0 to ob_showlast-1
array.push(ob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
if iob_size > 0
if barstate.islast
display_ob(iob_boxes, iob_top, iob_btm, iob_left, iob_type, iob_showlast, false, iob_size)
if ob_size > 0
if barstate.islast
display_ob(ob_boxes, ob_top, ob_btm, ob_left, ob_type, ob_showlast, true, ob_size)
//-----------------------------------------------------------------------------}
//EQH/EQL
//-----------------------------------------------------------------------------{
var eq_prev_top = 0.
var eq_top_x = 0
var eq_prev_btm = 0.
var eq_btm_x = 0
if show_eq
eq_top = ta.pivothigh(eq_len, eq_len)
eq_btm = ta.pivotlow(eq_len, eq_len)
if eq_top
max = math.max(eq_top, eq_prev_top)
min = math.min(eq_top, eq_prev_top)
if max < min + atr * eq_threshold
eqh_line = line.new(eq_top_x, eq_prev_top, n-eq_len, eq_top
, color = bear_css
, style = line.style_dotted)
eqh_lbl = label.new(int(math.avg(n-eq_len, eq_top_x)), eq_top, 'EQH'
, color = #00000000
, textcolor = bear_css
, style = label.style_label_down
, size = size.tiny)
if mode == 'Present'
line.delete(eqh_line )
label.delete(eqh_lbl )
eqh_alert := true
eq_prev_top := eq_top
eq_top_x := n-eq_len
if eq_btm
max = math.max(eq_btm, eq_prev_btm)
min = math.min(eq_btm, eq_prev_btm)
if min > max - atr * eq_threshold
eql_line = line.new(eq_btm_x, eq_prev_btm, n-eq_len, eq_btm
, color = bull_css
, style = line.style_dotted)
eql_lbl = label.new(int(math.avg(n-eq_len, eq_btm_x)), eq_btm, 'EQL'
, color = #00000000
, textcolor = bull_css
, style = label.style_label_up
, size = size.tiny)
eql_alert := true
if mode == 'Present'
line.delete(eql_line )
label.delete(eql_lbl )
eq_prev_btm := eq_btm
eq_btm_x := n-eq_len
//-----------------------------------------------------------------------------}
//Fair Value Gaps
//-----------------------------------------------------------------------------{
var bullish_fvg_max = array.new_box(0)
var bullish_fvg_min = array.new_box(0)
var bearish_fvg_max = array.new_box(0)
var bearish_fvg_min = array.new_box(0)
float bullish_fvg_avg = na
float bearish_fvg_avg = na
bullish_fvg_cnd = false
bearish_fvg_cnd = false
=
request.security(syminfo.tickerid, fvg_tf, get_ohlc())
if show_fvg
delta_per = (src_c1 - src_o1) / src_o1 * 100
change_tf = timeframe.change(fvg_tf)
threshold = fvg_auto ? ta.cum(math.abs(change_tf ? delta_per : 0)) / n * 2
: 0
//FVG conditions
bullish_fvg_cnd := src_l > src_h2
and src_c1 > src_h2
and delta_per > threshold
and change_tf
bearish_fvg_cnd := src_h < src_l2
and src_c1 < src_l2
and -delta_per > threshold
and change_tf
//FVG Areas
if bullish_fvg_cnd
array.unshift(bullish_fvg_max, box.new(n-1, src_l, n + fvg_extend, math.avg(src_l, src_h2)
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
array.unshift(bullish_fvg_min, box.new(n-1, math.avg(src_l, src_h2), n + fvg_extend, src_h2
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
if bearish_fvg_cnd
array.unshift(bearish_fvg_max, box.new(n-1, src_h, n + fvg_extend, math.avg(src_h, src_l2)
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))
array.unshift(bearish_fvg_min, box.new(n-1, math.avg(src_h, src_l2), n + fvg_extend, src_l2
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))
for bx in bullish_fvg_min
if low < box.get_bottom(bx)
box.delete(bx)
box.delete(array.get(bullish_fvg_max, array.indexof(bullish_fvg_min, bx)))
for bx in bearish_fvg_max
if high > box.get_top(bx)
box.delete(bx)
box.delete(array.get(bearish_fvg_min, array.indexof(bearish_fvg_max, bx)))
//-----------------------------------------------------------------------------}
//Previous day/week high/lows
//-----------------------------------------------------------------------------{
//Daily high/low
= request.security(syminfo.tickerid, 'D', hl()
, lookahead = barmerge.lookahead_on)
//Weekly high/low
= request.security(syminfo.tickerid, 'W', hl()
, lookahead = barmerge.lookahead_on)
//Monthly high/low
= request.security(syminfo.tickerid, 'M', hl()
, lookahead = barmerge.lookahead_on)
//Display Daily
if show_pdhl
phl(pdh, pdl, 'D', pdhl_css)
//Display Weekly
if show_pwhl
phl(pwh, pwl, 'W', pwhl_css)
//Display Monthly
if show_pmhl
phl(pmh, pml, 'M', pmhl_css)
//-----------------------------------------------------------------------------}
//Premium/Discount/Equilibrium zones
//-----------------------------------------------------------------------------{
var premium = box.new(na, na, na, na
, bgcolor = color.new(premium_css, 80)
, border_color = na)
var premium_lbl = label.new(na, na
, text = 'Premium'
, color = TRANSP_CSS
, textcolor = premium_css
, style = label.style_label_down
, size = size.small)
var eq = box.new(na, na, na, na
, bgcolor = color.rgb(120, 123, 134, 80)
, border_color = na)
var eq_lbl = label.new(na, na
, text = 'Equilibrium'
, color = TRANSP_CSS
, textcolor = eq_css
, style = label.style_label_left
, size = size.small)
var discount = box.new(na, na, na, na
, bgcolor = color.new(discount_css, 80)
, border_color = na)
var discount_lbl = label.new(na, na
, text = 'Discount'
, color = TRANSP_CSS
, textcolor = discount_css
, style = label.style_label_up
, size = size.small)
//Show Premium/Discount Areas
if barstate.islast and show_sd
avg = math.avg(trail_up, trail_dn)
box.set_lefttop(premium, math.max(top_x, btm_x), trail_up)
box.set_rightbottom(premium, n, .95 * trail_up + .05 * trail_dn)
label.set_xy(premium_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_up)
box.set_lefttop(eq, math.max(top_x, btm_x), .525 * trail_up + .475*trail_dn)
box.set_rightbottom(eq, n, .525 * trail_dn + .475 * trail_up)
label.set_xy(eq_lbl, n, avg)
box.set_lefttop(discount, math.max(top_x, btm_x), .95 * trail_dn + .05 * trail_up)
box.set_rightbottom(discount, n, trail_dn)
label.set_xy(discount_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_dn)
//-----------------------------------------------------------------------------}
//Trend
//-----------------------------------------------------------------------------{
var color trend_css = na
if show_trend
if style == 'Colored'
trend_css := itrend == 1 ? bull_css : bear_css
else if style == 'Monochrome'
trend_css := itrend == 1 ? #b2b5be : #5d606b
plotcandle(open, high, low, close
, color = trend_css
, wickcolor = trend_css
, bordercolor = trend_css
, editable = false)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//Internal Structure
alertcondition(bull_ibos_alert, 'Internal Bullish BOS', 'Internal Bullish BOS formed')
alertcondition(bull_ichoch_alert, 'Internal Bullish CHoCH', 'Internal Bullish CHoCH formed')
alertcondition(bear_ibos_alert, 'Internal Bearish BOS', 'Internal Bearish BOS formed')
alertcondition(bear_ichoch_alert, 'Internal Bearish CHoCH', 'Internal Bearish CHoCH formed')
//Swing Structure
alertcondition(bull_bos_alert, 'Bullish BOS', 'Internal Bullish BOS formed')
alertcondition(bull_choch_alert, 'Bullish CHoCH', 'Internal Bullish CHoCH formed')
alertcondition(bear_bos_alert, 'Bearish BOS', 'Bearish BOS formed')
alertcondition(bear_choch_alert, 'Bearish CHoCH', 'Bearish CHoCH formed')
//order Blocks
alertcondition(bull_iob_break, 'Bullish Internal OB Breakout', 'Price broke bullish iternal OB')
alertcondition(bear_iob_break, 'Bearish Internal OB Breakout', 'Price broke bearish iternal OB')
alertcondition(bull_ob_break, 'Bullish OB Breakout', 'Price broke bullish iternal OB')
alertcondition(bear_ob_break, 'bearish OB Breakout', 'Price broke bearish iternal OB')
//EQH/EQL
alertcondition(eqh_alert, 'Equal Highs', 'Equal highs detected')
alertcondition(eql_alert, 'Equal Lows', 'Equal lows detected')
//FVG
alertcondition(bullish_fvg_cnd, 'Bullish FVG', 'Bullish FVG formed')
alertcondition(bearish_fvg_cnd, 'Bearish FVG', 'Bearish FVG formed')
//-----------------------------------
Optimized Smart Money Concept for BTCUSDThis indicator identifies breakout patterns in BTCUSD and calculates potential entry points, stop losses, and take profits based on a user-defined risk/reward ratio. It visually marks these levels on the chart, making it easier for traders to spot opportunities.
To optimize this indicator for BTCUSD, we should consider a few factors specific to Bitcoin's price action, such as its volatility, market behavior, and typical patterns. Here's a list of potential adjustments to improve the performance of the strategy for BTCUSD:
1. Volatility Considerations: BTCUSD tends to experience higher volatility, so we might want to adjust the stop-loss and take-profit levels to accommodate these fluctuations.
2. Period Lengths: Bitcoin's price action may respond better to different period lengths for indicators like RSI, MACD, and the swing points.
3. Breakout Conditions: Bitcoin often experiences significant breakouts, so optimizing the breakout pattern and using larger lookback periods for detecting support and resistance might help improve the signal accuracy.
4. Risk/Reward Ratio: You might want to experiment with a wider risk/reward ratio for BTCUSD, given its price swings.
withoutfaking Advanced charts readerFeatures:
1. Multi-Timeframe Adaptive:
- Triple EMA system (21/50/200) identifies macro/micro trends
- ADX filter ensures trades only in strong momentum phases
2. Elliott Wave Integration:
- Proprietary EWO (Elliott Wave Oscillator) with signal line
- Detects wave 3 acceleration and wave 5 exhaustion
3. Smart Money Detection:
- Volume-weighted MFI filters false breakouts
- Combined with Stochastic for precision timing
4. Adaptive Alerts:
- Multi-condition confluence required for signals
- Self-adjusting to any timeframe (1m - monthly)
Usage:
- Day Trading: Use on 5-15m charts with tighter EMA settings
- Swing Trading: Apply on 1H-4H with default parameters
- Investing: Weekly/Monthly charts with 50/200 EMA cross
Signal Logic:
- Entries require 5/34 EWO cross + EMA alignment + volume confirmation
- Exits trigger at opposing MFI extreme + EMA flip
Risk Management:
- Bullish signals invalidate below 21 EMA
- Bearish signals cancel above 50 EMA
This system combines institutional flow analysis with technical patterns, designed to adapt to both mean-reverting and trending markets.
MACD with Candle DisplayMACD Calculation:
Uses user-defined Fast Length, Slow Length, and Signal Smoothing parameters to compute MACD.
Supports SMA (Simple Moving Average) or EMA (Exponential Moving Average) for the MACD line and signal line
Histogram-Based Candle Coloring:
The script categorizes histogram bars into four states:
0 (Very Bullish) → Green
1 (Likely Bearish) → Blue
2 (Likely Bullish) → Orange
3 (Very Bearish) → Red
Histogram Plot:
Displays histogram bars with distinct colors based on price momentum changes.
Market Sentiment Display in Status Line & Price Scale:
Instead of adding a label on the chart (which could obstruct candles), a text display is shown in the price scale and status line:
"0 Very Bullish"
"1 Likely Bearish"
"2 Likely Bullish"
"3 Very Bearish"
The text appears in the top-right corner with white font on a black background.
Purpose:
This indicator enhances the standard MACD by incorporating candle coloring and a cleaner sentiment display in the price scale, helping traders quickly interpret market momentum without cluttering the chart.
Smart Money Concepts [Nitin]//@version=5
indicator("Smart Money Concepts ", "Smart Money Concepts "
, overlay = true
, max_labels_count = 500
, max_lines_count = 500
, max_boxes_count = 500
, max_bars_back = 500)
//-----------------------------------------------------------------------------{
//Constants
//-----------------------------------------------------------------------------{
color TRANSP_CSS = #ffffff00
//Tooltips
string MODE_TOOLTIP = 'Allows to display historical Structure or only the recent ones'
string STYLE_TOOLTIP = 'Indicator color theme'
string COLOR_CANDLES_TOOLTIP = 'Display additional candles with a color reflecting the current trend detected by structure'
string SHOW_INTERNAL = 'Display internal market structure'
string CONFLUENCE_FILTER = 'Filter non significant internal structure breakouts'
string SHOW_SWING = 'Display swing market Structure'
string SHOW_SWING_POINTS = 'Display swing point as labels on the chart'
string SHOW_SWHL_POINTS = 'Highlight most recent strong and weak high/low points on the chart'
string INTERNAL_OB = 'Display internal order blocks on the chart Number of internal order blocks to display on the chart'
string SWING_OB = 'Display swing order blocks on the chart Number of internal swing blocks to display on the chart'
string FILTER_OB = 'Method used to filter out volatile order blocks It is recommended to use the cumulative mean range method when a low amount of data is available'
string SHOW_EQHL = 'Display equal highs and equal lows on the chart'
string EQHL_BARS = 'Number of bars used to confirm equal highs and equal lows'
string EQHL_THRESHOLD = 'Sensitivity threshold in a range (0, 1) used for the detection of equal highs & lows Lower values will return fewer but more pertinent results'
string SHOW_FVG = 'Display fair values gaps on the chart'
string AUTO_FVG = 'Filter out non significant fair value gaps'
string FVG_TF = 'Fair value gaps timeframe'
string EXTEND_FVG = 'Determine how many bars to extend the Fair Value Gap boxes on chart'
string PED_ZONES = 'Display premium, discount, and equilibrium zones on chart'
//-----------------------------------------------------------------------------{
//Settings
//-----------------------------------------------------------------------------{
//General
//----------------------------------------{
mode = input.string('Historical'
, options =
, group = 'Smart Money Concepts'
, tooltip = MODE_TOOLTIP)
style = input.string('Colored'
, options =
, group = 'Smart Money Concepts'
, tooltip = STYLE_TOOLTIP)
show_trend = input(false, 'Color Candles'
, group = 'Smart Money Concepts'
, tooltip = COLOR_CANDLES_TOOLTIP)
//----------------------------------------}
//Internal Structure
//----------------------------------------{
show_internals = input(true, 'Show Internal Structure'
, group = 'Real Time Internal Structure'
, tooltip = SHOW_INTERNAL)
show_ibull = input.string('All', 'Bullish Structure'
, options =
, inline = 'ibull'
, group = 'Real Time Internal Structure')
swing_ibull_css = input(#089981, ''
, inline = 'ibull'
, group = 'Real Time Internal Structure')
//Bear Structure
show_ibear = input.string('All', 'Bearish Structure'
, options =
, inline = 'ibear'
, group = 'Real Time Internal Structure')
swing_ibear_css = input(#f23645, ''
, inline = 'ibear'
, group = 'Real Time Internal Structure')
ifilter_confluence = input(false, 'Confluence Filter'
, group = 'Real Time Internal Structure'
, tooltip = CONFLUENCE_FILTER)
//----------------------------------------}
//Swing Structure
//----------------------------------------{
show_Structure = input(true, 'Show Swing Structure'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING)
//Bull Structure
show_bull = input.string('All', 'Bullish Structure'
, options =
, inline = 'bull'
, group = 'Real Time Swing Structure')
swing_bull_css = input(#089981, ''
, inline = 'bull'
, group = 'Real Time Swing Structure')
//Bear Structure
show_bear = input.string('All', 'Bearish Structure'
, options =
, inline = 'bear'
, group = 'Real Time Swing Structure')
swing_bear_css = input(#f23645, ''
, inline = 'bear'
, group = 'Real Time Swing Structure')
//Swings
show_swings = input(false, 'Show Swings Points'
, inline = 'swings'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING_POINTS)
length = input.int(50, ''
, minval = 10
, inline = 'swings'
, group = 'Real Time Swing Structure')
show_hl_swings = input(true, 'Show Strong/Weak High/Low'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWHL_POINTS)
//----------------------------------------}
//Order Blocks
//----------------------------------------{
show_iob = input(true, 'Internal Order Blocks'
, inline = 'iob'
, group = 'Order Blocks'
, tooltip = INTERNAL_OB)
iob_showlast = input.int(5, ''
, minval = 1
, inline = 'iob'
, group = 'Order Blocks')
show_ob = input(false, 'Swing Order Blocks'
, inline = 'ob'
, group = 'Order Blocks'
, tooltip = SWING_OB)
ob_showlast = input.int(5, ''
, minval = 1
, inline = 'ob'
, group = 'Order Blocks')
ob_filter = input.string('Atr', 'Order Block Filter'
, options =
, group = 'Order Blocks'
, tooltip = FILTER_OB)
ibull_ob_css = input.color(color.new(#3179f5, 80), 'Internal Bullish OB'
, group = 'Order Blocks')
ibear_ob_css = input.color(color.new(#f77c80, 80), 'Internal Bearish OB'
, group = 'Order Blocks')
bull_ob_css = input.color(color.new(#1848cc, 80), 'Bullish OB'
, group = 'Order Blocks')
bear_ob_css = input.color(color.new(#b22833, 80), 'Bearish OB'
, group = 'Order Blocks')
//----------------------------------------}
//EQH/EQL
//----------------------------------------{
show_eq = input(true, 'Equal High/Low'
, group = 'EQH/EQL'
, tooltip = SHOW_EQHL)
eq_len = input.int(3, 'Bars Confirmation'
, minval = 1
, group = 'EQH/EQL'
, tooltip = EQHL_BARS)
eq_threshold = input.float(0.1, 'Threshold'
, minval = 0
, maxval = 0.5
, step = 0.1
, group = 'EQH/EQL'
, tooltip = EQHL_THRESHOLD)
//----------------------------------------}
//Fair Value Gaps
//----------------------------------------{
show_fvg = input(false, 'Fair Value Gaps'
, group = 'Fair Value Gaps'
, tooltip = SHOW_FVG)
fvg_auto = input(true, "Auto Threshold"
, group = 'Fair Value Gaps'
, tooltip = AUTO_FVG)
fvg_tf = input.timeframe('', "Timeframe"
, group = 'Fair Value Gaps'
, tooltip = FVG_TF)
bull_fvg_css = input.color(color.new(#00ff68, 70), 'Bullish FVG'
, group = 'Fair Value Gaps')
bear_fvg_css = input.color(color.new(#ff0008, 70), 'Bearish FVG'
, group = 'Fair Value Gaps')
fvg_extend = input.int(1, "Extend FVG"
, minval = 0
, group = 'Fair Value Gaps'
, tooltip = EXTEND_FVG)
//----------------------------------------}
//Previous day/week high/low
//----------------------------------------{
//Daily
show_pdhl = input(false, 'Daily'
, inline = 'daily'
, group = 'Highs & Lows MTF')
pdhl_style = input.string('⎯⎯⎯', ''
, options =
, inline = 'daily'
, group = 'Highs & Lows MTF')
pdhl_css = input(#2157f3, ''
, inline = 'daily'
, group = 'Highs & Lows MTF')
//Weekly
show_pwhl = input(false, 'Weekly'
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_style = input.string('⎯⎯⎯', ''
, options =
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_css = input(#2157f3, ''
, inline = 'weekly'
, group = 'Highs & Lows MTF')
//Monthly
show_pmhl = input(false, 'Monthly'
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_style = input.string('⎯⎯⎯', ''
, options =
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_css = input(#2157f3, ''
, inline = 'monthly'
, group = 'Highs & Lows MTF')
//----------------------------------------}
//Premium/Discount zones
//----------------------------------------{
show_sd = input(false, 'Premium/Discount Zones'
, group = 'Premium & Discount Zones'
, tooltip = PED_ZONES)
premium_css = input.color(#f23645, 'Premium Zone'
, group = 'Premium & Discount Zones')
eq_css = input.color(#b2b5be, 'Equilibrium Zone'
, group = 'Premium & Discount Zones')
discount_css = input.color(#089981, 'Discount Zone'
, group = 'Premium & Discount Zones')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index
atr = ta.atr(200)
cmean_range = ta.cum(high - low) / n
//HL Output function
hl() =>
//Get ohlc values function
get_ohlc()=> [close , open , high, low, high , low ]
//Display Structure function
display_Structure(x, y, txt, css, dashed, down, lbl_size)=>
structure_line = line.new(x, y, n, y
, color = css
, style = dashed ? line.style_dashed : line.style_solid)
structure_lbl = label.new(int(math.avg(x, n)), y, txt
, color = TRANSP_CSS
, textcolor = css
, style = down ? label.style_label_down : label.style_label_up
, size = lbl_size)
if mode == 'Present'
line.delete(structure_line )
label.delete(structure_lbl )
//Swings detection/measurements
swings(len)=>
var os = 0
upper = ta.highest(len)
lower = ta.lowest(len)
os := high > upper ? 0 : low < lower ? 1 : os
top = os == 0 and os != 0 ? high : 0
btm = os == 1 and os != 1 ? low : 0
//Order block coordinates function
ob_coord(use_max, loc, target_top, target_btm, target_left, target_type)=>
min = 99999999.
max = 0.
idx = 1
ob_threshold = ob_filter == 'Atr' ? atr : cmean_range
//Search for highest/lowest high within the structure interval and get range
if use_max
for i = 1 to (n - loc)-1
if (high - low ) < ob_threshold * 2
max := math.max(high , max)
min := max == high ? low : min
idx := max == high ? i : idx
else
for i = 1 to (n - loc)-1
if (high - low ) < ob_threshold * 2
min := math.min(low , min)
max := min == low ? high : max
idx := min == low ? i : idx
array.unshift(target_top, max)
array.unshift(target_btm, min)
array.unshift(target_left, time )
array.unshift(target_type, use_max ? -1 : 1)
//Set order blocks
display_ob(boxes, target_top, target_btm, target_left, target_type, show_last, swing, size)=>
for i = 0 to math.min(show_last-1, size-1)
get_box = array.get(boxes, i)
box.set_lefttop(get_box, array.get(target_left, i), array.get(target_top, i))
box.set_rightbottom(get_box, array.get(target_left, i), array.get(target_btm, i))
box.set_extend(get_box, extend.right)
color css = na
if swing
if style == 'Monochrome'
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
border_css = array.get(target_type, i) == 1 ? #b2b5be : #5d606b
box.set_border_color(get_box, border_css)
else
css := array.get(target_type, i) == 1 ? bull_ob_css : bear_ob_css
box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)
else
if style == 'Monochrome'
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
else
css := array.get(target_type, i) == 1 ? ibull_ob_css : ibear_ob_css
box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)
//Line Style function
get_line_style(style) =>
out = switch style
'⎯⎯⎯' => line.style_solid
'----' => line.style_dashed
'····' => line.style_dotted
//Set line/labels function for previous high/lows
phl(h, l, tf, css)=>
var line high_line = line.new(na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label high_lbl = label.new(na,na
, xloc = xloc.bar_time
, text = str.format('P{0}H', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
var line low_line = line.new(na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label low_lbl = label.new(na,na
, xloc = xloc.bar_time
, text = str.format('P{0}L', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
hy = ta.valuewhen(h != h , h, 1)
hx = ta.valuewhen(h == high, time, 1)
ly = ta.valuewhen(l != l , l, 1)
lx = ta.valuewhen(l == low, time, 1)
if barstate.islast
ext = time + (time - time )*20
//High
line.set_xy1(high_line, hx, hy)
line.set_xy2(high_line, ext, hy)
label.set_xy(high_lbl, ext, hy)
//Low
line.set_xy1(low_line, lx, ly)
line.set_xy2(low_line, ext, ly)
label.set_xy(low_lbl, ext, ly)
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
var trend = 0, var itrend = 0
var top_y = 0., var top_x = 0
var btm_y = 0., var btm_x = 0
var itop_y = 0., var itop_x = 0
var ibtm_y = 0., var ibtm_x = 0
var trail_up = high, var trail_dn = low
var trail_up_x = 0, var trail_dn_x = 0
var top_cross = true, var btm_cross = true
var itop_cross = true, var ibtm_cross = true
var txt_top = '', var txt_btm = ''
//Alerts
bull_choch_alert = false
bull_bos_alert = false
bear_choch_alert = false
bear_bos_alert = false
bull_ichoch_alert = false
bull_ibos_alert = false
bear_ichoch_alert = false
bear_ibos_alert = false
bull_iob_break = false
bear_iob_break = false
bull_ob_break = false
bear_ob_break = false
eqh_alert = false
eql_alert = false
//Structure colors
var bull_css = style == 'Monochrome' ? #b2b5be
: swing_bull_css
var bear_css = style == 'Monochrome' ? #b2b5be
: swing_bear_css
var ibull_css = style == 'Monochrome' ? #b2b5be
: swing_ibull_css
var ibear_css = style == 'Monochrome' ? #b2b5be
: swing_ibear_css
//Swings
= swings(length)
= swings(5)
//-----------------------------------------------------------------------------}
//Pivot High
//-----------------------------------------------------------------------------{
var line extend_top = na
var label extend_top_lbl = label.new(na, na
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.tiny)
if top
top_cross := true
txt_top := top > top_y ? 'HH' : 'LH'
if show_swings
top_lbl = label.new(n-length, top, txt_top
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.small)
if mode == 'Present'
label.delete(top_lbl )
//Extend recent top to last bar
line.delete(extend_top )
extend_top := line.new(n-length, top, n, top
, color = bear_css)
top_y := top
top_x := n - length
trail_up := top
trail_up_x := n - length
if itop
itop_cross := true
itop_y := itop
itop_x := n - 5
//Trailing maximum
trail_up := math.max(high, trail_up)
trail_up_x := trail_up == high ? n : trail_up_x
//Set top extension label/line
if barstate.islast and show_hl_swings
line.set_xy1(extend_top, trail_up_x, trail_up)
line.set_xy2(extend_top, n + 20, trail_up)
label.set_x(extend_top_lbl, n + 20)
label.set_y(extend_top_lbl, trail_up)
label.set_text(extend_top_lbl, trend < 0 ? 'Strong High' : 'Weak High')
//-----------------------------------------------------------------------------}
//Pivot Low
//-----------------------------------------------------------------------------{
var line extend_btm = na
var label extend_btm_lbl = label.new(na, na
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = size.tiny)
if btm
btm_cross := true
txt_btm := btm < btm_y ? 'LL' : 'HL'
if show_swings
btm_lbl = label.new(n - length, btm, txt_btm
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = size.small)
if mode == 'Present'
label.delete(btm_lbl )
//Extend recent btm to last bar
line.delete(extend_btm )
extend_btm := line.new(n - length, btm, n, btm
, color = bull_css)
btm_y := btm
btm_x := n-length
trail_dn := btm
trail_dn_x := n-length
if ibtm
ibtm_cross := true
ibtm_y := ibtm
ibtm_x := n - 5
//Trailing minimum
trail_dn := math.min(low, trail_dn)
trail_dn_x := trail_dn == low ? n : trail_dn_x
//Set btm extension label/line
if barstate.islast and show_hl_swings
line.set_xy1(extend_btm, trail_dn_x, trail_dn)
line.set_xy2(extend_btm, n + 20, trail_dn)
label.set_x(extend_btm_lbl, n + 20)
label.set_y(extend_btm_lbl, trail_dn)
label.set_text(extend_btm_lbl, trend > 0 ? 'Strong Low' : 'Weak Low')
//-----------------------------------------------------------------------------}
//Order Blocks Arrays
//-----------------------------------------------------------------------------{
var iob_top = array.new_float(0)
var iob_btm = array.new_float(0)
var iob_left = array.new_int(0)
var iob_type = array.new_int(0)
var ob_top = array.new_float(0)
var ob_btm = array.new_float(0)
var ob_left = array.new_int(0)
var ob_type = array.new_int(0)
//-----------------------------------------------------------------------------}
//Pivot High BOS/CHoCH
//-----------------------------------------------------------------------------{
//Filtering
var bull_concordant = true
if ifilter_confluence
bull_concordant := high - math.max(close, open) > math.min(close, open - low)
//Detect internal bullish Structure
if ta.crossover(close, itop_y) and itop_cross and top_y != itop_y and bull_concordant
bool choch = na
if itrend < 0
choch := true
bull_ichoch_alert := true
else
bull_ibos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_internals
if show_ibull == 'All' or (show_ibull == 'BOS' and not choch) or (show_ibull == 'CHoCH' and choch)
display_Structure(itop_x, itop_y, txt, ibull_css, true, true, size.tiny)
itop_cross := false
itrend := 1
//Internal Order Block
if show_iob
ob_coord(false, itop_x, iob_top, iob_btm, iob_left, iob_type)
//Detect bullish Structure
if ta.crossover(close, top_y) and top_cross
bool choch = na
if trend < 0
choch := true
bull_choch_alert := true
else
bull_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bull == 'All' or (show_bull == 'BOS' and not choch) or (show_bull == 'CHoCH' and choch)
display_Structure(top_x, top_y, txt, bull_css, false, true, size.small)
//Order Block
if show_ob
ob_coord(false, top_x, ob_top, ob_btm, ob_left, ob_type)
top_cross := false
trend := 1
//-----------------------------------------------------------------------------}
//Pivot Low BOS/CHoCH
//-----------------------------------------------------------------------------{
var bear_concordant = true
if ifilter_confluence
bear_concordant := high - math.max(close, open) < math.min(close, open - low)
//Detect internal bearish Structure
if ta.crossunder(close, ibtm_y) and ibtm_cross and btm_y != ibtm_y and bear_concordant
bool choch = false
if itrend > 0
choch := true
bear_ichoch_alert := true
else
bear_ibos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_internals
if show_ibear == 'All' or (show_ibear == 'BOS' and not choch) or (show_ibear == 'CHoCH' and choch)
display_Structure(ibtm_x, ibtm_y, txt, ibear_css, true, false, size.tiny)
ibtm_cross := false
itrend := -1
//Internal Order Block
if show_iob
ob_coord(true, ibtm_x, iob_top, iob_btm, iob_left, iob_type)
//Detect bearish Structure
if ta.crossunder(close, btm_y) and btm_cross
bool choch = na
if trend > 0
choch := true
bear_choch_alert := true
else
bear_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bear == 'All' or (show_bear == 'BOS' and not choch) or (show_bear == 'CHoCH' and choch)
display_Structure(btm_x, btm_y, txt, bear_css, false, false, size.small)
//Order Block
if show_ob
ob_coord(true, btm_x, ob_top, ob_btm, ob_left, ob_type)
btm_cross := false
trend := -1
//-----------------------------------------------------------------------------}
//Order Blocks
//-----------------------------------------------------------------------------{
//Set order blocks
var iob_boxes = array.new_box(0)
var ob_boxes = array.new_box(0)
//Delete internal order blocks box coordinates if top/bottom is broken
for element in iob_type
index = array.indexof(iob_type, element)
if close < array.get(iob_btm, index) and element == 1
array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bull_iob_break := true
else if close > array.get(iob_top, index) and element == -1
array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bear_iob_break := true
//Delete internal order blocks box coordinates if top/bottom is broken
for element in ob_type
index = array.indexof(ob_type, element)
if close < array.get(ob_btm, index) and element == 1
array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bull_ob_break := true
else if close > array.get(ob_top, index) and element == -1
array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bear_ob_break := true
iob_size = array.size(iob_type)
ob_size = array.size(ob_type)
if barstate.isfirst
if show_iob
for i = 0 to iob_showlast-1
array.push(iob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
if show_ob
for i = 0 to ob_showlast-1
array.push(ob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
if iob_size > 0
if barstate.islast
display_ob(iob_boxes, iob_top, iob_btm, iob_left, iob_type, iob_showlast, false, iob_size)
if ob_size > 0
if barstate.islast
display_ob(ob_boxes, ob_top, ob_btm, ob_left, ob_type, ob_showlast, true, ob_size)
//-----------------------------------------------------------------------------}
//EQH/EQL
//-----------------------------------------------------------------------------{
var eq_prev_top = 0.
var eq_top_x = 0
var eq_prev_btm = 0.
var eq_btm_x = 0
if show_eq
eq_top = ta.pivothigh(eq_len, eq_len)
eq_btm = ta.pivotlow(eq_len, eq_len)
if eq_top
max = math.max(eq_top, eq_prev_top)
min = math.min(eq_top, eq_prev_top)
if max < min + atr * eq_threshold
eqh_line = line.new(eq_top_x, eq_prev_top, n-eq_len, eq_top
, color = bear_css
, style = line.style_dotted)
eqh_lbl = label.new(int(math.avg(n-eq_len, eq_top_x)), eq_top, 'EQH'
, color = #00000000
, textcolor = bear_css
, style = label.style_label_down
, size = size.tiny)
if mode == 'Present'
line.delete(eqh_line )
label.delete(eqh_lbl )
eqh_alert := true
eq_prev_top := eq_top
eq_top_x := n-eq_len
if eq_btm
max = math.max(eq_btm, eq_prev_btm)
min = math.min(eq_btm, eq_prev_btm)
if min > max - atr * eq_threshold
eql_line = line.new(eq_btm_x, eq_prev_btm, n-eq_len, eq_btm
, color = bull_css
, style = line.style_dotted)
eql_lbl = label.new(int(math.avg(n-eq_len, eq_btm_x)), eq_btm, 'EQL'
, color = #00000000
, textcolor = bull_css
, style = label.style_label_up
, size = size.tiny)
eql_alert := true
if mode == 'Present'
line.delete(eql_line )
label.delete(eql_lbl )
eq_prev_btm := eq_btm
eq_btm_x := n-eq_len
//-----------------------------------------------------------------------------}
//Fair Value Gaps
//-----------------------------------------------------------------------------{
var bullish_fvg_max = array.new_box(0)
var bullish_fvg_min = array.new_box(0)
var bearish_fvg_max = array.new_box(0)
var bearish_fvg_min = array.new_box(0)
float bullish_fvg_avg = na
float bearish_fvg_avg = na
bullish_fvg_cnd = false
bearish_fvg_cnd = false
=
request.security(syminfo.tickerid, fvg_tf, get_ohlc())
if show_fvg
delta_per = (src_c1 - src_o1) / src_o1 * 100
change_tf = timeframe.change(fvg_tf)
threshold = fvg_auto ? ta.cum(math.abs(change_tf ? delta_per : 0)) / n * 2
: 0
//FVG conditions
bullish_fvg_cnd := src_l > src_h2
and src_c1 > src_h2
and delta_per > threshold
and change_tf
bearish_fvg_cnd := src_h < src_l2
and src_c1 < src_l2
and -delta_per > threshold
and change_tf
//FVG Areas
if bullish_fvg_cnd
array.unshift(bullish_fvg_max, box.new(n-1, src_l, n + fvg_extend, math.avg(src_l, src_h2)
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
array.unshift(bullish_fvg_min, box.new(n-1, math.avg(src_l, src_h2), n + fvg_extend, src_h2
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
if bearish_fvg_cnd
array.unshift(bearish_fvg_max, box.new(n-1, src_h, n + fvg_extend, math.avg(src_h, src_l2)
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))
array.unshift(bearish_fvg_min, box.new(n-1, math.avg(src_h, src_l2), n + fvg_extend, src_l2
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))
for bx in bullish_fvg_min
if low < box.get_bottom(bx)
box.delete(bx)
box.delete(array.get(bullish_fvg_max, array.indexof(bullish_fvg_min, bx)))
for bx in bearish_fvg_max
if high > box.get_top(bx)
box.delete(bx)
box.delete(array.get(bearish_fvg_min, array.indexof(bearish_fvg_max, bx)))
//-----------------------------------------------------------------------------}
//Previous day/week high/lows
//-----------------------------------------------------------------------------{
//Daily high/low
= request.security(syminfo.tickerid, 'D', hl()
, lookahead = barmerge.lookahead_on)
//Weekly high/low
= request.security(syminfo.tickerid, 'W', hl()
, lookahead = barmerge.lookahead_on)
//Monthly high/low
= request.security(syminfo.tickerid, 'M', hl()
, lookahead = barmerge.lookahead_on)
//Display Daily
if show_pdhl
phl(pdh, pdl, 'D', pdhl_css)
//Display Weekly
if show_pwhl
phl(pwh, pwl, 'W', pwhl_css)
//Display Monthly
if show_pmhl
phl(pmh, pml, 'M', pmhl_css)
//-----------------------------------------------------------------------------}
//Premium/Discount/Equilibrium zones
//-----------------------------------------------------------------------------{
var premium = box.new(na, na, na, na
, bgcolor = color.new(premium_css, 80)
, border_color = na)
var premium_lbl = label.new(na, na
, text = 'Premium'
, color = TRANSP_CSS
, textcolor = premium_css
, style = label.style_label_down
, size = size.small)
var eq = box.new(na, na, na, na
, bgcolor = color.rgb(120, 123, 134, 80)
, border_color = na)
var eq_lbl = label.new(na, na
, text = 'Equilibrium'
, color = TRANSP_CSS
, textcolor = eq_css
, style = label.style_label_left
, size = size.small)
var discount = box.new(na, na, na, na
, bgcolor = color.new(discount_css, 80)
, border_color = na)
var discount_lbl = label.new(na, na
, text = 'Discount'
, color = TRANSP_CSS
, textcolor = discount_css
, style = label.style_label_up
, size = size.small)
//Show Premium/Discount Areas
if barstate.islast and show_sd
avg = math.avg(trail_up, trail_dn)
box.set_lefttop(premium, math.max(top_x, btm_x), trail_up)
box.set_rightbottom(premium, n, .95 * trail_up + .05 * trail_dn)
label.set_xy(premium_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_up)
box.set_lefttop(eq, math.max(top_x, btm_x), .525 * trail_up + .475*trail_dn)
box.set_rightbottom(eq, n, .525 * trail_dn + .475 * trail_up)
label.set_xy(eq_lbl, n, avg)
box.set_lefttop(discount, math.max(top_x, btm_x), .95 * trail_dn + .05 * trail_up)
box.set_rightbottom(discount, n, trail_dn)
label.set_xy(discount_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_dn)
//-----------------------------------------------------------------------------}
//Trend
//-----------------------------------------------------------------------------{
var color trend_css = na
if show_trend
if style == 'Colored'
trend_css := itrend == 1 ? bull_css : bear_css
else if style == 'Monochrome'
trend_css := itrend == 1 ? #b2b5be : #5d606b
plotcandle(open, high, low, close
, color = trend_css
, wickcolor = trend_css
, bordercolor = trend_css
, editable = false)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//Internal Structure
alertcondition(bull_ibos_alert, 'Internal Bullish BOS', 'Internal Bullish BOS formed')
alertcondition(bull_ichoch_alert, 'Internal Bullish CHoCH', 'Internal Bullish CHoCH formed')
alertcondition(bear_ibos_alert, 'Internal Bearish BOS', 'Internal Bearish BOS formed')
alertcondition(bear_ichoch_alert, 'Internal Bearish CHoCH', 'Internal Bearish CHoCH formed')
//Swing Structure
alertcondition(bull_bos_alert, 'Bullish BOS', 'Internal Bullish BOS formed')
alertcondition(bull_choch_alert, 'Bullish CHoCH', 'Internal Bullish CHoCH formed')
alertcondition(bear_bos_alert, 'Bearish BOS', 'Bearish BOS formed')
alertcondition(bear_choch_alert, 'Bearish CHoCH', 'Bearish CHoCH formed')
//order Blocks
alertcondition(bull_iob_break, 'Bullish Internal OB Breakout', 'Price broke bullish iternal OB')
alertcondition(bear_iob_break, 'Bearish Internal OB Breakout', 'Price broke bearish iternal OB')
alertcondition(bull_ob_break, 'Bullish OB Breakout', 'Price broke bullish iternal OB')
alertcondition(bear_ob_break, 'bearish OB Breakout', 'Price broke bearish iternal OB')
//EQH/EQL
alertcondition(eqh_alert, 'Equal Highs', 'Equal highs detected')
alertcondition(eql_alert, 'Equal Lows', 'Equal lows detected')
//FVG
alertcondition(bullish_fvg_cnd, 'Bullish FVG', 'Bullish FVG formed')
alertcondition(bearish_fvg_cnd, 'Bearish FVG', 'Bearish FVG formed')
//-----------------------------------
Nadaraya-Watson Backtest with FiltersBuilding upon 'Non-Repainting Nadaraya-Watson Envelope ' to include optional entry and exit filters to backtest strategy and increase potential profitability.
Filters include:
- Target Profit
- Target Stop Loss Percent
- Enter Long Positions
- Enter Short Positions
- Require Engulfing Candle Entry
- Use 200 SMA Filter
- Use MACD Filter
- Use "Maximum Bars in Trade"
Pinbar Detector By Shabi v6Description of the Pinbar Detector Script (Pine Script v6)
This Pinbar Detector script is designed for TradingView using Pine Script v6. It identifies and highlights bullish and bearish pinbars on a price chart.
How It Works
The script evaluates each candlestick and checks whether it meets the conditions for a pinbar pattern:
Body Size: The difference between the open and close prices.
Upper Wick: The distance between the high and the larger of open/close.
Lower Wick: The distance between the low and the smaller of open/close.
Pinbar Criteria:
Bullish Pinbar (Green Marker Below the Candle)
Long lower wick (at least twice the body size).
Short upper wick.
Close is higher than open (bullish candle).
Bearish Pinbar (Red Marker Above the Candle)
Long upper wick (at least twice the body size).
Short lower wick.
Close is lower than open (bearish candle).
Visual Features
Bullish Pinbar → Green Upward Arrow Below the Candle
Bearish Pinbar → Red Downward Arrow Above the Candle
Daily COC Strategy with SHERLOCK WAVESThis indicator implements a unique trading strategy known as the "Daily COC (Candle Over Candle) Strategy" enhanced with "SHERLOCK WAVES" for pattern recognition. It's designed for traders looking to capitalize on specific candlestick formations with a negative risk-reward ratio, with the aim of achieving a high win rate (over 70%) through numerous trading opportunities, despite each trade having a higher risk relative to the reward.
Key Features:
Pattern Recognition: Identifies a setup based on three consecutive candles - a red candle followed by a shooting star, then an entry candle that does not break below the shooting star's low.
Negative Risk/Reward Trade Selection: Focuses on entries where the potential stop loss is greater than the take profit, banking on a high win rate to offset the individual trade's negative risk-reward ratio.
Visual Signals:
Green Label: Marks potential entry points at the high of the candle before the entry.
Green Dot: Indicates a winning trade closure.
Red Dot: Signals a losing trade closure.
Blue Circle: Warns when the current candle is within 2% of breaking above the previous candle's high, suggesting a potential setup is developing.
Green Circle: Plots the take profit level.
Red Circle: Plots the stop loss level.
Dynamic Statistics: A live updating label showing the number of trades, wins, losses, open trades, current account balance, and win percentage.
Customizable Parameters:
Risk % per Trade: Adjust the percentage of your account balance you're willing to risk on each trade.
Initial Account Balance: Set your starting balance for tracking performance.
Start Date for Strategy: Define when the strategy should start calculating from, allowing for backtesting.
Alerts:
An alert condition is set for when a potential trade setup is developing, helping traders prepare for entries.
Usage Tips:
This strategy is predicated on the idea that a high win rate can compensate for the negative risk-reward ratio of individual trades. It might not suit all market conditions or traders' risk profiles.
Use this strategy in conjunction with other analysis methods to validate trade setups.
Note: Always backtest thoroughly before applying to live markets. Consider this tool as part of a broader trading strategy, not a standalone solution. Monitor your win rate and adjust your risk management accordingly to ensure the strategy remains profitable over time.
This description now correctly explains the purpose behind the negative risk-reward ratio in the context of your trading strategy.