15-Min Option Trend Strategy with AlertsSimple buy and sell strategy using RSI and SUPERTREND with price action. D'Trader
Indicatori e strategie
Reversal Signal avec TICK + RSIThis indicator is a potential reversal indicator for SCALPING, don't use it for swing. It's base on TICK and on an overbrought/oversold condition of the RSI. You can play with the setting, typicaly I like my TICK to be over reacting an 800/-800 and my rsi over 20 and 80, but it give not enough signal. So I set the TICK signal at 651/-651 and the RSI at 25/75. This indicator is made for SP500 and Nasdaq, so SPY/QQQ/SPX/ES/NQ should work well. It's the first version of it, so maybe I'll add so more data to it to increase signal and lower false one. For now I've test it on live market yet(26/7/25).
The RSI is Fast(5 period), I like to use it on the 1 or 5 min chart.
Please not that it only work during 9h30am to 4pm EST.(Because of the TICK)
Feel free to try and even comment. Don't be harsh on me, it's my first try!
(Sorry for my 'english' it's not my first language)
FAUCON
Supertrend with ADX & MTF MA Filter# **Supertrend with ADX & MTF MA Filter - Comprehensive Explanation**
---
## **1. Purpose of This Indicator**
This indicator combines three powerful technical analysis tools to create a robust trading system:
✅ **Supertrend** (Trend-following)
✅ **ADX Filter** (Trend strength confirmation)
✅ **MTF MA Filter** (Multi-timeframe trend direction confirmation)
**Primary Goals:**
✔ **Identify high-probability trend reversals** with confirmation from multiple indicators
✔ **Filter out weak trends** using ADX (Average Directional Index)
✔ **Add higher timeframe context** with MTF (Multi-TimeFrame) Moving Average
✔ **Reduce false signals** by requiring confluence between all three components
---
## **2. Core Logic & Components**
### **A. Supertrend (Base Indicator)**
- **Calculation:**
```pine
up = hl2 - (Multiplier * ATR(Periods))
dn = hl2 + (Multiplier * ATR(Periods))
```
- **Bullish trend** when price > `up` (green line)
- **Bearish trend** when price < `dn` (red line)
- **Why Supertrend?**
- Simple yet effective trend-following system
- Adapts to volatility via ATR (Average True Range)
---
### **B. ADX Filter (Trend Strength Confirmation)**
- **ADX Calculation:**
```pine
= calcADX(adxLength, adxSmoothing)
strongTrend = adxVal >= adxThreshold
```
- **ADX > Threshold (Default: 20)** = Strong trend
- **DI+ > DI-** = Bullish momentum
- **DI- > DI+** = Bearish momentum
- **Why ADX?**
- Avoids trading in choppy markets (low ADX = weak trend)
- Confirms if Supertrend signals occur in a strong trend
---
### **C. MTF MA Filter (Higher Timeframe Trend Alignment)**
- **Moving Average Calculation:**
```pine
= getMA(maSource, maLength, maType, maTF)
```
- **MA Type:** SMA, EMA, WMA, or DEMA
- **Timeframe:** Any (1m, 5m, 1H, 4H, D, W, M)
- **Trend Direction:**
- **Buy Signal:** MA must be **rising**
- **Sell Signal:** MA must be **falling**
- **Why MTF MA?**
- Aligns trades with the **higher timeframe trend**
- Reduces counter-trend entries
---
## **3. How to Use This Indicator**
### **A. Buy Conditions (All Must Be True)**
1. **Supertrend turns bullish** (price crosses above `up` line)
2. **ADX ≥ Threshold** (trend is strong)
3. **Higher timeframe MA is rising** (confirms bullish bias)
### **B. Sell Conditions (All Must Be True)**
1. **Supertrend turns bearish** (price crosses below `dn` line)
2. **ADX ≥ Threshold** (trend is strong)
3. **Higher timeframe MA is falling** (confirms bearish bias)
### **C. Recommended Settings**
| Parameter | Recommended Value | Description |
|-----------|------------------|-------------|
| **ATR Period** | 14 | Sensitivity of Supertrend |
| **Multiplier** | 1.5-3.0 | Adjust for volatility |
| **ADX Threshold** | 20-25 | Higher = stricter trend filter |
| **MA Length** | 20-50 | Smoothness of trend filter |
| **MA Timeframe** | 1H/D | Align with trading style |
---
## **4. Trading Strategies**
### **A. Trend-Following Strategy**
- **Enter:** When all 3 conditions align (Supertrend + ADX + MA)
- **Exit:** When Supertrend flips or ADX drops below threshold
### **B. Pullback Strategy**
- **Wait for:**
- Supertrend in trend direction
- ADX remains strong
- MA still aligned
- **Enter:** On pullback to Supertrend line
### **C. Multi-Timeframe Confirmation**
- **Intraday traders:** Use 4H/D MA for trend bias
- **Swing traders:** Use D/W MA for trend bias
---
## **5. Advantages Over Standard Supertrend**
✔ **Fewer false signals** (ADX filters weak trends)
✔ **Higher timeframe alignment** (avoids trading against larger trends)
✔ **Customizable MA types** (SMA, EMA, WMA, DEMA)
✔ **Works on all markets** (stocks, forex, crypto)
---
### **Final Thoughts**
This indicator is designed for traders who want **high-confidence trend signals** by combining:
🔹 **Supertrend** (entry trigger)
🔹 **ADX** (trend strength filter)
🔹 **MTF MA** (higher timeframe trend alignment)
By requiring all three components to align, it significantly improves signal quality compared to standalone Supertrend systems.
**→ Best for:** Swing trading, trend-following, and avoiding choppy markets.
Markov Chain Trend ProbabilityA Markov Chain is a mathematical model that predicts future states based on the current state, assuming that the future depends only on the present (not the past). Originally developed by Russian mathematician Andrey Markov, this concept is widely used in:
Finance: Risk modeling, portfolio optimization, credit scoring, algorithmic trading
Weather Forecasting: Predicting sunny/rainy days, temperature patterns, storm tracking
Here's an example of a Markov chain: If the weather is sunny, the probability that will be sunny 30 min later is say 90%. However, if the state changes, i.e. it starts raining, how the probability that will be raining 30 min later is say 70% and only 30% sunny.
Similar concept can be applied to markets price action and trends.
Mathematical Foundation
The core principle follows the Markov Property: P(X_{t+1}|X_t, X_{t-1}, ..., X_0) = P(X_{t+1}|X_t)
Transition Matrix :
-------------Next State
Current----
--------P11 P12
-----P21 P22
Probability Calculations:
P(Up→Up) = Count(Up→Up) / Count(Up states)
P(Down→Down) = Count(Down→Down) / Count(Down states)
Steady-state probability: π = πP (where π is the stationary distribution)
State Definition:
State = UPTREND if (Price_t - Price_{t-n})/ATR > threshold
State = DOWNTREND if (Price_t - Price_{t-n})/ATR < -threshold
How It Works in Trading
This indicator applies Markov Chain theory to market trends by:
Defining States: Classifies market conditions as UPTREND or DOWNTREND based on price movement relative to ATR (Average True Range)
Learning Transitions: Analyzes historical data to calculate probabilities of moving from one state to another
Predicting Probabilities: Estimates the likelihood of future trend continuation or reversal
How to Use
Parameters:
Lookback Period: Number of bars to analyze for trend detection (default: 14)
ATR Threshold: Sensitivity multiplier for state changes (default: 0.5)
Historical Periods: Sample size for probability calculations (default: 33)
Trading Applications:
Trend confirmation for entry/exit decisions
Risk assessment through probability analysis
Market regime identification
Early warning system for potential trend reversals
The indicator works on any timeframe and asset class. Enjoy!
CRT Impulse Detector - Bull & BearHelps Identify Impulse Candles, only triggering those that break recent swings.
Crypto DanR 1.4.2 PC-Roye Edition📜 Crypto DanR 1.4.2 — PC Roye Edition (Open Source)
This indicator combines Smart Money Concepts (SMC), Liquidity Analysis, and Trend Filtering to provide traders with a high-quality tool for intraday and swing trading on assets like XRP/USDT.
✅ What This Script Does
Crypto DanR 1.4.2 integrates the following advanced features:
Break of Structure (BOS) & Change of Character (CHoCH):
Detects key shifts in market structure
Helps confirm trend direction and reversal points
Fair Value Gaps (FVG):
Displays unmitigated liquidity voids using a style inspired by LuxAlgo
Highlights potential retracement zones where smart money may re-enter
Equal Highs / Equal Lows (EQH/EQL):
Marks liquidity zones that institutions often target before reversals
Order Blocks (OB):
Identifies potential institutional demand/supply zones
Option to filter by wick, body, or mitigation logic
Fibonacci Volatility Bands (based on BigBeluga’s logic):
Detects potential price extremes using Fib extensions on volatility
10 Moving Averages in One (inspired by hiimannshu's script):
Supports 10 custom MAs (SMA, EMA, RMA, HMA, VWMA, etc.) with adjustable source and timeframe
Ideal for trend filtering or dynamic support/resistance
Vector Candles (TradersReality / PVSRA):
Color-coded candles showing real-time volume pressure and trend bias
Visual Trade Plan:
Optional overlay for entry, stop-loss, and take-profit planning
Displays risk-to-reward ratio and potential % gain/loss live
🧠 How It Works
The script uses a price-action-first approach, built around concepts from Smart Money Theory. CHoCH and BOS detect structural shifts, while FVGs and OBs help forecast likely reaction zones. The multiple moving averages act as a trend filter to avoid entering against momentum.
This combination allows traders to:
Enter on mitigations or breakouts
Set stops outside liquidity zones
Manage trades visually with dynamic risk/reward levels
📊 Best Use Cases
15m or 1h scalping (ideal)
Swing trading on 4h
Works well on crypto, FX, and indices
🙏 Credits
TradersReality for PVSRA logic via public library
LuxAlgo for FVG inspiration
hiimannshu for 10-in-1 MA logic
BigBeluga for Fibonacci Bands methodology
All reused logic is significantly modified and part of a broader framework.
📌 Notes
Script is open-source to promote transparency and collaboration
Please do not copy-paste and republish without adding meaningful improvements
Feedback and suggestions welcome!
Bias Dashboard + All Open Lines (M/W/D/H4/H1/15min)What does the script do?
This script displays a dashboard that shows the current market bias relative to the open prices of multiple timeframes:
Monthly
Weekly
Daily
4H
1H
15min
Additionally, it plots horizontal lines at each of these open levels on the chart.
How it works
Fetch Open Prices:
The script uses request.security() to get the open prices for each timeframe.
Determine Bias:
Compares the current close price to each open:
If close > open, then "Bullish"
If close < open, then "Bearish"
Display Dashboard:
A visual dashboard shows:
The timeframe label
Whether the current price is above (bullish) or below (bearish) that level
Plot Lines:
Colored horizontal lines are drawn on the chart to indicate each timeframe’s open level.
Williams Percent Range with ThresholdEnhance your trading analysis with the "Williams Percent Range with Threshold" indicator, a powerful modification of the classic Williams %R oscillator. This custom version introduces customizable uptrend and downtrend thresholds, combined with dynamic candlestick coloring to visually highlight market trends. Originally designed to identify overbought and oversold conditions, this script takes it a step further by allowing traders to define specific threshold levels for trend detection, making it a versatile tool for momentum and trend-following strategies.
Key Features:
Customizable Thresholds: Set your own uptrend (default: -16) and downtrend (default: -67) thresholds to adapt the indicator to your trading style.
Dynamic Candlestick Coloring: Candles turn green during uptrends, red during downtrends, and gray in neutral conditions, providing an intuitive visual cue directly on the price chart.
Flexible Length: Adjust the lookback period (default: 50) to fine-tune sensitivity.
Overlay Design: Integrates seamlessly with your price chart, enhancing readability without clutter.
How It Works:
The Williams %R calculates the current closing price's position relative to the highest and lowest prices over a specified period, expressed as a percentage between -100 and 0. This version adds trend detection based on user-defined thresholds, with candlestick colors reflecting the trend state. The indicator plots the %R line with color changes (green for uptrend, red for downtrend) and includes dashed lines for the custom thresholds.
Usage Tips:
Use the uptrend threshold (-16 by default) to identify potential buying opportunities when %R exceeds this level.
Apply the downtrend threshold (-67 by default) to spot selling opportunities when %R falls below.
Combine with other indicators (e.g., moving averages or support/resistance levels) for confirmation signals.
Adjust the length and thresholds based on the asset's volatility and your trading timeframe.
Candlestick Patterns Backtester [Optimized]Candlestick Patterns Backtester
What this is: This indicator is based on a really cool candlestick pattern backtester that I found (I'll update this later when I remember where I got it from or find the actual author). The original had this massive table showing win/loss ratios for a bunch of candlestick patterns, and according to the built-in backtester, it was actually profitable - which was pretty impressive.
The Problem: I played around with the original for a while but honestly wasn't really able to get it to work well at all for actual trading. It was still pretty cool to look at though! The main issues were:
It was just a big static table - hard to do anything useful with it
Couldn't send signals out to other strategies
The code was a monster - like 2,000+ lines of repetitive mess
What I Did: I completely refactored this thing and got it down from 2,000+ lines to just a few hundred lines. Much cleaner now! Here's what it does:
45+ Candlestick Patterns - All the classics are in there
Dynamic Filtering - Set your own requirements (minimum win rate, profit factor, total trades, etc.)
Flexible Logic - Choose AND/OR logic for your filters
Signal Generation - Creates actual buy/sell signals you can use with other strategies
Visual Badges - Shows pattern badges on chart when they meet your criteria
Active Patterns Table - Only shows patterns that are currently profitable based on your settings
Settings You Can Adjust:
Minimum win rate threshold
Minimum profit factor
Minimum number of trades required
Whether to use AND or OR logic for filtering
Colors, badge display, debug options
Reality Check: Trading these patterns really wasn't for me, but it was still a great learning experience. The backtesting results look good on paper, but as always, past performance doesn't guarantee future results. Use this as a research tool and educational resource more than anything else.
Credit: This is based on someone else's original work that I heavily modified and optimized. I'll update this description once I track down the original author to give proper credit where it's due.
This introduction captures your casual, honest tone while explaining the technical improvements you made and setting realistic expectations about the indicator's practical use.
Custom ZigZag IndicatorOverview
The Custom ZigZag Indicator is a technical analysis tool built in Pine Script (version 5) for TradingView. It overlays on price charts to visualize market trends by connecting significant swing highs and lows, filtering out minor price noise. This helps identify the overall market direction (uptrends or downtrends), potential reversal points, and key support/resistance levels. Unlike standard price lines, it "zigzags" only between meaningful pivots, making trends clearer.
Core Logic and How It Works
The script uses a state-machine approach to track market direction and pivots:
Initialization
Starts assuming an upward trend on the first bar.
sets initial high/low prices and bar indices based on the current bar's high/low.
Direction Tracking:
Upward Trend (direction = 1):
Monitors for new highs: If the current high exceeds the tracked high, update the high price and bar.
Checks for reversal: If the low drops below the high by the deviation percentage (e.g., high * (1 - 0.05) for 5%), it signals a downtrend reversal.
Draws a green line from the last pivot (low) to the new high.
If labels are enabled, adds a label: "HH" (Higher High if above previous high), "LH" (Lower High if below), or "H" (for the first one).
Updates the last high and switches to downward direction.
Downward Trend (direction = -1):
Monitors for new lows: If the current low is below the tracked low, update the low price and bar.
Checks for reversal: If the high rises above the low by the deviation percentage (e.g., low * (1 + 0.05)), it signals an uptrend reversal.
Draws a red line from the last pivot (high) to the new low.
If labels are enabled, adds a label: "LL" (Lower Low if below previous low), "HL" (Higher Low if above), or "L" (for the first one).
Updates the last low and switches to upward direction.
ES Gap Trading Levels# ES Gap Trading Levels
## Overview
A professional gap trading indicator designed specifically for ES Futures traders. This indicator automatically captures the closing price at 3:59 PM ET (NYSE close) and immediately displays key gap levels for the evening trading session starting at 6:00 PM ET.
## Key Features
### ✅ **Automatic Gap Level Detection**
- Captures ES Futures closing price at 3:59-4:00 PM ET
- Instantly displays gap levels for immediate session planning
- Resets daily for fresh gap analysis
### ✅ **Six Critical Gap Levels**
- **±10 Points** (White lines) - Short-term gap targets
- **±20 Points** (Light Blue lines) - Medium gap targets
- **±30 Points** (Red lines) - Extended gap targets
### ✅ **Professional Display**
- Clean horizontal lines with customizable colors
- Clear labels showing point values (+30, +20, +10, -10, -20, -30)
- Gap levels table showing exact price targets
- Optional closing price reference line
### ✅ **Customizable Settings**
- Adjustable line colors, width, and extension
- Toggle labels and reference table on/off
- Manual closing price override for testing
- Debug mode for troubleshooting
### ✅ **Smart Management**
- Automatic cleanup of previous day's levels
- Lines appear immediately after market close
- Optimized for ES1!, MES1!, and other ES futures contracts
## How It Works
1. **Market Close Capture**: At 3:59 PM ET, the indicator captures the ES closing price
2. **Instant Display**: Gap levels immediately appear on your chart
3. **Evening Session Ready**: Lines are positioned for 6:00 PM ET session start
4. **Daily Reset**: Old levels are automatically cleared each new trading day
## Perfect For:
- Gap trading strategies
- Overnight futures trading
- ES futures scalping
- Session transition analysis
- Risk management levels
## Usage Tips:
- Best used on 1-15 minute ES futures charts
- Ensure chart timezone shows ET times
- Use manual mode for backtesting specific dates
- Combine with volume and momentum indicators
## Settings Guide:
- **Display Settings**: Control lines, labels, and table visibility
- **Colors**: Customize each gap level color scheme
- **Manual Settings**: Override closing price for testing
- **Debug**: View time detection and diagnostic information
*Designed by traders, for traders. Clean, professional, and reliable gap level detection for serious ES futures trading.*
Buy/Sell Indicator with Candles + RSI + MACD + S/RHere's a full Pine Script strategy for TradingView that combines:
Morning Star & Evening Star Doji patterns
RSI
MACD
Support & Resistance (basic logic)
Buy/Sell arrows with entry points
This script is for educational use and can be optimized further depending on your asset/timeframe.
Clarix Smart FlipPurpose
This tool identifies high-probability intraday reversals by detecting when price flips through the daily open after strong early-session commitment.
How It Works
A valid flip occurs when:
The previous daily candle is bullish or bearish
The first hour today continues in the same direction
Then, the price flips back through the daily open with a minimum break threshold (user-defined)
This setup is designed to catch liquidity grabs or fakeouts near the daily open, where early buyers or sellers get trapped after showing commitment
Signal Logic
Buy Flip
Previous day bearish → first hour bearish → price flips above open
Sell Flip
Previous day bullish → first hour bullish → price flips below open
Features
Configurable flip threshold in percentage
Signals only activate after the first hour ends
Daily open line displayed on chart
Simple triangle markers with no visual clutter
Alerts ready to use for automation or notifications
Usage Tips
Use "Once Per Bar" alert mode to get notified immediately when the flip happens
Works best in active markets like FX, indices, or crypto
Adjust threshold based on asset volatility
Suggested stop loss: use the previous daily high for sell flips or the previous daily low for buy flips
Suggested take profit: secure at least 30 pips to aim for a 1:3 risk-to-reward ratio on average
Clarix Ichimoku DashboardPurpose
The Mariam Ichimoku Dashboard is designed to simplify the Ichimoku trading system for both beginners and experienced traders. It provides a complete view of trend direction, strength, momentum, and key signals all in one compact dashboard on your chart. This tool helps traders make faster and more confident decisions without having to interpret every Ichimoku element manually.
How It Works
1. Trend Strength Score
Calculates a score from -5 to +5 based on Ichimoku components.
A high positive score means strong bullish momentum.
A low negative score shows strong bearish conditions.
A near-zero score indicates a sideways or unclear market.
2. Future Cloud Bias
Looks 26 candles ahead to determine if the future cloud is bullish or bearish.
This helps identify the longer-term directional bias of the market.
3. Flat Kijun / Flat Senkou B
Detects flat zones in the Kijun or Senkou B lines.
These flat areas act as strong support or resistance and can attract price.
4. TK Cross
Identifies Tenkan-Kijun crosses:
Bullish Cross means Tenkan crosses above Kijun
Bearish Cross means Tenkan crosses below Kijun
5. Last TK Cross Info
Shows whether the last TK cross was bullish or bearish and how many candles ago it happened.
Helps track trend development and timing.
6. Chikou Span Position
Checks if the Chikou Span is above, below, or inside past price.
Above means bullish momentum
Below means bearish momentum
Inside means mixed or indecisive
7. Near-Term Forecast (Breakout)
Warns when price is near the edge of the cloud, preparing for a potential breakout.
Useful for anticipating price moves.
8. Price Breakout
Shows if price has recently broken above or below the cloud.
This can confirm the start of a new trend.
9. Future Kumo Twist
Detects upcoming twists in the cloud, which often signal potential trend reversals.
10. Ichimoku Confluence
Measures how many key Ichimoku signals are in agreement.
The more signals align, the stronger the trend confirmation.
11. Price in or Near the Cloud
Displays if the price is inside the cloud, which often indicates low clarity or a choppy market.
12. Cloud Thickness
Shows whether the cloud is thin or thick.
Thick clouds provide stronger support or resistance.
Thin clouds may allow easier breakouts.
13. Recommendation
Gives a simple trading suggestion based on all major signals.
Strong Buy, Strong Sell, or Hold.
Helps simplify decision-making at a glance.
Features
All major Ichimoku signals summarized in one panel
Real-time trend strength scoring
Detects flat zones, crosses, cloud twists, and breakouts
Visual alerts for trend alignment and signal confluence
Compact, clean design
Built with simplicity in mind for beginner traders
Tips
Best used on 15-minute to 1-hour charts for short-term trading
Avoid entering trades when price is inside the cloud because the market is often indecisive
Wait for alignment between trend score, TK cross, cloud bias, and confluence
Use the dashboard to support your trading strategy, not replace it
Enable alerts for major confluence or upcoming Kumo twists
Triple Momentum Core v1🧠 Technical Structure:
Triple Momentum Core analyzes the underlying wave of price movement through a three-stage system:
1. 🔵 Follow Line – The First Spark of Momentum:
Constructed using Bollinger Bands and ATR, this line detects the very first signs of directional price expansion. It gently whispers when the market begins stretching with force in one direction.
2. 🟢 SuperTrend – Confirmation and Directional Validation:
After the initial move, SuperTrend acts as the second checkpoint — validating whether the price action is evolving into a genuine trend or fading out. It confirms whether the impulse has the strength to sustain.
3. 🔴 PMax – Core Trend & Structural Anchor:
Based on Moving Average and ATR logic, PMax tracks the heartbeat of the trend. It serves as a dynamic structural boundary — critical for identifying trend continuation and managing risk.
4. 🟡 PMax MA Line – Smooth Trend Pulse & Adaptive Guide:
This yellow moving average line within the PMax system softly follows the overall trend flow, without reacting to sharp price noise. It acts as a balanced, stable guide to gauge the solidity of the trend’s body structure.
(If you prefer a cleaner view without any moving average lines, you can disable it from the settings.)
🧠 Technical Structure:
Triple Momentum Core analyzes the underlying wave of price movement through a three-stage system:
1. 🔵 Follow Line – The First Spark of Momentum:
Constructed using Bollinger Bands and ATR, this line detects the very first signs of directional price expansion. It gently whispers when the market begins stretching with force in one direction.
2. 🟢 SuperTrend – Confirmation and Directional Validation:
After the initial move, SuperTrend acts as the second checkpoint — validating whether the price action is evolving into a genuine trend or fading out. It confirms whether the impulse has the strength to sustain.
3. 🔴 PMax – Core Trend & Structural Anchor:
Based on Moving Average and ATR logic, PMax tracks the heartbeat of the trend. It serves as a dynamic structural boundary — critical for identifying trend continuation and managing risk.
4. 🟡 PMax MA Line – Smooth Trend Pulse & Adaptive Guide:
This yellow moving average line within the PMax system softly follows the overall trend flow, without reacting to sharp price noise. It acts as a balanced, stable guide to gauge the solidity of the trend’s body structure.
(If you prefer a cleaner view without any moving average lines, you can disable it from the settings.)
💡 Why “Triple Momentum Core”?
Because this indicator doesn’t just detect movement — it breaks it down into its essential phases:
Ignition, validation, and confirmation.
Each layer captures a unique and essential part of price behavior:
The first reaction (Follow Line) ignites the initial spark.
The second reaction (SuperTrend) confirms whether that spark will become a real trend.
The third and final layer (PMax) structurally anchors and follows that trend.
That’s why we call it Triple Momentum Core:
A synchronized 3-engine momentum system working in harmony to capture the lifecycle of a trend — from spark to structure.
🔥 EMA Ribbon with Dynamic Colors🔥 EMA Ribbon with Dynamic Colors — Indicator Description
📌 Overview
This EMA Ribbon with Dynamic Colors indicator is designed to provide clear visual cues about market trend strength and direction using Exponential Moving Averages (EMAs). It combines a main EMA line with a colorful ribbon of multiple EMAs to help traders quickly identify bullish or bearish momentum zones on the chart.
🔍 How It Works
Main EMA Line (Default 50):
The thick main EMA line changes color dynamically based on its slope:
🟢 Green when the slope is positive (bullish momentum)
🔴 Red when the slope is negative (bearish momentum)
EMA Ribbon:
A series of 5 EMAs with customizable lengths (default 10, 15, 20, 25, 30) are plotted as thinner lines. These create a "ribbon" effect with semi-transparent fills between them, providing a smooth gradient visualization of the trend.
Each ribbon EMA line also changes color based on its slope to reflect momentum strength and direction.
Background Color:
The chart background subtly highlights the overall trend zone by shading green in bullish phases and red in bearish phases, helping you quickly identify market regimes.
Trend Label:
A clear "BULLISH" or "BEARISH" label is displayed above the latest bar to summarize the current trend state based on the main EMA slope.
🎯 Benefits & Use Cases
Trend Identification:
The color-coded ribbon visually confirms if the market is trending strongly or weakening, making it easy to decide when to enter or exit trades.
Momentum Strength:
Slope-based coloring on multiple EMAs helps spot shifts in momentum early.
Visual Appeal:
The smooth ribbon and background highlight improve readability and reduce chart clutter compared to multiple separate EMAs.
Customization:
You can adjust each EMA length individually to tailor the ribbon to different timeframes or instruments.
⚙️ How to Use
Add the indicator to your TradingView chart.
Customize the EMA lengths via inputs to match your trading style.
Use the green/red EMA lines and ribbon to confirm trend direction and strength.
Use the background shading and trend label as additional visual confirmation.
Combine with other indicators or price action for entry and exit decisions.
ORB Range Indicator with Fibonacci Targets
This script plots the Opening Range (ORB) high and low based on a configurable time window (5–45 minutes from the U.S. session open at 9:30 AM EST).
Once the ORB window closes, the indicator draws horizontal lines marking:
ORB High and Low
The size of the range in price and %
Fibonacci-based price targets above and below the range (0.382, 0.618, 1.000, 1.618, 2.000)
You can control:
Which Fibonacci levels to display
Whether to show long targets, short targets, or both
All drawings are automatically cleared at the start of each trading day.
Ideal for breakout traders using ORB and Fibonacci extensions for target planning.
RV Indicator This Pine Script defines a custom Relative Volatility (RV) Indicator, which measures the ratio of directional price movement to volatility over a specified number of bars. Below is a full explanation of what this script does.
Title:
RV Indicator — Relative Volatility Oscillator
Purpose:
This indicator measures how aggressively price is moving compared to recent volatility, and smooths the result with a signal line. It can be used to gauge momentum shifts and trend strength.
How It Works – Step by Step
1. Measuring Price Momentum (v1)
It calculates the difference between the close and open prices of the last 4 candles.
A weighted average is applied:
The current candle and the one 3 bars ago get weight 1.
The two middle candles (1 and 2 bars ago) get weight 2.
This creates a smoothed momentum measure:
If close > open (bullish), v1 is positive.
If close < open (bearish), v1 is negative.
2. Measuring Volatility (v2)
Similarly, it calculates the high-low range for the last 4 candles.
The same weighting (1, 2, 2, 1) is applied.
This gives a smoothed volatility measure.
3. Combining Momentum and Volatility (RV Ratio)
For the past ti bars (default: 10), it sums up:
All v1 values (momentum sum)
All v2 values (volatility sum)
Then it divides them:
𝑅𝑉= sum of price momentum % sum of volatility
This produces the RV value:
RV > 0: Momentum is bullish (price is generally moving up relative to its volatility).
RV < 0: Momentum is bearish (price is moving down relative to its volatility).
4. Smoothed Signal Line (rvsig)
A smoothed version of the RV is created using a weighted average of the latest 4 RV values.
This acts like a signal line, similar to how MACD uses a signal line.
Crossovers between RV and this signal line can be used to detect shifts in momentum.
5. Visual Output
Orange Line (RV): Shows the raw momentum/volatility ratio.
Blue Line (Signal): A smoother line that follows RV more slowly.
Zero Line: Divides bullish vs. bearish momentum.
How to Use It in Trading
1. Look for Crossovers:
If RV crosses above its signal line → Possible buy signal (momentum turning bullish).
If RV crosses below its signal line → Possible sell signal (momentum turning bearish).
2. Check the Zero Line:
If both RV and Signal are above zero, momentum is bullish.
If both are below zero, momentum is bearish.
3. Filter False Signals:
Combine RV with a trend filter (like a 50 or 200 EMA) to avoid trading against the main trend.
Disclaimer: This script is for informational and educational purposes only. It does not constitute financial advice or a recommendation to buy or sell any asset. All trading decisions are solely your responsibility. Use at your own risk.
30s OR ProjectionsThis script gets the opening range for NQ,ES, and YM. It then created deviations based on this range as targets to take profit from. You may also use the deviations to enter into trades looking for the other side of the range. You have the ability to shade areas of the range.
NY Close High/Low - UAE Time📌 Indicator Name:
New York Session Close High/Low – UAE Time
📄 Description:
This indicator automatically marks the high and low of the New York trading session closing candle, based on UAE local time (Asia/Dubai).
🕒 Time Logic:
The New York session closes at 5:00 PM EST, which corresponds to 1:00 AM UAE time (next day).
The indicator captures the 12:00 AM to 1:00 AM UAE time candle, which represents the final hour of the New York session.
✅ Features:
Marks the high and low of the NY close candle.
Updates dynamically each day.
Lines are plotted using UAE local time (Asia/Dubai).
Works on most timeframes (recommended: 1H or higher).
📈 Use Cases:
Identify key liquidity zones at the NY session close.
Use as support/resistance or breakout reference.
Combine with your existing trading strategy for precision entries.
Asian & London Ranges 09-23 │ Sweep-colour & Dynamic EndGood indicator for trading forex easy to trade helpfiull for begginers, auto liquidity helpfull easy good modern
DR V966 - Smart Money Concepts// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © DR.BASL
//
//@version=5
indicator("DR V966 - Smart Money Concepts", "DR V966 - Smart Money Concepts ",
overlay = true,
max_bars_back = 5000,
max_boxes_count = 500,
max_labels_count = 500,
max_lines_count = 500,
max_polylines_count = 100)
plot(na)
//
MSG = "MARKET STRUCTURE"
VBG = "VOLUMETRIC ORDER BLOCKS"
MST = "Limit market structure calculation to improve memory speed time"
SLT = " Limit swing structure to tot bars back"
IDT = " Start date of the internal structure"
CST = "Color candle based on trend detection system"
OBT = "Display internal buy and sell activity"
OBD = "Show Last number of orderblock"
OBMT = " Use Length to adjust cordinate of the orderblocks Use whole candle body"
_ ='
------------
–––––––––––––––––––––––––– INPUTS –––––––––––––––––––––––––––
------------ '//{
bool windowsis = input.bool(true, "Window", inline="kla", group=MSG)
int mswindow = input.int(5000, "", tooltip=MST,group=MSG, inline="kla", minval=1000)
bool showSwing = input.bool(true, "Swing", inline="scss", group=MSG)
int swingLimit = input.int(100, "", tooltip=SLT, inline="scss", group=MSG, minval=10, maxval=200)
color swingcssup = input.color(#089981, "", inline="scss", group=MSG)
color swingcssdn = input.color(#f23645, "", inline="scss", group=MSG)
bool showMapping = input.bool(false, "Mapping Structure", inline="mapping", group=MSG)
string mappingStyle = input.string("----", "", options= , inline="mapping", group=MSG)
color mappingcss = input.color(color.silver, "", tooltip="Display Mapping Structure", inline="mapping", group=MSG)
bool candlecss = input.bool(false, "Color Candles", tooltip=CST, group=MSG, inline="txt")
string mstext = input.string("Tiny", "", options= ,
inline="txt", group=MSG)
string msmode = input.string("Adjusted Points", "Algorithmic Logic", options=
, inline="node", group=MSG)
int mslen = input.int(5, "", inline="node", group=MSG, minval=2)
bool buildsweep = input.bool(true, "Build Sweep (x)", "Build sweep on market structure", "znc", MSG)
bool msbubble = input.bool(true, "Bubbles", tooltip="Display Circle Bubbles", inline="bubbles", group=MSG)
bool obshow = input.bool(true, "Show Last", tooltip=OBD, group=VBG, inline="obshow")
int oblast = input.int(5, "", group=VBG, inline="obshow", minval=0)
color obupcs = input.color(color.new(#089981, 90), "", inline="obshow", group=VBG)
color obdncs = input.color(color.new(#f23645, 90), "", inline="obshow", group=VBG)
bool obshowactivity = input.bool(true, "Show Buy/Sell Activity", inline="act", group=VBG, tooltip=OBT)
color obactup = input.color(color.new(#089981, 50), "", inline="act", group=VBG)
color obactdn = input.color(color.new(#f23645, 50), "", inline="act", group=VBG)
obshowbb = input.bool(false, "Show Breakers", inline="bb", group=VBG, tooltip="Display Breakers")
color bbup = input.color(color.new(#089981, 100), "", inline="bb", group=VBG)
color bbdn = input.color(color.new(#f23645, 100), "", inline="bb", group=VBG)
obmode = input.string("Length", "Construction", options= , tooltip=OBMT, inline="atr", group=VBG)
len = input.int(5, "", inline="atr", group=VBG, minval=1)
obmiti = input.string("Close", "Mitigation Method", options= ,
tooltip="Mitigation method for when to trigger order blocks", group=VBG)
obtxt = input.string("Normal", "Metric Size", options= ,
tooltip="Order block Metrics text size", inline="txt", group=VBG)
showmetric = input.bool(true, "Show Metrics", group=VBG)
showline = input.bool(true, "Show Mid-Line", group=VBG)
overlap = input.bool(true, "Hide Overlap", group=VBG, inline="ov")
wichlap = input.string("Recent", "", options= , inline="ov", group=VBG)
fvg_enable = input.bool(false, "", inline="1", group="FAIR VALUE GAP", tooltip="Display fair value gap")
what_fvg = input.string("FVG", "", inline="1", group="FAIR VALUE GAP", tooltip="Display fair value gap",
options= )
fvg_num = input.int(5, "Show Last", inline="1a", group="FAIR VALUE GAP", tooltip="Number of fvg to show", minval=0)
fvg_upcss = input.color(color.new(#089981, 80), "", inline="1", group="FAIR VALUE GAP")
fvg_dncss = input.color(color.new(#f23645, 80), "", inline="1", group="FAIR VALUE GAP")
fvgbbup = input.color(color.new(#089981, 100), "", inline="1", group="FAIR VALUE GAP")
fvgbbdn = input.color(color.new(#f23645, 100), "", inline="1", group="FAIR VALUE GAP")
fvg_src = input.string("Close", "Mitigation",
inline="3",
group="FAIR VALUE GAP",
tooltip=" Use the close of the body as trigger Use the extreme point of the body as trigger",
options= )
fvgthresh = input.float(0, "Threshold", tooltip="Filter out non significative FVG", group="FAIR VALUE GAP",
inline="asd", minval=0, maxval=2, step=0.1)
fvgoverlap = input.bool(true, "Hide Overlap", "Hide overlapping FVG", group="FAIR VALUE GAP")
fvgline = input.bool(true, "Show Mid-Line", group="FAIR VALUE GAP")
fvgextend = input.bool(false, "Extend FVG", group="FAIR VALUE GAP")
dispraid = input.bool(false, "Display Raids", inline="raid", group="FAIR VALUE GAP")
// إعدادات تفعيل/تعطيل وتخصيص لكل مستوى فيبوناتشي
show_fib_0 = input.bool(true, "إظهار 0.0" , group="Fibonacci")
show_fib_236 = input.bool(true, "إظهار 0.236" , group="Fibonacci")
show_fib_382 = input.bool(true, "إظهار 0.382" , group="Fibonacci")
show_fib_5 = input.bool(true, "إظهار 0.5" , group="Fibonacci")
show_fib_618 = input.bool(true, "إظهار 0.618" , group="Fibonacci")
show_fib_786 = input.bool(true, "إظهار 0.786" , group="Fibonacci")
show_fib_1 = input.bool(true, "إظهار 1.0" , group="Fibonacci")
show_fib_1272 = input.bool(true, "إظهار 1.272" , group="Fibonacci")
show_fib_1618 = input.bool(true, "إظهار 1.618" , group="Fibonacci")
show_fib_180 = input.bool(true, "إظهار 1.80" , group="Fibonacci")
show_fib_2 = input.bool(true, "إظهار 2.0" , group="Fibonacci")
show_fib_2272 = input.bool(true, "إظهار 2.272" , group="Fibonacci")
show_fib_2618 = input.bool(true, "إظهار 2.618" , group="Fibonacci")
fib_color_0 = input.color(color.white, "لون 0.0" , group="Fibonacci")
fib_color_236 = input.color(color.white, "لون 0.236" , group="Fibonacci")
fib_color_382 = input.color(color.white, "لون 0.382" , group="Fibonacci")
fib_color_5 = input.color(color.white, "لون 0.5" , group="Fibonacci")
fib_color_618 = input.color(color.white, "لون 0.618" , group="Fibonacci")
fib_color_786 = input.color(color.white, "لون 0.786" , group="Fibonacci")
fib_color_1 = input.color(color.white, "لون 1.0" , group="Fibonacci")
fib_color_1272 = input.color(color.white, "لون 1.272" , group="Fibonacci")
fib_color_1618 = input.color(color.white, "لون 1.618" , group="Fibonacci")
fib_color_180 = input.color(color.white, "لون 1.80" , group="Fibonacci")
fib_color_2 = input.color(color.white, "لون 2.0" , group="Fibonacci")
fib_color_2272 = input.color(color.white, "لون 2.272" , group="Fibonacci")
fib_color_2618 = input.color(color.white, "لون 2.618" , group="Fibonacci")
fib_size = input.string("normal", "حجم الخط", options= , group="Fibonacci")
fib_shift = input.int(0, "تحريك خطوط الفيبوناتشي إلى اليمين", minval=0, maxval=100, group="Fibonacci")
//}
_ ='
------------
–––––––––––––––––––––––––– UDT –––––––––––––––––––––––––––
------------ '//{
type hqlzone
box pbx
box ebx
box lbx
label plb
label elb
label lbl
type Zphl
line top
line bottom
label top_label
label bottom_label
bool stopcross
bool sbottomcross
bool itopcross
bool ibottomcross
string txtup
string txtdn
float topy
float bottomy
float topx
float bottomx
float tup
float tdn
int tupx
int tdnx
float itopy
float itopx
float ibottomy
float ibottomx
float uV
float dV
type entered
bool normal = false
bool breaker = false
type store
line ln
label lb
box bx
linefill lf
type structure
int zn
float zz
float bos
float choch
int loc
int temp
int trend
int start
float main
int xloc
bool upsweep
bool dnsweep
string txt = na
type drawms
int x1
int x2
float y
string txt
color css
string style
type ob
bool bull
float top
float btm
float avg
int loc
color css
float vol
int dir
int move
int blPOS
int brPOS
int xlocbl
int xlocbr
bool isbb = false
int bbloc
type FVG
float top = na
float btm = na
int loc = bar_index
bool isbb = false
int bbloc = na
bool israid = false
float raidy = na
int raidloc = na
int raidx2 = na
bool active = false
color raidcs = na
type SFP
float y
int loc
float ancor
type sfpbuildlbl
int x
float y
string style
color css
string txt
type sfpbuildline
int x1
int x2
float y
color css
float ancor
int loc
type equalbuild
int x1
float y1
int x2
float y2
color css
string style
type equalname
int x
float y
string txt
color css
string style
type ehl
float pt
int t
float pb
int b
type sellbuyside
float top
float btm
int loc
color css
string txt
float vol
type timer
bool start = false
int count = 0
//}
_ ='
------------
–––––––––––––––––––––––––– SETUP –––––––––––––––––––––––––––
------------ '//{
var store bin = store.new(
array.new< line >()
, array.new< label >()
, array.new< box >()
, array.new()
)
var entered blobenter = entered.new()
var entered brobenter = entered.new()
var entered blfvgenter = entered.new()
var entered brfvgenter = entered.new()
var entered blarea = entered.new()
var entered brarea = entered.new()
var timer lc = timer.new ()
if barstate.islast
for obj in bin.ln
obj.delete()
for obj in bin.lb
obj.delete()
for obj in bin.bx
obj.delete()
for obj in bin.lf
obj.delete()
bin.ln.clear()
bin.lb.clear()
bin.bx.clear()
bin.lf.clear()
invcol = #ffffff00
float atr = (ta.atr(200) / (5/len))
//}
_ ='
------------
–––––––––––––––––––––––––– UTILITY –––––––––––––––––––––––––––
------------ '//{
method txSz(string s) =>
out = switch s
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
"Auto" => size.auto
out
method lstyle(string style) =>
out = switch style
'⎯⎯⎯⎯' => line.style_solid
'----' => line.style_dashed
'····' => line.style_dotted
ghl() => [high , low , close , open , close, open, high, low, high , low , ta.atr(200)]
method IDMIDX(bool use_max, int loc) =>
min = 99999999.
max = 0.
idx = 0
if use_max
for i = 0 to (bar_index - loc)
max := math.max(high , max)
min := max == high ? low : min
idx := max == high ? i : idx
else
for i = 0 to (bar_index - loc)
min := math.min(low , min)
max := min == low ? high : max
idx := min == low ? i : idx
idx
SFPData() => [high, high , high , low, low , low , close, volume, time, bar_index , time ]
SFPcords() =>
RealTF = barstate.isrealtime ? 0 : 1
= SFPData()
[h , h1 , h2 , l , l1 , l2 , c , v , t , n , t1 ]
method find(structure ms, bool use_max, bool sweep, bool useob) =>
min = 99999999.
max = 0.
idx = 0
if not sweep
if ((bar_index - ms.loc) - 1) > 0
if use_max
for i = 0 to (bar_index - ms.loc) - 1
max := math.max(high , max)
min := max == high ? low : min
idx := max == high ? i : idx
if useob
if high > high
max := high
min := low
idx := idx + 1
else
for i = 0 to (bar_index - ms.loc) - 1
min := math.min(low , min)
max := min == low ? high : max
idx := min == low ? i : idx
if useob
if low < low
max := high
min := low
idx := idx + 1
else
if use_max
for i = 0 to (bar_index - ms.loc)
max := math.max(high , max)
min := max == high ? low : min
idx := max == high ? i : idx
if useob
if high > high
max := high
min := low
idx := idx + 1
else
for i = 0 to (bar_index - ms.loc)
min := math.min(low , min)
max := min == low ? high : max
idx := min == low ? i : idx
if useob
if low < low
max := high
min := low
idx := idx + 1
else
if ((bar_index - ms.xloc) - 1) > 0
if use_max
for i = 0 to (bar_index - ms.xloc) - 1
max := math.max(high , max)
min := max == high ? low : min
idx := max == high ? i : idx
if useob
if high > high
max := high
min := low
idx := idx + 1
else
for i = 0 to (bar_index - ms.xloc) - 1
min := math.min(low , min)
max := min == low ? high : max
idx := min == low ? i : idx
if useob
if low < low
max := high
min := low
idx := idx + 1
else
if use_max
for i = 0 to (bar_index - ms.xloc)
max := math.max(high , max)
min := max == high ? low : min
idx := max == high ? i : idx
if useob
if high > high
max := high
min := low
idx := idx + 1
else
for i = 0 to (bar_index - ms.xloc)
min := math.min(low , min)
max := min == low ? high : max
idx := min == low ? i : idx
if useob
if low < low
max := high
min := low
idx := idx + 1
idx
method fnOB(ob block, bool bull, float cords, int idx) =>
switch bull
true =>
blobenter.normal := false
blobenter.breaker := false
block.unshift(
ob.new(
true
, cords
, low
, math.avg(cords, low )
, time
, obupcs
, volume
, close > open ? 1 : -1
, 1
, 1
, 1
, time
)
)
false =>
brobenter.normal := false
brobenter.breaker := false
block.unshift(
ob.new(
false
, high
, cords
, math.avg(cords, high )
, time
, obdncs
, volume
, close > open ? 1 : -1
, 1
, 1
, 1
, time
)
)
method mitigated(ob block) =>
if barstate.isconfirmed
for in block
if not stuff.isbb
switch stuff.bull
true =>
if obmiti == "Close" ? math.min(close, open) < stuff.btm : obmiti == "Wick" ? low < stuff.btm : obmiti == "Avg" ? low < stuff.avg : na
stuff.isbb := true
stuff.bbloc := time
if not obshowbb
block.remove(i)
false =>
if obmiti == "Close" ? math.max(close, open) > stuff.top : obmiti == "Wick" ? high > stuff.top : obmiti == "Avg" ? high > stuff.avg : na
stuff.isbb := true
stuff.bbloc := time
if not obshowbb
block.remove(i)
else
switch stuff.bull
true =>
if obmiti == "Close" ? math.max(close, open) > stuff.top : obmiti == "Wick" ? high > stuff.top : obmiti == "Avg" ? high > stuff.avg : na
block.remove(i)
false =>
if obmiti == "Close" ? math.min(close, open) < stuff.btm : obmiti == "Wick" ? low < stuff.btm : obmiti == "Avg" ? low < stuff.avg : na
block.remove(i)
overlap(ob bull, ob bear) =>
if bull.size() > 1
for i = bull.size() - 1 to 1
stuff = bull.get(i)
current = bull.get(0)
v = wichlap == "Recent" ? i : 0
switch
stuff.btm > current.btm and stuff.btm < current.top => bull.remove(v)
stuff.top < current.top and stuff.btm > current.btm => bull.remove(v)
stuff.top > current.top and stuff.btm < current.btm => bull.remove(v)
stuff.top < current.top and stuff.top > current.btm => bull.remove(v)
if bear.size() > 1
for i = bear.size() - 1 to 1
stuff = bear.get(i)
current = bear.get(0)
v = wichlap == "Recent" ? i : 0
switch
stuff.btm > current.btm and stuff.btm < current.top => bear.remove(v)
stuff.top < current.top and stuff.btm > current.btm => bear.remove(v)
stuff.top > current.top and stuff.btm < current.btm => bear.remove(v)
stuff.top < current.top and stuff.top > current.btm => bear.remove(v)
if bull.size() > 0 and bear.size() > 0
for i = bull.size() - 1 to 0
stuff = bull.get(i)
current = bear.get(0)
v = wichlap == "Recent" ? 0 : i
switch
stuff.btm > current.btm and stuff.btm < current.top => bull.remove(v)
stuff.top < current.top and stuff.btm > current.btm => bull.remove(v)
stuff.top > current.top and stuff.btm < current.btm => bull.remove(v)
stuff.top < current.top and stuff.top > current.btm => bull.remove(v)
if bull.size() > 0 and bear.size() > 0
for i = bear.size() - 1 to 0
stuff = bear.get(i)
current = bull.get(0)
v = wichlap == "Recent" ? 0 : i
switch
stuff.btm > current.btm and stuff.btm < current.top => bear.remove(v)
stuff.top < current.top and stuff.btm > current.btm => bear.remove(v)
stuff.top > current.top and stuff.btm < current.btm => bear.remove(v)
stuff.top < current.top and stuff.top > current.btm => bear.remove(v)
overlapFVG(FVG blFVG, FVG brFVG) =>
if blFVG.size() > 1
for i = blFVG.size() - 1 to 1
stuff = blFVG.get(i)
current = blFVG.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top => blFVG.remove(i)
stuff.top < current.top and stuff.btm > current.btm => blFVG.remove(i)
stuff.top > current.top and stuff.btm < current.btm => blFVG.remove(i)
stuff.top < current.top and stuff.top > current.btm => blFVG.remove(i)
if brFVG.size() > 1
for i = brFVG.size() - 1 to 1
stuff = brFVG.get(i)
current = brFVG.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top => brFVG.remove(i)
stuff.top < current.top and stuff.btm > current.btm => brFVG.remove(i)
stuff.top > current.top and stuff.btm < current.btm => brFVG.remove(i)
stuff.top < current.top and stuff.top > current.btm => brFVG.remove(i)
if blFVG.size() > 0 and brFVG.size() > 0
for i = blFVG.size() - 1 to 0
stuff = blFVG.get(i)
current = brFVG.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top => blFVG.remove(i)
stuff.top < current.top and stuff.btm > current.btm => blFVG.remove(i)
stuff.top > current.top and stuff.btm < current.btm => blFVG.remove(i)
stuff.top < current.top and stuff.top > current.btm => blFVG.remove(i)
if blFVG.size() > 0 and brFVG.size() > 0
for i = brFVG.size() - 1 to 0
stuff = brFVG.get(i)
current = blFVG.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top => brFVG.remove(i)
stuff.top < current.top and stuff.btm > current.btm => brFVG.remove(i)
stuff.top > current.top and stuff.btm < current.btm => brFVG.remove(i)
stuff.top < current.top and stuff.top > current.btm => brFVG.remove(i)
method umt(ob metric) =>
switch metric.dir
1 =>
switch metric.move
1 => metric.blPOS := metric.blPOS + 1, metric.move := 2
2 => metric.blPOS := metric.blPOS + 1, metric.move := 3
3 => metric.brPOS := metric.brPOS + 1, metric.move := 1
-1 =>
switch metric.move
1 => metric.brPOS := metric.brPOS + 1, metric.move := 2
2 => metric.brPOS := metric.brPOS + 1, metric.move := 3
3 => metric.blPOS := metric.blPOS + 1, metric.move := 1
if (time - time ) == (time - time )
metric.xlocbl := metric.loc + (time - time ) * metric.blPOS
metric.xlocbr := metric.loc + (time - time ) * metric.brPOS
method display(ob id, ob full, int i) =>
if not id.isbb
bin.bx.unshift(box.new (top = id.top, bottom = id.btm, left = id.loc, right = time , border_color = na , bgcolor = id.css, xloc = xloc.bar_time))
bin.bx.unshift(box.new (top = id.top, bottom = id.btm, left = time , right = time + 1 , border_color = na , bgcolor = id.css, xloc = xloc.bar_time, extend = extend.right))
else
bin.bx.unshift(box.new (top = id.top, bottom = id.btm, left = id.loc , right = id.bbloc , border_color = na , bgcolor = id.css , xloc = xloc.bar_time))
bin.bx.unshift(box.new (top = id.top, bottom = id.btm, left = id.bbloc , right = time , border_color = id.css , bgcolor = id.bull ? bbup : bbdn , xloc = xloc.bar_time, border_width = 2))
bin.bx.unshift(box.new (top = id.top, bottom = id.btm, left = time , right = time + 1 , border_color = id.css , bgcolor = id.bull ? bbup : bbdn , xloc = xloc.bar_time, extend = extend.right))
if obshowactivity
bin.bx.unshift(box.new (top = id.top, bottom = id.avg, left = id.loc , right = id.xlocbl, border_color = na , bgcolor = obactup, xloc = xloc.bar_time))
bin.bx.unshift(box.new (top = id.avg, bottom = id.btm, left = id.loc , right = id.xlocbr, border_color = na , bgcolor = obactdn, xloc = xloc.bar_time))
if showline
bin.ln.unshift(line.new(
x1 = id.loc
, x2 = time
, y1 = id.avg
, y2 = id.avg
, color = color.new(id.css, 0)
, xloc = xloc.bar_time
, style = line.style_dashed
)
)
if showmetric
if i == math.min(oblast - 1, full.size() - 1)
float tV = 0
float dV = array.new()
seq = math.min(oblast - 1, full.size() - 1)
for j = 0 to seq
cV = full.get(j)
tV += cV.vol
if j == seq
for y = 0 to seq
dV.push(
math.floor(
(full.get(y).vol / tV) * 100)
)
ids = full.get(y)
bin.lb.unshift(label.new(
bar_index - 1
, ids.avg
, textcolor = color.new(ids.css, 0)
, style = label.style_label_left
, size = obtxt.txSz()
, color = #ffffff00
, text =
str.tostring(
math.round(full.get(y).vol, 3), format = format.volume) + " (" + str.tostring(dV.get(y)) + "%)"
)
)
method dispFVG(FVG fvg, int i, bool bull) =>
ext = fvgextend ? extend.right : extend.none
if not fvg.isbb
bin.bx.unshift(box .new(top = fvg.top, bottom = fvg.btm, left = fvg.loc , right = time , border_color = na , bgcolor = bull ? fvg_upcss : fvg_dncss , xloc = xloc.bar_time, extend = ext))
if fvgline
bin.ln.unshift(line.new(x1 = fvg.loc, x2 = time , y1 = math.avg(fvg.top, fvg.btm), y2 = math.avg(fvg.top, fvg.btm), xloc = xloc.bar_time, color = color.new(bull ? fvg_upcss : fvg_dncss, 0) , extend = ext))
if dispraid
bin.ln.unshift(line.new(x1 = fvg.raidloc, x2 = fvg.raidx2, y1 = fvg.raidy, y2 = fvg.raidy, xloc = xloc.bar_time, color = fvg.raidcs))
bin.lb.unshift(label.new(x = int(math.avg(fvg.raidloc, fvg.raidx2)), y = fvg.raidy, text = "x", xloc = xloc.bar_time, textcolor = fvg.raidcs, style = bull ? label.style_label_up : label.style_label_down, size = size.small, color = #ffffff00))
else
bin.bx.unshift(box .new(top = fvg.top , bottom = fvg.btm, left = fvg.loc , right = fvg.bbloc , border_color = na , bgcolor = bull ? fvg_upcss : fvg_dncss, xloc = xloc.bar_time))
bin.bx.unshift(box .new(top = fvg.top , bottom = fvg.btm, left = fvg.bbloc , right = time , border_color = bull ? fvg_dncss : fvg_upcss , bgcolor = bull ? fvg_dncss : fvg_upcss, xloc = xloc.bar_time, extend = ext))
if fvgline
bin.ln.unshift(line.new(x1 = fvg.loc , x2 = fvg.bbloc , y1 = math.avg(fvg.top, fvg.btm), y2 = math.avg(fvg.top, fvg.btm), color = color.new(bull ? fvg_upcss : fvg_dncss, 0) , xloc = xloc.bar_time))
bin.ln.unshift(line.new(x1 = fvg.bbloc, x2 = time , y1 = math.avg(fvg.top, fvg.btm), y2 = math.avg(fvg.top, fvg.btm), color = color.new(bull ? fvg_dncss : fvg_upcss, 0) , xloc = xloc.bar_time, extend = ext, style = line.style_dashed))
//}
_ ='
------------
–––––––––––––––––––––––––– FUNCTION –––––––––––––––––––––––––––
------------ '//{
mapping() =>
var float up = na
var float dn = na
var float point = na
var int trend = 0
var int idx = na
var int sum = na
var int project = na
var chart.point charts = array.new()
if na(up)
up := high
idx := bar_index
if na(dn)
dn := low
idx := bar_index
if high > up
if trend == -1
id = IDMIDX(false, idx)
charts.unshift(
chart.point.from_time(
time
, low
)
)
idx := bar_index
point := low
sum := time
up := high
dn := low
project := time
trend := 1
if low < dn
if trend == 1
id = IDMIDX(true, idx)
charts.unshift(
chart.point.from_time(
time
, high
)
)
idx := bar_index
point := high
sum := time
up := high
dn := low
project := time
trend := -1
if barstate.islast
var line ln = na
var polyline pl = na
ln.delete()
pl.delete()
ln := na
pl := na
ln := line.new(
x1 = sum
, x2 = project
, y1 = point
, y2 = trend == 1 ? up : dn
, xloc = xloc.bar_time
, color = color.red
)
pl := polyline.new(
charts
, line_color = mappingcss
, xloc = xloc.bar_time
, line_style = mappingStyle.lstyle()
)
dFVG() =>
= ghl()
var FVG blFVG = array.new()
var FVG brFVG = array.new()
bool upfvg = false
bool dnfvg = false
float blth = l1 + (fvatr * fvgthresh)
float brth = h1 - (fvatr * fvgthresh)
cc = timeframe.change()
switch
what_fvg == "FVG" or what_fvg == "Breakers" =>
if l > h2 and cc and c1 > blth
upfvg := true
if l2 > h and cc and c1 < brth
dnfvg := true
if upfvg
if blFVG.size() > 0
fvg = blFVG.get(0)
if fvg.israid == true and fvg.active == false
fvg.active := true
fvg.raidloc := na
fvg.raidx2 := na
fvg.raidy := na
fvg.raidcs := #ffffff00
blFVG.unshift(
FVG.new(
l
, h2
, time
, false
, na
)
)
if dnfvg
if brFVG.size() > 0
fvg = brFVG.get(0)
if fvg.israid == true and fvg.active == false
fvg = brFVG.get(0)
fvg.active := true
fvg.active := true
fvg.raidloc := na
fvg.raidx2 := na
fvg.raidy := na
fvg.raidcs := #ffffff00
brFVG.unshift(
FVG.new(
l2
, h
, time
, false
, na
)
)
if blFVG.size() > 0
for in blFVG
if not fvg.isbb
if fvg_src == "Close" ? math.min(c, o) < fvg.btm : fvg_src == "Wick" ? l < fvg.btm : fvg_src == "Avg" ? l < math.avg(fvg.top, fvg.btm) : na
fvg.isbb := true
fvg.bbloc := time
if what_fvg == "FVG"
blFVG.remove(i)
else
if (fvg_src == "Close" ? math.max(c, o) > fvg.top : fvg_src == "Wick" ? h > fvg.top : fvg_src == "Avg" ? h > math.avg(fvg.top, fvg.btm) : na) and what_fvg == "Breakers"
blFVG.remove(i)
if brFVG.size() > 0
for in brFVG
if not fvg.isbb
if (fvg_src == "Close" ? math.max(c, o) > fvg.top : fvg_src == "Wick" ? h > fvg.top : fvg_src == "Avg" ? h > math.avg(fvg.top, fvg.btm) : na)
fvg.isbb := true
fvg.bbloc := time
if what_fvg == "FVG"
brFVG.remove(i)
else
if (fvg_src == "Close" ? math.min(c, o) < fvg.btm : fvg_src == "Wick" ? l < fvg.btm : fvg_src == "Avg" ? l < math.avg(fvg.top, fvg.btm) : na) and what_fvg == "Breakers"
brFVG.remove(i)
if fvgoverlap
overlapFVG(blFVG, brFVG)
if dispraid
for in blFVG
if not fvg.israid and not fvg.isbb
if low < fvg.top and close > fvg.top
fvg.israid := true
fvg.raidloc := time
fvg.raidx2 := time
fvg.raidy := low
fvg.raidcs := chart.fg_color
else
if low <= fvg.raidy and fvg.active == false and not fvg.isbb
fvg.active := true
fvg.raidx2 := time
else
if fvg.active == false and not fvg.isbb
fvg.raidx2 := time
for in brFVG
if not fvg.israid and not fvg.isbb
if high > fvg.btm and close < fvg.btm and not fvg.isbb
fvg.israid := true
fvg.raidloc := time
fvg.raidy := high
fvg.raidx2 := time
fvg.raidcs := chart.fg_color
else
if high >= fvg.raidy and fvg.active == false and not fvg.isbb
fvg.active := true
fvg.raidx2 := time
else
if fvg.active == false and not fvg.isbb
fvg.raidx2 := time
if barstate.islast
if blFVG.size() > 0 and fvg_num > 0
for i = 0 to math.min(fvg_num - 1, blFVG.size() - 1)
fvg = blFVG.get(i)
dispFVG(fvg, i, true)
if brFVG.size() > 0 and fvg_num > 0
for i = 0 to math.min(fvg_num - 1, brFVG.size() - 1)
fvg = brFVG.get(i)
dispFVG(fvg, i, false)
structure(color upcss, color dncss, bool draw, bool internal, int limit) =>
var structure ms = structure.new(start = 0)
var ob blob = array.new< ob >()
var ob brob = array.new< ob >()
var drawms bldw = array.new< drawms >()
var drawms brdw = array.new< drawms >()
var sellbuyside sellside = array.new()
var sellbuyside buyside = array.new()
bool crossup = false
bool crossdn = false
var float up = na
var float dn = na
idbull = ms.find(false, false, true)
idbear = ms.find(true , false, true)
btmP = obmode == "Length" ? (high - 1 * atr ) < low ? low : (high - 1 * atr ) : low
topP = obmode == "Length" ? (low + 1 * atr ) > high ? high : (low + 1 * atr ) : high
atr = ta.atr (200)
buy = low + atr
sel = high - atr
ph = ta.pivothigh(high, mslen, mslen)
pl = ta.pivotlow (low , mslen, mslen)
var int phn = array.new< int >(1, na)
var int pln = array.new< int >(1, na)
var float php = array.new(1, na)
var float plp = array.new(1, na)
if internal
blob.clear()
brob.clear()
if ph
phn.unshift(bar_index )
php.unshift(high )
if pl
pln.unshift(bar_index )
plp.unshift(low )
if php.size() > 0
if high > php.get(0)
php.clear()
phn.clear()
if plp.size() > 0
if low < plp.get(0)
plp.clear()
pln.clear()
if na(up)
up := high
if na(dn)
dn := low
if high > up
up := high
dn := low
crossup := true
if low < dn
up := high
dn := low
crossdn := true
if ms.start == 0
ms := structure.new(bar_index, na, high, low , bar_index, bar_index, 0, 1, na, bar_index)
if draw
bldw.unshift(drawms.new(time, time, high , "CHoCH" , upcss, line.style_dashed))
brdw.unshift(drawms.new(time, time, low , "CHoCH" , dncss, line.style_dashed))
ms.upsweep := false
ms.dnsweep := false
if ms.start == 1
switch
low <= ms.choch and close >= ms.choch and buildsweep =>
ms.dnsweep := true
ms.choch := low
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
brdw.unshift(
drawms.new(
time
, time
, low
, "CHoCH"
, dncss
, line.style_dashed
)
)
high >= ms.bos and close <= ms.bos and buildsweep =>
ms.upsweep := true
ms.bos := high
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
bldw.unshift(
drawms.new(
time
, time
, high
, "CHoCH"
, upcss
, line.style_dashed
)
)
close <= ms.choch =>
ms.txt := "choch"
lc.start := true
lc.count := 0
blob.fnOB(true, topP, idbull)
ms.trend := -1
ms.choch := ms.bos
ms.bos := na
ms.start := 2
ms.loc := bar_index
ms.main := low
ms.temp := ms.loc
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed : line.style_solid
close >= ms.bos =>
ms.txt := "choch"
lc.start := true
lc.count := 0
brob.fnOB(false, btmP, idbear)
ms.trend := 1
ms.choch := ms.choch
ms.bos := na
ms.start := 2
ms.loc := bar_index
ms.main := high
ms.temp := ms.loc
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed : line.style_solid
if ms.start == 2
switch ms.trend
-1 =>
if low <= ms.main
ms.main := low
ms.temp := bar_index
if bar_index % mslen * 2 == 0
if not na(ms.bos) and msmode == "Adjusted Points" and php.size() > 0
if php.get(0) < ms.choch
// ms.xloc := phn.get(0)
ms.choch := php.get(0)
ms.loc := phn.get(0)
ms.xloc := phn.get(0)
ms.temp := phn.get(0)
if draw
choch = bldw.get(0)
choch.x1 := time
choch.x2 := time
choch.y := php.get(0)
if na(ms.bos)
if crossup and close > open and close > open
ms.bos := ms.main
ms.loc := ms.temp
ms.xloc := ms.loc
if draw
brdw.unshift(
drawms.new(
time
, time
, low
, "BOS"
, dncss
, line.style_dashed
)
)
if not na(ms.bos) and draw
dw = brdw.get(0)
dw.x2 := time
if draw
choch = bldw.get(0)
choch.x2 := time
switch
low <= ms.bos and close >= ms.bos and not na(ms.bos) and buildsweep =>
ms.dnsweep := true
ms.bos := low
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
brdw.unshift(
drawms.new(
time
, time
, low
, "BOS"
, dncss
, line.style_dashed
)
)
ms.xloc := bar_index
close <= ms.bos and not na(ms.bos) =>
ms.txt := "bos"
ms.zz := ms.bos
ms.zn := bar_index
lc.start := true
lc.count := 0
brob.fnOB(false, btmP, idbear)
id = ms.find(true, false, false)
ms.xloc := bar_index
ms.bos := na
ms.choch := high
ms.loc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed : line.style_solid
choch = bldw.get(0)
choch.x1 := time
choch.x2 := time
choch.y := high
switch
high >= ms.choch and close <= ms.choch and buildsweep =>
ms.upsweep := true
ms.choch := high
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
bldw.unshift(
drawms.new(
time
, time
, high
, "CHoCH"
, upcss
, line.style_dashed
)
)
close >= ms.choch =>
ms.txt := "choch"
ms.zz := ms.choch
ms.zn := bar_index
lc.start := true
lc.count := 0
blob.fnOB(true, topP, idbull)
id = ms.find(false, false, false)
switch
na(ms.bos) =>
ms.choch := low
if draw
brdw.unshift(
drawms.new(
time
, time
, low
, "BOS"
, dncss
, line.style_dashed
)
)
choch = brdw.get(0)
choch.x1 := time
=> ms.choch := ms.bos//low < low ? low : low
ms.bos := na
ms.main := high
ms.trend := 1
ms.loc := bar_index
ms.xloc := bar_index
ms.temp := ms.loc
if draw
dw = bldw.get(0)
dw.x2 := time
dw.txt := "CHoCH"
dw.style := internal ? line.style_dashed : line.style_solid
choch = brdw.get(0)
choch.x2 := time
choch.y := ms.choch
choch.txt := "CHoCH"
ms.xloc := bar_index
blarea.normal := false
1 =>
if high >= ms.main
ms.main := high
ms.temp := bar_index
if na(ms.bos)
if crossdn and close < open and close < open
ms.bos := ms.main
ms.loc := ms.temp
ms.xloc := ms.loc
if draw
bldw.unshift(
drawms.new(
time
, time
, high
, "BOS"
, upcss
, line.style_dashed
)
)
if bar_index % mslen * 2 == 0
if not na(ms.bos) and msmode == "Adjusted Points" and plp.size() > 0
if plp.get(0) > ms.choch
// ms.xloc := pln.get(0)
ms.choch := plp.get(0)
ms.loc := pln.get(0)
ms.xloc := pln.get(0)
ms.temp := pln.get(0)
// ms.loc := pln.get(0)
if draw
choch = brdw.get(0)
choch.x1 := time
choch.x2 := time
choch.y := plp.get(0)
if not na(ms.bos) and draw
dw = bldw.get(0)
dw.x2 := time
if draw
choch = brdw.get(0)
choch.x2 := time
switch
high >= ms.bos and close <= ms.bos and not na(ms.bos) and buildsweep =>
ms.upsweep := true
ms.bos := high
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
bldw.unshift(
drawms.new(
time
, time
, high
, "BOS"
, upcss
, line.style_dashed
)
)
ms.xloc := bar_index
close >= ms.bos and not na(ms.bos) =>
ms.txt := "bos"
ms.zz := ms.bos
ms.zn := bar_index
lc.start := true
lc.count := 0
blob.fnOB(true, topP, idbull)
id = ms.find(false, false, false)
ms.xloc := bar_index
ms.bos := na
ms.choch := low
ms.loc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed : line.style_solid
choch = brdw.get(0)
choch.x1 := time
choch.x2 := time
choch.y := low
switch
low <= ms.choch and close >= ms.choch and buildsweep =>
ms.dnsweep := true
ms.choch := low
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
brdw.unshift(
drawms.new(
time
, time
, low
, "CHoCH"
, dncss
, line.style_dashed
)
)
close <= ms.choch =>
ms.txt := "choch"
ms.zz := ms.choch
ms.zn := bar_index
lc.start := true
lc.count := 0
brob.fnOB(false, btmP, idbear)
id = ms.find(true, false, false)
switch
na(ms.bos) =>
ms.choch := high
if draw
bldw.unshift(
drawms.new(
time
, time
, high
, "BOS"
, upcss
, line.style_dashed
)
)
choch = bldw.get(0)
choch.x1 := time
=> ms.choch := ms.bos//high > high ? high : high
ms.bos := na
ms.main := low
ms.trend := -1
ms.loc := bar_index
ms.temp := ms.loc
if draw
dw = brdw.get(0)
dw.x2 := time
dw.txt := "CHoCH"
dw.style := internal ? line.style_dashed : line.style_solid
choch = bldw.get(0)
choch.y := ms.choch
choch.x2 := time
choch.txt := "CHoCH"
ms.xloc := bar_index
if blob.size() > 0
ob = blob.get(0)
if not ob.isbb
if low < ob.top
if blobenter.normal == false
blobenter.normal := true
else
if high > ob.btm
if blobenter.breaker == false
blobenter.breaker := true
if brob.size() > 0
ob = brob.get(0)
if not ob.isbb
if high > ob.btm
if brobenter.normal == false
brobenter.normal := true
else
if low < ob.top
if brobenter.breaker == false
brobenter.breaker := true
if obshow and oblast > 0
if barstate.isconfirmed
blob.mitigated()
brob.mitigated()
if overlap
overlap(blob, brob)
if blob.size() > 0
for in blob
metric.umt()
if brob.size() > 0
for in brob
metric.umt()
if barstate.islast
if blob.size() > 0
for i = 0 to math.min(oblast - 1, blob.size() - 1)
obs = blob.get(i)
display(obs, blob, i)
if brob.size() > 0
for i = 0 to math.min(oblast - 1, brob.size() - 1)
obs = brob.get(i)
display(obs, brob, i)
if barstate.islast and draw and bldw.size() > 0 and brdw.size() > 0
for i = 0 to bldw.size() - 1
obj = bldw.get(i)
if i <= limit
bin.ln.unshift(
line.new(
x1 = obj.x1
, x2 = obj.x2
, y1 = obj.y
, y2 = obj.y
, color = obj.css
, style = obj.style
, xloc = xloc.bar_time
)
)
bin.lb.unshift(
label.new(
x = int(math.avg(bin.ln.get(0).get_x1(), bin.ln.get(0).get_x2()))
, y = obj.y
, xloc = xloc.bar_time
, color = #ffffff00
, style = label.style_label_down
, textcolor = obj.css
, size = mstext.txSz()
, text = obj.txt
)
)
if msbubble
bin.lb.unshift(
label.new(
x = obj.x1
, y = obj.y
, xloc = xloc.bar_time
, color = color.new(obj.css, 80)
, style = label.style_circle
, size = size.tiny
)
)
for i = 0 to brdw.size() - 1
obj = brdw.get(i)
if i <= limit
bin.ln.unshift(
line.new(
x1 = obj.x1
, x2 = obj.x2
, y1 = obj.y
, y2 = obj.y
, color = obj.css
, style = obj.style
, xloc = xloc.bar_time
)
)
bin.lb.unshift(
label.new(
x = int(math.avg(bin.ln.get(0).get_x1(), bin.ln.get(0).get_x2()))
, y = obj.y
, xloc = xloc.bar_time
, color = #ffffff00
, style = label.style_label_up
, textcolor = obj.css
, size = mstext.txSz()
, text = obj.txt
)
)
if msbubble
bin.lb.unshift(
label.new(
x = obj.x1
, y = obj.y
, xloc = xloc.bar_time
, color = color.new(obj.css, 80)
, style = label.style_circle
, size = size.tiny
)
)
ms
//}
_ ='
------------
–––––––––––––––––––––––––– EXECUTION –––––––––––––––––––––––––––
------------ '//{
structure ms = na
if windowsis
if (bar_index > last_bar_index - mswindow)
ms := structure(swingcssup , swingcssdn , showSwing , false, swingLimit)
if windowsis == false
ms := structure(swingcssup , swingcssdn , showSwing , false, swingLimit)
// if showInternal and inZone
// structure ims = structure(interncssup, interncssdn, showInternal, true , swingLimit)
color css = na
method darkcss(color css, float factor) =>
blue = color.b(css) * (1 - factor)
red = color.r(css) * (1 - factor)
green = color.g(css) * (1 - factor)
color.rgb(red, green, blue, 0)
if windowsis ? (bar_index > last_bar_index - mswindow) : true
css := ms.trend == 1 ? swingcssup : swingcssdn
css := (ms.txt == "bos" ? css : css.darkcss(0.3))
barcolor(candlecss ? css : na)
if fvg_enable
dFVG()
if showMapping
mapping()
var phl = Zphl.new(
na
, na
, label.new(na , na , color = invcol , textcolor = swingcssdn , style = label.style_label_down , size = size.tiny , text = "")
, label.new(na , na , color = invcol , textcolor = swingcssup , style = label.style_label_up , size = size.tiny , text = "")
, true
, true
, true
, true
, ""
, ""
, 0
, 0
, 0
, 0
, high
, low
, 0
, 0
, 0
, 0
, 0
, 0
, na
, na
)
// إعدادات تفعيل/تعطيل وتخصيص لكل مستوى فيبوناتشي
// حساب آخر قمة وقاع محوري
int fib_pivot_len = 5
ph = ta.pivothigh(high, fib_pivot_len, fib_pivot_len)
pl = ta.pivotlow(low, fib_pivot_len, fib_pivot_len)
var float last_high = na
var int last_high_x = na
var float last_low = na
var int last_low_x = na
if not na(ph)
last_high := high
last_high_x := bar_index - fib_pivot_len
if not na(pl)
last_low := low
last_low_x := bar_index - fib_pivot_len
var float fib_top = na
var float fib_bottom = na
var int fib_x1 = na
var int fib_x2 = na
if not na(last_high) and not na(last_low)
if last_high_x > last_low_x
fib_top := last_high
fib_bottom := last_low
fib_x1 := last_low_x
fib_x2 := last_high_x
else
fib_top := last_high
fib_bottom := last_low
fib_x1 := last_high_x
fib_x2 := last_low_x
var line fib_lines_pivot = array.new()
var label fib_labels_pivot = array.new()
if not na(fib_top) and not na(fib_bottom) and not na(fib_x1) and not na(fib_x2)
if barstate.islast
// حذف الخطوط والليبلات القديمة
for l in fib_lines_pivot
l.delete()
fib_lines_pivot.clear()
for lb in fib_labels_pivot
lb.delete()
fib_labels_pivot.clear()
// ...existing code...
fib_vals = array.from(0.0, 0.236, 0.382, 0.5, 0.618, 0.786, 1.0, 1.272, 1.618, 1.80, 2.0, 2.272, 2.618)
fib_shows = array.from(show_fib_0, show_fib_236, show_fib_382, show_fib_5, show_fib_618, show_fib_786, show_fib_1, show_fib_1272, show_fib_1618, show_fib_180, show_fib_2, show_fib_2272, show_fib_2618)
fib_colors = array.from(fib_color_0, fib_color_236, fib_color_382, fib_color_5, fib_color_618, fib_color_786, fib_color_1, fib_color_1272, fib_color_1618, fib_color_180, fib_color_2, fib_color_2272, fib_color_2618)
fib_texts = array.from("0.0", "23.6%", "38.2%", "50.0%", "61.8%", "78.6%", "100%", "127.2%", "161.8%", "180%", "200%", "227.2%", "261.8%")
// عند رسم الخطوط والليبلات:
for i = 0 to array.size(fib_vals) - 1
level_val = array.get(fib_vals, i)
level_show = array.get(fib_shows, i)
level_color = array.get(fib_colors, i)
level_txt = array.get(fib_texts, i)
if level_show
price = fib_bottom + (fib_top - fib_bottom) * level_val
l = line.new(x1=fib_x1, y1=price, x2=fib_x2 + fib_shift, y2=price, color=level_color, width=1, style=line.style_dotted, xloc=xloc.bar_index)
array.push(fib_lines_pivot, l)
lb = label.new(x=fib_x2 + fib_shift, y=price, text=level_txt + " | " + str.tostring(price, format.mintick), color=#ffffff00, textcolor=level_color, size=fib_size, style=label.style_label_left, xloc=xloc.bar_index)
array.push(fib_labels_pivot, lb)
10-Day Avg Upside vs Downside VolumeUpside Volume: The total volume on days when the stock closes higher than the previous day.
Downside Volume: The total volume on days when the stock closes lower than the previous day.
It calculates the 10-day simple moving average of both upside and downside volumes.
An optional ratio line is included to visualize relative buying vs selling pressure.