High ATRHigh-ATR is an indicator that visualizes volatility using the Average True Range (ATR). It highlights periods of elevated volatility by comparing the ATR to its moving average.
When the ATR exceeds its moving average, it is considered "Overthreshold" and is displayed in red. This helps identify candles with significant volatility.
Note: ATR does not indicate market direction, only the magnitude (width) of the trading range.
Default Settings:
Long length: 50 (used for the ATR moving average)
Short length: 1 (used for the current ATR)
Multiplier: 2
These values can be adjusted depending on your trading style, but this is the default configuration.
Breadth Indicators
SuperZweig thrust (<= 30 dias)SuperZweig Thrust (≤ 30-day breadth trigger)
This study tracks the classic Zweig Breadth Thrust pattern, but restricts valid signals to a 30-bar (≈ 30-trading-day) window.
---
What it plots
| Plot | Meaning |
|------|---------|
| **Blue line** – `EMA10` | 10-bar exponential moving average of the _breadth ratio_:`advancing issues / (advancing + declining)` |
| **Red h-line 0.35** | Oversold threshold ( < 0.35 ) |
| **Green h-line 0.64** | Overbought threshold ( > 0.64 ) |
| **Red “×”** | The moment EMA10 crosses **down** through 0.35 |
| **Green “●”** | The moment EMA10 crosses **up** through 0.64 |
| **Green “BUY” label** | Complete Super-Zweig thrust: red × followed by green ● **within 30 daily bars** |
Signal logic
1. **Trigger phase** – when EMA10 drops below 0.35
*Script starts a 30-bar countdown.*
2. **Confirmation phase** – if, while the countdown is active, EMA10 rises above 0.64:
*A single “BUY” label is plotted beneath that bar.*
3. **Expiry** – if 30 bars elapse without the 0.64 cross, the cycle resets; no signal is produced.
4. After any valid “BUY” the cycle also resets, so a new signal requires a fresh cross < 0.35.
Inputs
* **EMA length** – default 10.
* **Advancing / Declining symbols** – default `ADVS` / `DECS` (NYSE issues); can be pointed to any Exchange-specific or custom breadth tickers.
Typical use
Apply on a **daily chart** of a broad index (e.g., S&P; 500).
A printed “BUY” indicates a historically rare surge in market breadth often associated with durable rallies. Combine with other risk-management and trend filters before trading.
Custom Multi-Indicator [bandar]//1-SuperTrend 2-MACD 3-RSI 4-Stochastic 5-EMA (50 & 200) 6-Bollinger Bands 7-ADX 8-Ichimoku Cloud 9-Volume Weighted Average Price (VWAP) 10-Parabolic SAR
//@version=5
indicator("Custom Multi-Indicator ", overlay=true)
// SuperTrend (تم التصحيح النهائي هنا)
atrPeriod = 10
factor = 3.0
= request.security(syminfo.tickerid, timeframe.period, ta.supertrend(factor, atrPeriod))
supertrendBuy = close > supertrend
supertrendSell = close < supertrend
// MACD
= ta.macd(close, 12, 26, 9)
macdBuy = ta.crossover(macdLine, signalLine)
macdSell = ta.crossunder(macdLine, signalLine)
// RSI
rsi = ta.rsi(close, 14)
rsiBuy = rsi < 30
rsiSell = rsi > 70
// Stochastic (تصحيح كامل)
k = ta.stoch(close, high, low, 14)
d = ta.sma(k, 3)
stochBuy = ta.crossover(k, d) and k < 20
stochSell = ta.crossunder(k, d) and k > 80
// EMA Cross
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
emaBuy = ta.crossover(ema50, ema200)
emaSell = ta.crossunder(ema50, ema200)
// Bollinger Bands
= ta.bb(close, 20, 2)
bbBuy = ta.crossover(close, lower)
bbSell = ta.crossunder(close, upper)
// ADX
= ta.dmi(14, 14)
adxBuy = adx > 25 and diPlus > diMinus
adxSell = adx > 25 and diPlus < diMinus
// Ichimoku Cloud (تصحيح يدوي كامل)
conversionLine = (ta.highest(high, 9) + ta.lowest(low, 9)) / 2
baseLine = (ta.highest(high, 26) + ta.lowest(low, 26)) / 2
leadingSpanA = (conversionLine + baseLine) / 2
leadingSpanB = (ta.highest(high, 52) + ta.lowest(low, 52)) / 2
laggingSpan = close
// إشارات الشراء والبيع بناءً على الكلاود
ichiBuy = close > leadingSpanA and close > leadingSpanB
ichiSell = close < leadingSpanA and close < leadingSpanB
// VWAP
vwap = ta.vwap
vwapBuy = close > vwap
vwapSell = close < vwap
// Parabolic SAR (تصحيح كامل)
sar = ta.sar(0.02, 0.02, 0.2)
sarBuy = close > sar
sarSell = close < sar
// حساب مجموع الإشارات
buySignals = (supertrendBuy ? 1 : 0) + (macdBuy ? 1 : 0) + (rsiBuy ? 1 : 0) + (stochBuy ? 1 : 0) +
(emaBuy ? 1 : 0) + (bbBuy ? 1 : 0) + (adxBuy ? 1 : 0) + (ichiBuy ? 1 : 0) +
(vwapBuy ? 1 : 0) + (sarBuy ? 1 : 0)
sellSignals = (supertrendSell ? 1 : 0) + (macdSell ? 1 : 0) + (rsiSell ? 1 : 0) + (stochSell ? 1 : 0) +
(emaSell ? 1 : 0) + (bbSell ? 1 : 0) + (adxSell ? 1 : 0) + (ichiSell ? 1 : 0) +
(vwapSell ? 1 : 0) + (sarSell ? 1 : 0)
// شروط القرار النهائي
finalBuy = buySignals >= 7
finalSell = sellSignals >= 7
// الرسم على الشارت
plotshape(finalBuy, title="BUY Signal", location=location.belowbar, style=shape.labelup, color=color.green, size=size.tiny, text="BUY")
plotshape(finalSell, title="SELL Signal", location=location.abovebar, style=shape.labeldown, color=color.red, size=size.tiny, text="SELL")
// تلوين الخلفية
bgcolor(finalBuy ? color.new(color.green,90) : finalSell ? color.new(color.red,90) : na)
// إظهار عدد الإشارات
var label lbl = na
if barstate.islast
label.delete(lbl)
lbl := label.new(bar_index, high, str.tostring(buySignals) + " Buy | " + str.tostring(sellSignals) + " Sell", color=color.white, style=label.style_label_down)
SuperTrend + MACD Webhook (bandar)//@version=5
indicator("SuperTrend + MACD Webhook (bandar)", overlay=true)
// === إعدادات SuperTrend ===
atrPeriod = input.int(10, title="ATR Length")
factor = input.float(1.5, title="Multiplier", step=0.1) // ← تم تحديد step = 0.1 بوضوح
= ta.supertrend(factor, atrPeriod)
// === إعدادات MACD ===
fastLen = input.int(12, title="MACD Fast Length")
slowLen = input.int(26, title="MACD Slow Length")
signalSmoothing = input.int(9, title="MACD Signal Smoothing")
= ta.macd(close, fastLen, slowLen, signalSmoothing)
// === منطق الدخول والخروج ===
longSignal = trendDir == 1 and macdLine > signalLine
shortSignal = trendDir == -1 and macdLine < signalLine
// === منع تكرار الإشارة
var bool inTrade = false
symbolName = syminfo.ticker
// === إشارات وتنبيهات webhook
buyCondition = longSignal and not inTrade
sellCondition = shortSignal and inTrade
if buyCondition
inTrade := true
label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white)
alert('{"action":"buy","symbol":"' + symbolName + '"}', alert.freq_once_per_bar_close)
if sellCondition
inTrade := false
label.new(bar_index, high, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white)
alert('{"action":"sell","symbol":"' + symbolName + '"}', alert.freq_once_per_bar_close)
// === عرض خط SuperTrend
plot(supertrend, color=trendDir == 1 ? color.green : color.red, title="SuperTrend Line")
Zweig Market Breadth Thrust Indicator+Trigger [LazyBear x rwak]The Breadth Thrust (BT) indicator is a market momentum indicator developed by Dr. Martin Zweig. According to Dr. Zweig, a Breadth Thrust occurs when, during a 10-day period, the Breadth Thrust indicator rises from below 40 percent to above 61.5 percent.
A "Thrust" indicates that the stock market has rapidly changed from an oversold condition to one of strength, but has not yet become overbought. This is very rare and has happened only a few times. Dr. Zweig also points out that most bull markets begin with a Breadth Thrust.
This version of the Breadth Thrust indicator includes a trigger visualized with red circles, making it easier to spot when the indicator crosses the critical 61.5% level, signaling potential bullish momentum.
All parameters are configurable. You can draw BT for NYSE, NASDAQ, AMEX, or based on combined data (i.e., AMEX+NYSE+NASD). There is also a "CUSTOM" mode supported, so you can enter your own ADV/DEC symbols.
Credit: The original Breadth Thrust logic was created by LazyBear, whose public indicators can be found here , and app-store indicators here .
More info:
Definition of Breadth Thrust
A Breadth Thrust Signal
A Rare "Zweig" Buy Signal
Zweig Breadth Thrust: Redux
ADR% Extension Levels from SMA 50I created this indicator inspired by RealSimpleAriel (a swing trader I recommend following on X) who does not buy stocks extended beyond 4 ADR% from the 50 SMA and uses extensions from the 50 SMA at 7-8-9-10-11-12-13 ADR% to take profits with a 20% position trimming.
RealSimpleAriel's strategy (as I understood it):
-> Focuses on leading stocks from leading groups and industries, i.e., those that have grown the most in the last 1-3-6 months (see on Finviz groups and then select sector-industry).
-> Targets stocks with the best technical setup for a breakout, above the 200 SMA in a bear market and above both the 50 SMA and 200 SMA in a bull market, selecting those with growing Earnings and Sales.
-> Buys stocks on breakout with a stop loss set at the day's low of the breakout and ensures they are not extended beyond 4 ADR% from the 50 SMA.
-> 3-5 day momentum burst: After a breakout, takes profits by selling 1/2 or 1/3 of the position after a 3-5 day upward move.
-> 20% trimming on extension from the 50 SMA: At 7 ADR% (ADR% calculated over 20 days) extension from the 50 SMA, takes profits by selling 20% of the remaining position. Continues to trim 20% of the remaining position based on the stock price extension from the 50 SMA, calculated using the 20-period ADR%, thus trimming 20% at 8-9-10-11 ADR% extension from the 50 SMA. Upon reaching 12-13 ADR% extension from the 50 SMA, considers the stock overextended, closes the remaining position, and evaluates a short.
-> Trailing stop with ascending SMA: Uses a chosen SMA (10, 20, or 50) as the definitive stop loss for the position, depending on the stock's movement speed (preferring larger SMAs for slower-moving stocks or for long-term theses). If the stock's closing price falls below the chosen SMA, the entire position is closed.
In summary:
-->Buy a breakout using the day's low of the breakout as the stop loss (this stop loss is the most critical).
--> Do not buy stocks extended beyond 4 ADR% from the 50 SMA.
--> Sell 1/2 or 1/3 of the position after 3-5 days of upward movement.
--> Trim 20% of the position at each 7-8-9-10-11-12-13 ADR% extension from the 50 SMA.
--> Close the entire position if the breakout fails and the day's low of the breakout is reached.
--> Close the entire position if the price, during the rise, falls below a chosen SMA (10, 20, or 50, depending on your preference).
--> Definitively close the position if it reaches 12-13 ADR% extension from the 50 SMA.
I used Grok from X to create this indicator. I am not a programmer, but based on the ADR% I use, it works.
Below is Grok from X's description of the indicator:
Script Description
The script is a custom indicator for TradingView that displays extension levels based on ADR% relative to the 50-period Simple Moving Average (SMA). Below is a detailed description of its features, structure, and behavior:
1. Purpose of the Indicator
Name: "ADR% Extension Levels from SMA 50".
Objective: Draw horizontal blue lines above and below the 50-period SMA, corresponding to specific ADR% multiples (4, 7, 8, 9, 10, 11, 12, 13). These levels represent potential price extension zones based on the average daily percentage volatility.
Overlay: The indicator is overlaid on the price chart (overlay=true), so the lines and SMA appear directly on the price graph.
2. Configurable Inputs
The indicator allows users to customize parameters through TradingView settings:
SMA Length (smaLength):
Default: 50 periods.
Description: Specifies the number of periods for calculating the Simple Moving Average (SMA). The 50-period SMA serves as the reference point for extension levels.
Constraint: Minimum 1 period.
ADR% Length (adrLength):
Default: 20 periods.
Description: Specifies the number of days to calculate the moving average of the daily high/low ratio, used to determine ADR%.
Constraint: Minimum 1 period.
Scale Factor (scaleFactor):
Default: 1.0.
Description: An optional multiplier to adjust the distance of extension levels from the SMA. Useful if levels are too close or too far due to an overly small or large ADR%.
Constraint: Minimum 0.1, increments of 0.1.
Tooltip: "Adjust if levels are too close or far from SMA".
3. Main Calculations
50-period SMA:
Calculated with ta.sma(close, smaLength) using the closing price (close).
Serves as the central line around which extension levels are drawn.
ADR% (Average Daily Range Percentage):
Formula: 100 * (ta.sma(dhigh / dlow, adrLength) - 1).
Details:
dhigh and dlow are the daily high and low prices, obtained via request.security(syminfo.tickerid, "D", high/low) to ensure data is daily-based, regardless of the chart's timeframe.
The dhigh / dlow ratio represents the daily percentage change.
The simple moving average (ta.sma) of this ratio over 20 days (adrLength) is subtracted by 1 and multiplied by 100 to obtain ADR% as a percentage.
The result is multiplied by scaleFactor for manual adjustments.
Extension Levels:
Defined as ADR% multiples: 4, 7, 8, 9, 10, 11, 12, 13.
Stored in an array (levels) for easy iteration.
For each level, prices above and below the SMA are calculated as:
Above: sma50 * (1 + (level * adrPercent / 100))
Below: sma50 * (1 - (level * adrPercent / 100))
These represent price levels corresponding to a percentage change from the SMA equal to level * ADR%.
4. Visualization
Horizontal Blue Lines:
For each level (4, 7, 8, 9, 10, 11, 12, 13 ADR%), two lines are drawn:
One above the SMA (e.g., +4 ADR%).
One below the SMA (e.g., -4 ADR%).
Color: Blue (color.blue).
Style: Solid (style=line.style_solid).
Management:
Each level has dedicated variables for upper and lower lines (e.g., upperLine1, lowerLine1 for 4 ADR%).
Previous lines are deleted with line.delete before drawing new ones to avoid overlaps.
Lines are updated at each bar with line.new(bar_index , level, bar_index, level), covering the range from the previous bar to the current one.
Labels:
Displayed only on the last bar (barstate.islast) to avoid clutter.
For each level, two labels:
Above: E.g., "4 ADR%", positioned above the upper line (style=label.style_label_down).
Below: E.g., "-4 ADR%", positioned below the lower line (style=label.style_label_up).
Color: Blue background, white text.
50-period SMA:
Drawn as a gray line (color.gray) for visual reference.
Diagnostics:
ADR% Plot: ADR% is plotted in the status line (orange, histogram style) to verify the value.
ADR% Label: A label on the last bar near the SMA shows the exact ADR% value (e.g., "ADR%: 2.34%"), with a gray background and white text.
5. Behavior
Dynamic Updating:
Lines update with each new bar to reflect new SMA 50 and ADR% values.
Since ADR% uses daily data ("D"), it remains constant within the same day but changes day-to-day.
Visibility Across All Bars:
Lines are drawn on every bar, not just the last one, ensuring visibility on historical data as well.
Adaptability:
The scaleFactor allows level adjustments if ADR% is too small (e.g., for low-volatility symbols) or too large (e.g., for cryptocurrencies).
Compatibility:
Works on any timeframe since ADR% is calculated from daily data.
Suitable for symbols with varying volatility (e.g., stocks, forex, cryptocurrencies).
6. Intended Use
Technical Analysis: Extension levels represent significant price zones based on average daily volatility. They can be used to:
Identify potential price targets (e.g., take profit at +7 ADR%).
Assess support/resistance zones (e.g., -4 ADR% as support).
Measure price extension relative to the 50 SMA.
Trading: Useful for strategies based on breakouts or mean reversion, where ADR% levels indicate reversal or continuation points.
Debugging: Labels and ADR% plot help verify that values align with the symbol’s volatility.
7. Limitations
Dependence on Daily Data: ADR% is based on daily dhigh/dlow, so it may not reflect intraday volatility on short timeframes (e.g., 1 minute).
Extreme ADR% Values: For low-volatility symbols (e.g., bonds) or high-volatility symbols (e.g., meme stocks), ADR% may require adjustments via scaleFactor.
Graphical Load: Drawing 16 lines (8 upper, 8 lower) on every bar may slow the chart for very long historical periods, though line management is optimized.
ADR% Formula: The formula 100 * (sma(dhigh/dlow, Length) - 1) may produce different values compared to other ADR% definitions (e.g., (high - low) / close * 100), so users should be aware of the context.
8. Visual Example
On a chart of a stock like TSLA (daily timeframe):
The 50 SMA is a gray line tracking the average trend.
Assuming an ADR% of 3%:
At +4 ADR% (12%), a blue line appears at sma50 * 1.12.
At -4 ADR% (-12%), a blue line appears at sma50 * 0.88.
Other lines appear at ±7, ±8, ±9, ±10, ±11, ±12, ±13 ADR%.
On the last bar, labels show "4 ADR%", "-4 ADR%", etc., and a gray label shows "ADR%: 3.00%".
ADR% is visible in the status line as an orange histogram.
9. Code: Technical Structure
Language: Pine Script @version=5.
Inputs: Three configurable parameters (smaLength, adrLength, scaleFactor).
Calculations:
SMA: ta.sma(close, smaLength).
ADR%: 100 * (ta.sma(dhigh / dlow, adrLength) - 1) * scaleFactor.
Levels: sma50 * (1 ± (level * adrPercent / 100)).
Graphics:
Lines: Created with line.new, deleted with line.delete to avoid overlaps.
Labels: Created with label.new only on the last bar.
Plots: plot(sma50) for the SMA, plot(adrPercent) for debugging.
Optimization: Uses dedicated variables for each line (e.g., upperLine1, lowerLine1) for clear management and to respect TradingView’s graphical object limits.
10. Possible Improvements
Option to show lines only on the last bar: Would reduce visual clutter.
Customizable line styles: Allow users to choose color or style (e.g., dashed).
Alert for anomalous ADR%: A message if ADR% is too small or large.
Dynamic levels: Allow users to specify ADR% multiples via input.
Optimization for short timeframes: Adapt ADR% for intraday timeframes.
Conclusion
The script creates a visual indicator that helps traders identify price extension levels based on daily volatility (ADR%) relative to the 50 SMA. It is robust, configurable, and includes debugging tools (ADR% plot and labels) to verify values. The ADR% formula based on dhigh/dlow
Ichimoku Chikou Breakout Strategy v2The Zerep indicator, which identifies compression and breakout zones based on the behavior of the lagging span within an Ichimoku framework.
Smart Multi-Signal System PROInput Parameters The script allows users to customize settings via TradingView’s input panel:lookback (default: 20): The number of bars to look back to identify pivot highs/lows for supply/demand zones. Affects the sensitivity of zone detection.risk_reward (default: 5.0): The risk-reward ratio for calculating take-profit levels relative to stop-loss. For example, a 5.0 ratio means the take-profit target is 5 times the stop-loss distance.rsi_period (default: 14): The period for calculating the RSI, used as a momentum filter.rsi_overbought (default: 70): RSI level above which a market is considered overbought (used for sell signals).rsi_oversold (default: 30): RSI level below which a market is considered oversold (used for buy signals
Nirvana Mode PRO v2 - FULL AUTONİRVANAPROV2 INDİKATOR H4RSI_TRENDBOT
emaFast = ta.ema(close, 8)
emaSlow = ta.ema(close, 21)
rsi = ta.rsi(close, 14)
= ta.supertrend(2.0, 10)
volAvg = ta.sma(volume, 10)
volSpike = volume > volAvg * 1.5
CryptoQuebec Suite// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// Crypto Quebec & StefB.
//@version=6
indicator("CryptoQuebec Suite", overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, max_bars_back = 500)
//strategy("UT BOT Amélioré pour le Day Trading Crypto", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Version 2.0 order block ajustable colors
// Version 2.1 draw swing High/low
// Version 2.2 Changed the wording of "Area of interest" for "Premium Zone" and "Discount Zone"
// Version 2.3 Added the price to the auto fib levels.
// Version 2.4 Correction. Added 3 digits after the dot of the auto fib. This was lost when the price has been added.
// Version 2.4.01 Added few fib levels. (0, -0.272, -0.414, -0.618).
// Version 2.4.02 Added few fib levels. (1, 1.272, 1.414, 1.618).
// Version 2.4.03 Made a small change in the label of 240L, 240H, DL and DH. Change 240 for 4h and H/L for Lo/Hi
// Version 2.4.04 Added digits after the dot for more price precision into the Fib levels.
// Version 2.4.05 Added Entry long/short indicator base on EMA. Also added the trailing stop line.
// Version 2.4.06 Added Trail Stop enable/disable option. Moved the Buy/Sell label farther from the candles.
// Version 2.4.07 Added Trend info table with active trading session
// Version 2.4.08 Small adjustment in the trend table and FIB lines more visible.
// Version 2.4.09 Changed the indicator name for CryptoQuebe Suite.
//---------------------------------------------------------------------------------------------------------------------
//CONSTANTS & STRINGS & INPUTS
//---------------------------------------------------------------------------------------------------------------------
BULLISH = +1
BEARISH = -1
showHighLowSwingsTooltip = 'Highlight most recent strong and weak high/low points on the chart'
bullC = input.color(defval = #14D990, title = "Bull Color", group = "Smart Money Concepts", inline = "7")
bearC = input.color(defval = #F24968, title = "Bear Color", group = "Smart Money Concepts", inline = "7")
showInt = input.bool(defval = true, title = "Show Internals", group = "Smart Money Concepts")
intSens = input.int(3, "Internals Sensitivity", options = , group = "Smart Money Concepts", inline = "20")
intStru = input.string(defval = "All", title = "Internal Structure", options = , inline = "30", group = "Smart Money Concepts")
showExt = input.bool(defval = true, title = "Show Externals" ,group = "Smart Money Concepts")
extSens = input.int(25, "Externals Sensitivity", options = ,group = "Smart Money Concepts", inline = "21")
extStru = input.string(defval = "All", title = "External Structure", options = , inline = "31", group = "Smart Money Concepts")
showOB = input.bool(defval = true, title = "Show Order Blocks" ,group = "Swing Blocks")
//----------------------------------------------
//showHighLowSwingsInput = input(true, 'Show Strong/Weak High/Low', group = "Smart Money Concepts", tooltip = showHighLowSwingsTooltip)
BullOBColor = input.color(color.new(#3179f5, 80), 'Internal Bullish OB',group = "Swing Blocks")
BearOBColor = input.color(color.new(#f77c80, 80), 'Internal Bearish OB',group = "Swing Blocks")
//---------------------------------------------------------------------------
showLast = input.int(defval = 10, title = "Swing Order Blocks", minval = 0, group = "Swing Blocks")
showHHLH = input.bool(defval = true, title = "Show HH/LH", group = "Swing Blocks")
showHLLL = input.bool(defval = true, title = "Show LH/LL", group = "Swing Blocks")
showAOE = input.bool(defval = true, title = "Show Premium/Discount", group = "Swing Blocks")
//showAOE = input.bool(defval = true, title = "Show Area of Interest", group = "Swing Blocks")
show1D = input.bool(defval = true, title = "Show Previous Day High", group = "High/Low")
show1DLab = input.bool(defval = true, title = "Show 1 Day Labels", group = "High/Low")
show4H = input.bool(defval = true, title = "Show 4 Hour High", group = "High/Low")
show4hLab = input.bool(defval = true, title = "Show 4 Hour Labels", group = "High/Low")
showFVG = input.bool(defval = true, title = "Show Fair Value Gaps", group = "FVG")
contract = input.bool(defval = false, title = "Contract Violated FVG", group = "FVG")
closeOnly = input.bool(defval = false, title = "Show Closest Up/Down FVG Only", group = "FVG")
fvgcol = input.color(defval = #F2B807, title = "FVG Color", group = "FVG")
fvgtra = input.int(defval = 80, minval = 0, maxval = 100, title = "FVG Transparency", group = "FVG")
showFibs = input.bool(defval = true, title = "Show Auto Fibs", group = "Auto Fibs")
// extSensFibs = input.int(25, "Fibs Sensitivity", options = , group = "Auto Fibs", inline = "22")
show0_618 = input.bool(defval = true, title = "", inline = "1", group = "Auto Fibs")
show0_414 = input.bool(defval = true, title = "", inline = "2", group = "Auto Fibs")
show0_272 = input.bool(defval = true, title = "", inline = "3", group = "Auto Fibs")
show0 = input.bool(defval = true, title = "", inline = "4", group = "Auto Fibs")
show236 = input.bool(defval = true, title = "", inline = "5", group = "Auto Fibs")
show382 = input.bool(defval = true, title = "", inline = "6", group = "Auto Fibs")
show5 = input.bool(defval = true, title = "", inline = "7", group = "Auto Fibs")
show618 = input.bool(defval = true, title = "", inline = "8", group = "Auto Fibs")
show65 = input.bool(defval = true, title = "", inline = "9", group = "Auto Fibs")
show786 = input.bool(defval = true, title = "", inline = "10", group = "Auto Fibs")
show1 = input.bool(defval = true, title = "", inline = "11", group = "Auto Fibs")
show1_272 = input.bool(defval = true, title = "", inline = "12", group = "Auto Fibs")
show1_414 = input.bool(defval = true, title = "", inline = "13", group = "Auto Fibs")
show1_618 = input.bool(defval = true, title = "", inline = "14", group = "Auto Fibs")
fib1 = input.float(defval = -0.618, title = "", minval = -0.618, step = 0.01, inline = "1", group = "Auto Fibs")
fib2 = input.float(defval = -0.414, title = "", minval = -0.618, step = 0.01, inline = "2", group = "Auto Fibs")
fib3 = input.float(defval = -0.272, title = "", minval = -0.618, step = 0.01, inline = "3", group = "Auto Fibs")
fib4 = input.float(defval = 0, title = "", minval = 0, step = 0.01, inline = "4", group = "Auto Fibs")
fib5 = input.float(defval = .236, title = "", minval = 0, step = 0.01, inline = "5", group = "Auto Fibs")
fib6 = input.float(defval = .382, title = "", minval = 0, step = 0.01, inline = "6", group = "Auto Fibs")
fib7 = input.float(defval = .5, title = "", minval = 0, step = 0.01, inline = "7", group = "Auto Fibs")
fib8 = input.float(defval = .618, title = "", minval = 0, step = 0.01, inline = "8", group = "Auto Fibs")
fib9 = input.float(defval = .65, title = "", minval = 0, step = 0.01, inline = "9", group = "Auto Fibs")
fib10 = input.float(defval = .786, title = "", minval = 0, step = 0.01, inline = "10", group = "Auto Fibs")
fib11 = input.float(defval = 1, title = "", minval = 0, step = 0.01, inline = "11", group = "Auto Fibs")
fib12 = input.float(defval = 1.272, title = "", minval = 0, step = 0.01, inline = "12", group = "Auto Fibs")
fib13 = input.float(defval = 1.414, title = "", minval = 0, step = 0.01, inline = "13", group = "Auto Fibs")
fib14 = input.float(defval = 1.618, title = "", minval = 0, step = 0.01, inline = "14", group = "Auto Fibs")
fib1col = input.color(title = "", defval = color.orange, inline = "1", group = "Auto Fibs")
fib2col = input.color(title = "", defval = color.orange, inline = "2", group = "Auto Fibs")
fib3col = input.color(title = "", defval = color.orange, inline = "3", group = "Auto Fibs")
fib4col = input.color(title = "", defval = color.gray, inline = "4", group = "Auto Fibs")
fib5col = input.color(title = "", defval = color.white, inline = "5", group = "Auto Fibs")
fib6col = input.color(title = "", defval = color.white, inline = "6", group = "Auto Fibs")
fib7col = input.color(title = "", defval = color.red, inline = "7", group = "Auto Fibs")
fib8col = input.color(title = "", defval = color.green, inline = "8", group = "Auto Fibs")
fib9col = input.color(title = "", defval = color.green, inline = "9", group = "Auto Fibs")
fib10col = input.color(title = "", defval = color.white, inline = "10", group = "Auto Fibs")
fib11col = input.color(title = "", defval = color.gray, inline = "11", group = "Auto Fibs")
fib12col = input.color(title = "", defval = color.orange, inline = "12", group = "Auto Fibs")
fib13col = input.color(title = "", defval = color.orange, inline = "13", group = "Auto Fibs")
fib14col = input.color(title = "", defval = color.orange, inline = "14", group = "Auto Fibs")
//---------------------------------------------------------------------------------------------------------------------
//DATA STRUCTURES & VARIABLES
//---------------------------------------------------------------------------------------------------------------------
// @type UDT representing last swing extremes (top & bottom)
// @field top last top swing price
// @field bottom last bottom swing price
// @field barTime last swing bar time
// @field barIndex last swing bar index
// @field lastTopTime last top swing time
// @field lastBottomTime last bottom swing time
type trailingExtremes
float top
float bottom
int barTime
int barIndex
int lastTopTime
int lastBottomTime
// @type UDT representing trend bias
// @field bias BULLISH or BEARISH
type trend
int bias
var bigData = map.new()
// @variable swing trend bias
var trend swingTrend = trend.new(0)
// @variable last trailing swing high and low
var trailingExtremes trailing = trailingExtremes.new()
// @variable color for swing bullish structures
var swingBullishColor = color.green //styleInput == MONOCHROME ? MONO_BULLISH : swingBullColorInput
// @variable color for swing bearish structures
var swingBearishColor = color.red //styleInput == MONOCHROME ? MONO_BEARISH : swingBearColorInput
if bigData.size() == 0
bigData.put("moving", 0)
bigData.put("upaxis", 0.0)
bigData.put("upaxis2", 0)
bigData.put("dnaxis", 0.0)
bigData.put("dnaxis2", 0)
bigData.put("upside", 1)
bigData.put("downside", 1)
= request.security(syminfo.tickerid, "1D", [high , low , high, low, time , time])
var highArr = array.new_float(), var lowArr = array.new_float()
var timeArr = array.new_int (), var volArr = array.new_float()
var closeArr = array.new_float(), var openArr = array.new_float()
highArr.unshift(high), lowArr.unshift(low)
timeArr.unshift(time), volArr.unshift(volume)
closeArr.unshift(close), openArr.unshift(open)
type rollingTF
float highTF = 0
float lowTF = 1e8
int highTFt = 0
int lowTFt = 0
float volTF = 0
map rTFdraw
map rTFlabel
// Convert time period in text
f_convert_tf_to_text(tf) =>
tf == "240" ? "H4" : tf == "1D" ? "D" : tf == "60" ? "1h" : tf == "15" ? "15m" : tf
// Create the labels fo each level
offset = 10 // Ajustez cette valeur selon le décalage souhaité
// Ajust the label position in case of overide
f_adjust_label_position(x, offset) =>
x + offset
// @function tfDraw
// @param tfDiff Specifies the timeframe difference for the high/low calculations.
// @param showRollingLab Indicates whether to display rolling labels for timeframes.
// @param tf Specifies the timeframe as a string.
// @param showLevels Determines if the high/low levels for the timeframe should be shown.
// @returns A tuple with the total volume (TFhrdata.volTF) and the rolling volume array (volRolling).
method tfDraw(int tfDiff, bool showRollingLab, string tf, bool showLevels) =>
TFhrdata = rollingTF.new(), var volRolling = array.new()
if highArr.size() > tfDiff
for i = 0 to tfDiff
if showLevels and barstate.islast
getHigh = highArr.get(i), getLow = lowArr.get(i),
getTime = timeArr.get(i)
TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh)
TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow )
if TFhrdata.highTF == getHigh
TFhrdata.highTFt := timeArr.get(i)
if TFhrdata.lowTF == getLow
TFhrdata.lowTFt := timeArr.get(i)
TFhrdata.volTF += volArr.get(i)
volRolling.push(TFhrdata.volTF)
var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new())
if showLevels
switch lineDraw.rTFdraw.size() == 0
true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF,
xloc = xloc.bar_time, color = color.aqua)),
lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF ,
xloc = xloc.bar_time, color = color.aqua))
=> lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF),
lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF),
lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF),
lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF)
if showRollingLab
switch lineDraw.rTFlabel.size() == 0
true => lineDraw.rTFlabel.put("High", label.new(f_adjust_label_position(bar_index, offset), TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Hi", style = label.style_label_left, size = size.normal, color = #00000000)),
lineDraw.rTFlabel.put("Low", label.new(f_adjust_label_position(bar_index, offset), TFhrdata.lowTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Lo", style = label.style_label_left, size = size.normal, color = #00000000))
=> lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF),
lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF)
// @function tfDrawLower
// @param showRollingLab Indicates whether to display rolling labels for lower timeframes.
// @param tf Specifies the lower timeframe as a string.
// @param showLevels Determines if the high/low levels for the lower timeframe should be shown.
// @returns (volume and volume array)
tfDrawLower(bool showRollingLab, simple string tf, bool showLevels) =>
simple int end = switch tf
"240" => 240
"1D" => 1440
= request.security_lower_tf(syminfo.tickerid, "1", )
var oArr = array.new_float()
var hArr = array.new_float()
var lArr = array.new_float()
var cArr = array.new_float()
var vArr = array.new_float()
var tArr = array.new_int()
TFhrdata = rollingTF.new(), var volRolling = array.new()
if h.size() > 0
for i = 0 to h.size() - 1
oArr.push(o.get(i))
hArr.push(h.get(i))
lArr.push(l.get(i))
cArr.push(c.get(i))
vArr.push(v.get(i))
tArr.push(t.get(i))
if hArr.size() > end
oArr.shift()
hArr.shift()
lArr.shift()
cArr.shift()
vArr.shift()
tArr.shift()
for i = 0 to hArr.size() - 1
if showLevels
getHigh = hArr.get(i), getLow = lArr.get(i),
getTime = tArr.get(i)
TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh)
TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow)
if TFhrdata.highTF == getHigh
TFhrdata.highTFt := tArr.get(i)
if TFhrdata.lowTF == getLow
TFhrdata.lowTFt := tArr.get(i)
TFhrdata.volTF += vArr.get(i)
volRolling.push(TFhrdata.volTF)
var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new())
if showLevels
switch lineDraw.rTFdraw.size() == 0
true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF,
xloc = xloc.bar_time, color = color.aqua)),
lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF ,
xloc = xloc.bar_time, color = color.aqua))
=> lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF),
lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF),
lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF),
lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF)
if showRollingLab
switch lineDraw.rTFlabel.size() == 0
true => lineDraw.rTFlabel.put("High", label.new(f_adjust_label_position(bar_index, 0), TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Hi", style = label.style_label_left, size = size.normal, color = #00000000)),
lineDraw.rTFlabel.put("Low" , label.new(f_adjust_label_position(bar_index, 0), TFhrdata.lowTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Lo", style = label.style_label_left, size = size.normal, color = #00000000))
=> lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF),
lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF)
var r4hrbars = math.floor(timeframe.in_seconds("240") / timeframe.in_seconds(timeframe.period))
var rDbars = math.floor(timeframe.in_seconds("1D") / timeframe.in_seconds(timeframe.period))
= switch
timeframe.in_seconds() <= 60 => r4hrbars.tfDraw(show4hLab, "240", show4H)
=> tfDrawLower(show4hLab, "240", show4H)
= switch
timeframe.in_seconds() <= 60 => rDbars.tfDraw(show1DLab, "1D", show1D)
=> tfDrawLower(show1DLab, "1D", show1D)
// @function calculatePivots
// @param length Specifies the lookback length for high/low pivot calculations.
// @returns A tuple with top and bottom swing values.
calculatePivots(length)=>
var int intraCalc = 0
if bar_index > length + 1
up = highArr.slice(0, length).max()
dn = lowArr .slice(0, length).min()
cHi = highArr.get(length)
cLo = lowArr .get(length)
intraCalc := switch
cHi > up => 0
cLo < dn => 1
=> intraCalc
topSwing = switch
intraCalc == 0 and intraCalc != 0 => cHi
=> 0
botSwing = switch
intraCalc == 1 and intraCalc != 1 => cLo
=> 0
= calculatePivots(extSens)
= calculatePivots(intSens)
var label upLabel = array.new_label(1)
var label dnLabel = array.new_label(1)
var box highBlock = array.new_box()
var box lowBlock = array.new_box()
drawChar(x, y, str, col, down) =>
style = switch down
true => label.style_label_down
=> label.style_label_up
line.new (int(x), y, bar_index, y, color = col, style = line.style_dashed)
label.new(math.round(math.avg(x, bar_index)), y, str, color = #00000000, textcolor = col, style = style, size = size.small)
// @function drawStructureExt
// @returns Counter indicating the structure direction: 1 for bullish, -1 for bearish, 0 for neutral.
drawStructureExt() =>
var int counter = 0
if bigUpper != 0
bigData.put("upside", 1)
x1 = bar_index - extSens
txt = switch bigUpper > bigData.get("upaxis")
true => 'HH'
=> 'LH'
if showHHLH
upLabel.set(0, label.new(x1, bigUpper, txt,
color = color.new(color.white, 100),
textcolor = bearC,
style = label.style_label_down,
size = size.small
))
if showOB
highBlock.push(box.new(x1, bigUpper, last_bar_index + 5, bigUpper * .998, border_color = BearOBColor, bgcolor = BearOBColor))
bigData.put("upaxis" , bigUpper)
bigData.put("upaxis2", x1)
counter := 1
if bigLower != 0
bigData.put("downside", 1)
x1 = bar_index - extSens
txt = switch bigLower < bigData.get("dnaxis")
true => "LL"
=> "HL"
if showHLLL == true
dnLabel.set(0, label.new(x1, bigLower, txt, color = #ffffff00,
textcolor = bullC,
style = label.style_label_up,
size = size.small
))
if showOB
lowBlock.push(box.new(x1, bigLower, last_bar_index + 5, bigLower * 1.002, border_color = BullOBColor, bgcolor = BullOBColor))
//border_color = color.new(color.blue, 60),//75),
//bgcolor = color.new(color.blue, 70)//95)
//))
bigData.put("dnaxis" , bigLower)
bigData.put("dnaxis2", x1)
counter := -1
if showExt
if ta.crossover(close, bigData.get("upaxis"))
if bigData.get("upside") != 0
str = switch bigData.get("moving") < 0
true => extStru != "BoS" ? 'CHoCH' : ""
=> extStru != 'CHoCH' ? 'BoS' : ""
if extStru == "All" or str.contains(extStru, str)
drawChar(bigData.get("upaxis2"), bigData.get("upaxis"), str, bullC, true)
bigData.put("upside", 0)
bigData.put("moving", 1)
if ta.crossunder(close, bigData.get("dnaxis"))
if bigData.get("downside") != 0
str = switch bigData.get("moving") > 0
true => extStru != "BoS" ? 'CHoCH' : ""
=> extStru != 'CHoCH' ? 'BoS' : ""
if extStru == "All" or str.contains(extStru, str)
drawChar(bigData.get("dnaxis2"), bigData.get("dnaxis"), str, bearC, false)
bigData.put("downside", 0)
bigData.put("moving", -1)
counter
counter = drawStructureExt()
// @function updateBox
// @param id Array of boxes to update based on the bar index.
// @returns void
method updateBox(array id) =>
if id.size() > 0
for i = 0 to id.size() - 1
id.get(i).set_right(last_bar_index + 5)
method cleanseLevel(array id, bool isHighBlock) =>
if id.size() > 0
for i = id.size() - 1 to 0
condition = switch isHighBlock
true => close >= id.get(i).get_top()
=> close <= id.get(i).get_bottom()
if condition
id.remove(i).delete()
if id.size() > showLast and showLast != 0
for i = id.size() - showLast to 0
id.remove(i).delete()
highBlock.cleanseLevel(true)
lowBlock .cleanseLevel(false)
if barstate.islast
highBlock.updateBox()
lowBlock .updateBox()
// @function updateMain
// @param id Line object for updating based on price structure pivots.
// @returns void
// @description Updates the main line indicator to match the latest high/low price levels.
method updateMain(line id) =>
hi = 0.0
lo = 1e8
if showFibs
= calculatePivots(25)
var int counterFibs = 0
if bigUpperFibs != 0
counterFibs := 1
if bigLowerFibs != 0
counterFibs := -1
if counterFibs == 1
hi := 0.0
id.set_xy1(int(bigData.get("upaxis2")), bigData.get("upaxis"))
for i = 0 to bar_index - int(bigData.get("dnaxis2"))
getLow = lowArr.get(i)
lo := math.min(getLow, lo)
if lo == getLow
id.set_xy2(bar_index - i, lo)
else if counterFibs == -1
lo := 1e8
id.set_xy1(int(bigData.get("dnaxis2")), bigData.get("dnaxis"))
for i = 0 to bar_index - bigData.get("upaxis2")
getHigh = highArr.get(i)
hi := math.max(highArr.get(i), hi)
if hi == getHigh
id.set_xy2(bar_index - i, hi)
if id.get_x2() < id.get_x1()
x2 = id.get_x2(), x1 = id.get_x1()
y2 = id.get_y2(), y1 = id.get_y1(),
id.set_xy2(x1, y1),
id.set_xy1(x2, y2)
switch id.get_y2() < id.get_y1()
true => id.set_color(#F24968)
=> id.set_color(#14D990)
0
var main = line.new(dnLabel.first().get_x(), dnLabel.first().get_y(), upLabel.first().get_x(), upLabel.first().get_y(),
style = line.style_dashed,
width = 2
)
main.updateMain()
//-----------------------------------FIB----------------------------------------------------------
// @function quickLine
// @param getX2 The x-coordinate for the endpoint of the line.
// @param y The y-coordinate for the line’s position.
// @param color The color of the line to be drawn.
// @returns void
// @description Draws a horizontal line on the chart with specific attributes.
quickLine(getX2, y, color) =>
line.new(getX2, y, bar_index + 5, y, color = color.new(color, 50))
// @function quickLabel
// @param y The y-coordinate for the label’s position.
// @param txt Text content of the label.
// @param color The text color of the label.
// @returns void
// @description Places a label with given text and color at a specified y-coordinate.
quickLabel(y, txt, color) =>
label.new(bar_index + 5, y, text = str.tostring(txt), color = #00000000, style = label.style_label_left, textcolor = color)
// @function drawFibs
// @returns void
// @description Draws Fibonacci retracement levels based on recent price action.
drawFibs() =>
if barstate.islast
var fibLine = array.new(14)
var fibLab = array.new(14)
if fibLine.size() > 0
for i = 0 to fibLine.size() - 1
fibLine .get(i).delete()
fibLab .get(i).delete()
if showFibs
getY2 = main.get_y2(), sub = main.get_y1() - getY2,
getX1 = main.get_x1(), getX2 = main.get_x2()
for i = 0 to fibLine.size() - 1
mod = i % fibLine.size() - 1
= switch mod
0 =>
1 =>
2 =>
3 =>
4 =>
5 =>
6 =>
7 =>
8 =>
9 =>
10 =>
11 =>
12 =>
13 =>
fibLine.set(i, quickLine (getX2, y, col))
// Combine text level and price
priceLabel = str.tostring(y, "#.#####")
combinedText = txt + " (" + priceLabel + ")" // Prix entre parenthèses
fibLab.set(i, quickLabel(y, combinedText, col))
drawFibs()
// @function drawStructureInternals
// @returns void
// @description Draws internal structures for smaller price swings based on user-defined settings.
drawStructureInternals() =>
if showInt
var keyValues = map.new()
if keyValues.size() == 0
keyValues.put("movingSmall", 0)
if smallUpper != 0
keyValues.put("upsideSmall", 1)
keyValues.put("upaxisSmall", smallUpper)
keyValues.put("upaxis2Small", bar_index - intSens)
if smallLower != 0
keyValues.put("downsideSmall", 1)
keyValues.put("dnaxisSmall", smallLower)
keyValues.put("dnaxis2Small", bar_index - intSens)
if ta.crossover(close, keyValues.get("upaxisSmall"))
if keyValues.get("upsideSmall") != 0
str = switch
keyValues.get("movingSmall") < 0 => intStru != "BoS" ? 'I-CHoCH' : ""
=> intStru != "CHoCH" ? 'I-BoS' : ""
if intStru == "All" or str.contains(str, intStru)
drawChar(keyValues.get("upaxis2Small"), keyValues.get("upaxisSmall"), str, bullC, true)
keyValues.put("upsideSmall", 0)
keyValues.put("movingSmall", 1)
if ta.crossunder(close, keyValues.get("dnaxisSmall"))
if keyValues.get("downsideSmall") != 0
str = switch
keyValues.get("movingSmall") > 0 => intStru != "BoS" ? 'I-CHoCH' : ""
=> intStru != "CHoCH" ? 'I-BoS' : ""
if intStru == "All" or str.contains(str, intStru)
drawChar(keyValues.get("dnaxis2Small"), keyValues.get("dnaxisSmall"), str, bearC, false)
keyValues.put("downsideSmall", 0)
keyValues.put("movingSmall", -1)
drawStructureInternals()
// @function drawAOE
// @returns void
// @description Draws the Premium and Discount Zones on the chart based on recent highs and lows.
drawAOE() =>
atr = ta.atr(14)
if showAOE
if closeArr.size() > 50
aoi = closeArr.slice(0, 50)
aoi2 = openArr .slice(0, 50)
maxaoiH = math.max(aoi.max(), aoi2.max())
minaoiL = math.min(aoi.min(), aoi2.min())
var aoeLevels = map.new()
if aoeLevels.size() == 0
aoeLevels.put("High",
box.new(bar_index , maxaoiH * 1.01, bar_index + 5, maxaoiH,
border_color = #00000000,
bgcolor = color.new(#F24968, 90),
text = "Premium Zone", //"Area of Interest" ,
text_size = size.normal,//.small,
text_color = color.new(#F24968, 33)
))
aoeLevels.put("Low",
box.new(bar_index , minaoiL, bar_index + 5, minaoiL * .99,
border_color = #00000000,
bgcolor = color.new(#14D990, 90),
text = "Discount Zone", //"Area of Interest" ,
text_size = size.normal,//size.small,
text_color = color.new(#14D990, 33)
))
getHighBox = aoeLevels.get("High")
if close <= getHighBox.get_top() * 1.01
getHighBox.set_lefttop (bar_index , maxaoiH + atr)
getHighBox.set_rightbottom (bar_index + 5, maxaoiH)
getHighBox.set_text ("Premium Zone") //"Area of Interest")
else
getHighBox.set_lefttop (bar_index + 5, maxaoiH + atr)
getHighBox.set_rightbottom (bar_index + 5, maxaoiH + atr)
getHighBox.set_text ("")
getLowBox = aoeLevels.get("Low")
if close >= getLowBox.get_bottom() * .99
getLowBox.set_lefttop (bar_index , minaoiL)
getLowBox.set_rightbottom (bar_index + 5, minaoiL - atr)
getLowBox.set_text ("Discount Zone") //"Area of Interest")
else
getLowBox.set_lefttop (bar_index + 5, minaoiL)
getLowBox.set_rightbottom (bar_index + 5, - atr)
getLowBox.set_text ("")
drawAOE()
var table tab2 = table.new(position.top_right, 13, 13, bgcolor = #20222C, border_color = #363843, frame_color = #363843, border_width = 1, frame_width = 1)
nyHour = hour (timenow, "America/New_York")
nyMinute = minute(timenow, "America/New_York")
// @function fvg
// @param direction Determines the direction for fair value gap (FVG) detection: positive for up, negative for down.
// @returns An array of FVG boxes in the specified direction.
// @description Identifies fair value gaps (FVGs) and stores them in an array of boxes for visual representation.
fvg(direction) =>
var fvgMat = matrix.new(5), var fvgDrawings = array.new()
fvgMat.add_col(0, array.from(math.sign(close - open), close, high, low, time))
if fvgMat.columns() > 3
fvgMat.remove_col(fvgMat.columns() - 1)
if fvgMat.row(0).sum() == direction
getDir = math.sign(direction)
= switch getDir
-1 =>
=>
col = switch closeOnly
true => #00000000
=> color.new(fvgcol, fvgtra)
fvgDrawings.push(
box.new(int(fvgMat.get(4, 1)),y, last_bar_time, y1, xloc = xloc.bar_time,
border_color = col, bgcolor = col)
)
fvgDrawings
if showFVG
fvgDn = fvg(-3)
fvgUp = fvg(3)
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getfvg = fvgDn.get(i)
if high >= getfvg.get_top()
getfvg.delete()
fvgDn.remove(i)
else if contract
if high > getfvg.get_bottom()
getfvg.set_bottom(high)
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getfvg = fvgUp.get(i)
if low <= getfvg.get_bottom()
getfvg.delete()
fvgUp.remove(i)
else if contract
if low < getfvg.get_top()
getfvg.set_top(low)
if closeOnly and barstate.islast
minDist = matrix.new(1, 2, 20e20)
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getBottom = fvgDn.get(i).get_bottom()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getBottom)))
if math.abs(close - getBottom) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgDn.get(i).set_right(fvgDn.get(i).get_left())
fvgDn.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_right(last_bar_time)
minDist.set(0, 0, 0)
minDist.set(0, 1, 20e20)
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getTop = fvgUp.get(i).get_top()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getTop)))
if math.abs(close - getTop) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgUp.get(i).set_right(fvgUp.get(i).get_left())
fvgUp.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_right(last_bar_time)
// @function calculateTimeDifference
// @param timestamp1 The starting timestamp for time difference calculation.
// @param timestamp2 The ending timestamp for time difference calculation.
// @returns A tuple containing hours and minutes as integers.
// @description Calculates the time difference between two timestamps, outputting hours and minutes.
//calculateTimeDifference(timestamp1, timestamp2) =>
// timeDifference = timestamp2 - timestamp1
// hours = math.floor(timeDifference / 3600000)
// minutes = math.floor((timeDifference % 3600000) / 60000)
//
//dayAdjustment = (hour(timenow, "America/New_York") < 2) ? dayofmonth(timenow) + 1 : dayofmonth(timenow)
//dayAdjustment2 = nyHour >= 20 or nyHour < 2 ? dayofmonth(timenow) + 1 : dayofmonth(timenow)
// @function timeIsInRange
// @param startHour The start hour of the time range.
// @param startMinute The start minute of the time range.
// @param endHour The end hour of the time range.
// @param endMinute The end minute of the time range.
// @returns Boolean indicating if the current time is within the specified range.
// @description Checks if the current time falls within a specified range based on New York timezone.
//timeIsInRange(startHour, startMinute, endHour, endMinute) =>
// (nyHour > startHour or (nyHour == startHour and nyMinute >= startMinute)) and (nyHour < endHour or (nyHour == endHour and nyMinute <= endMinute))
// = switch
// timeIsInRange(9, 30, 16, 0) =>
// timeIsInRange(20, 0, 2 , 0) =>
// timeIsInRange(3, 0, 11, 30) =>
// =>
// = calculateTimeDifference(timenow, timetilchange)
//timetilchange2 = switch
// timeIsInRange(9, 30, 16, 0) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 20, 0, 0)
// timeIsInRange(20, 0, 2 , 0) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 3, 0, 0)
// timeIsInRange(3, 0, 11, 30) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 9, 30, 0)
// => na
//if na(timetilchange2)
// timetilchange2 := switch
// nyHour < 9 or (nyHour == 9 and nyMinute < 30) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 9, 30, 0)
// nyHour < 20 or (nyHour >= 16 and nyHour < 20) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 20, 0, 0)
// nyHour < 3 or (nyHour >= 2 and nyHour < 3) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 3, 0, 0)
// => na
// = calculateTimeDifference(timenow, timetilchange2)
//method getActivity(array id, float id2) =>
// if id.size() > 0
// volPerc1 = id.percentile_nearest_rank(10)
// volPerc2 = id.percentile_nearest_rank(33)
// volPerc3 = id.percentile_nearest_rank(50)
// volPerc4 = id.percentile_nearest_rank(66)
// volPerc5 = id.percentile_nearest_rank(90)
// log.warning(str.tostring(volPerc1) + " " + str.tostring(volPerc2) + " " + str.tostring(volPerc3) + " " + str.tostring(volPerc4) + " " + str.tostring(volPerc5))
// activity = switch
// id2 <= volPerc1 => "Very Low"
// id2 <= volPerc2 => "Low"
// id2 <= volPerc3 => "Average"
// id2 <= volPerc4 => "High"
// => "Very High"
// activity
//if barstate.islast
// hr4Act = vol4hrArr.getActivity(vol4hr)
// D1Act = vol1DArr .getActivity(vol1D)
// str = str.tostring(timetilchange)
// ch = str.substring(str, str.pos(str, ".") + 1, str.length(str))
// nu = str.tonumber(ch) * 6
// nu2 = str.substring(str.tostring(nu), 0, 2)
// table.cell(tab2, 0, 2, text = "Session:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 3, text = "Session Close:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 4, text = "Next Session:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 5, text = "Next Session Open:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 6, text = "4-Hr Volume:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 7, text = "24-Hr Volume:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 1, 2, text = stringCol , text_color = color.white)
// table.cell(tab2, 1, 3, text = stringCol != "Dead Zone" ? str.tostring(hours)+ "h" + str.tostring(minutes) + "m": "Dead Zone", text_color = color.white)
// table.cell(tab2, 1, 4, text =stringCol2, text_color = color.white)
// table.cell(tab2, 1, 5, text = str.tostring(hours2) + "h:" + str.tostring(minutes2) + "m", text_color = color.white)
// table.cell(tab2, 1, 6, text = hr4Act, text_color = color.white)
// table.cell(tab2, 1, 7, text = D1Act, text_color = color.white)
nyHour2 = hour (time, "America/New_York")
nyMinute2 = minute(time, "America/New_York")
// @function timeIsInRange2
// @param startHour The starting hour for checking the time range.
// @param startMinute The starting minute within the hour.
// @param endHour The ending hour for checking the time range.
// @param endMinute The ending minute within the hour.
// @returns Boolean indicating if the current time is within the specified range.
// @description Checks if the current chart time falls within a specified time range.
timeIsInRange2(startHour, startMinute, endHour, endMinute) =>
if endHour >= startHour
(nyHour2 > startHour or (nyHour2 == startHour and nyMinute2 >= startMinute)) and
(nyHour2 < endHour or (nyHour2 == endHour and nyMinute2 <= endMinute))
else
(nyHour2 > startHour or (nyHour2 == startHour and nyMinute2 >= startMinute)) or
(nyHour2 < endHour or (nyHour2 == endHour and nyMinute2 <= endMinute))
nyCol = input.color(defval = #f24968, title = "NY Color")
asCol = input.color(defval = #14D990, title = "Asia Color")
loCol = input.color(defval = #F2B807, title = "London Color")
tra = input.int(defval = 98, minval = 0, maxval = 100, title = "Transparency")
bgcolor(timeIsInRange2(9, 30, 16, 0) ? color.new(nyCol, tra) : na)
bgcolor(timeIsInRange2(20, 0, 2 , 0) ? color.new(asCol, tra) : na)
bgcolor(timeIsInRange2(3, 0, 11, 30) ? color.new(loCol, tra) : na)
//---------------------------------------Entry/Exit-------------------------------------------------------
// "Entry/Exit signal"
Entry_exit_ena = input.bool(defval = true, title = "Entry/Exit Signal" ,group = "Entry/exit Signal")
a = input.float(1.5, title="Key Value. 'This changes the sensitivity'", group = "Entry/exit Signal")
c = input.int(7, title="ATR Period", group = "Entry/exit Signal")
ma_length = input.int(50, minval=1, title="Période de la Moyenne Mobile", group = "Entry/exit Signal")
Trail_Stop_ENA = input.bool(defval = true, title = "Trail Stop" ,group = "Entry/exit Signal")
Trail_stop_col = input.color(title = "Trailing stop color", defval = color.yellow, group = "Entry/exit Signal")
//if Entry_exit_ena
// Paramètres de la Moyenne Mobile (Filtre de Tendance)
// Calculs de base
xATR = ta.atr(c)
nLoss = a * xATR
src = close
// Calcul de l'UT BOT Trailing Stop
var float xATRTrailingStop = 0.0
xATRTrailingStop := if src > nz(xATRTrailingStop ) and src > nz(xATRTrailingStop )
math.max(nz(xATRTrailingStop ), src - nLoss)
else if src < nz(xATRTrailingStop ) and src < nz(xATRTrailingStop )
math.min(nz(xATRTrailingStop ), src + nLoss)
else if src > nz(xATRTrailingStop )
src - nLoss
else
src + nLoss
// Calcul de la Moyenne Mobile
ma = ta.ema(close, ma_length)
// Condition de tendance
is_uptrend = close > ma
is_downtrend = close < ma
// Signaux d'achat et de vente selon le trend
buy = ta.crossover(src, xATRTrailingStop) and is_uptrend
sell = ta.crossunder(src, xATRTrailingStop) and is_downtrend
// Tracé de l'UT BOT Trailing Stop
plot(Trail_Stop_ENA ? xATRTrailingStop : na, color=buy ? color.green : sell ? color.red : Trail_stop_col, linewidth=2, title="Trailing Stop Style")
// Indication des signaux sur le graphique
if buy and Entry_exit_ena
label.new(bar_index, low, text='Buy', style=label.style_label_up, yloc=yloc.belowbar ,color=color.green, textcolor=color.white, size=size.small)
if sell and Entry_exit_ena
label.new(bar_index, high, text='Sell', style=label.style_label_down, yloc=yloc.abovebar, color=color.red, textcolor=color.white, size=size.small)
alertcondition(buy, "Buy/Long", "Buy Long")
alertcondition(sell, "Sell/Short", "Sell/Short")
// ----------------------------------------Trend table-----------------------------------------------
// Paramètres utilisateur
afficher_tableau = input.bool(true, "Afficher le tableau", group="Trend Table")
periode_ema = input.int(200, minval=1, title="Période EMA pour les tendances", group="Trend Table")
periode_ema_btc = input.int(200, minval=1, title="Période EMA pour la tendance BTC", group="Trend Table")
// Configuration des périodes de tendance avec un menu déroulant lisible
periode1 = input.string("15m", "Période de tendance 1", options= , group="Trend Table")
periode2 = input.string("1h", "Période de tendance 2", options= , group="Trend Table")
periode3 = input.string("4h", "Période de tendance 3", options= , group="Trend Table")
periode4 = input.string("Day", "Période de tendance 4", options= , group="Trend Table")
// Période de tendance pour le BTC
btc_periode_tendance = input.string("4h", "Période de tendance BTC", options= , group="Trend Table")
// Couleurs pour les tendances
color_haussier = color.green
color_baissier = color.red
// Couleurs de fond alternées pour les lignes (définies globalement)
bg_color_odd = color.new(color.gray, 90) // Gris très clair pour les lignes impaires
bg_color_even = color.new(color.gray, 70) // Gris clair pour les lignes paires
// Fonction de mapping des périodes lisibles en valeurs temporelles standard
f_mapper_periode(timeframe_lisible) =>
switch timeframe_lisible
"5m" => "5"
"15m" => "15"
"1h" => "60"
"4h" => "240"
"8h" => "480"
"12h" => "720"
"Day" => "D"
=> timeframe_lisible // Cas par défaut si aucune correspondance n'est trouvée
// Mapper les périodes sélectionnées
periode1_mapped = f_mapper_periode(periode1)
periode2_mapped = f_mapper_periode(periode2)
periode3_mapped = f_mapper_periode(periode3)
periode4_mapped = f_mapper_periode(periode4)
btc_periode_tendance_mapped = f_mapper_periode(btc_periode_tendance)
// Fonction pour déterminer la session actuelle en utilisant l'heure du graphique (UTC-5)
f_session_actuelle() =>
heure = hour(time)
minute_ = minute(time)
heure_mod = heure * 60 + minute_
sessions_actives = ""
// Définir les plages horaires des sessions en UTC-5
// Session Asie (19:00 - 04:00)
if (heure_mod >= (19 * 60) or heure_mod < (4 * 60))
sessions_actives := sessions_actives + "Asie, "
// Session Londres (03:00 - 12:00)
if (heure_mod >= (3 * 60) and heure_mod < (12 * 60))
sessions_actives := sessions_actives + "Londres, "
// Session New York (08:00 - 17:00)
if (heure_mod >= (8 * 60) and heure_mod < (17 * 60))
sessions_actives := sessions_actives + "NY, "
// Nettoyer la chaîne de caractères pour enlever la virgule finale
if (str.endswith(sessions_actives, ", "))
sessions_actives := str.substring(sessions_actives, 0, str.length(sessions_actives) - 2)
// Si aucune session n'est active
sessions_actives := sessions_actives == "" ? "Hors session" : sessions_actives
sessions_actives
session_actuelle = f_session_actuelle()
// Fonction pour calculer la tendance basée sur l'EMA sans lookahead
f_tendance(symbole, timeframe_tendance, periode_ema) =>
= request.security(symbole, timeframe_tendance, , barmerge.gaps_off, barmerge.lookahead_off)
tendance = cours > ema_valeur ? "Haussier" : "Baissier"
tendance
// Calcul de la tendance du BTC
tendance_btc = f_tendance("BINANCE:BTCUSDT", btc_periode_tendance_mapped, periode_ema_btc)
// Calcul des tendances pour les périodes spécifiées
tendance_periode1 = f_tendance(syminfo.tickerid, periode1_mapped, periode_ema)
tendance_periode2 = f_tendance(syminfo.tickerid, periode2_mapped, periode_ema)
tendance_periode3 = f_tendance(syminfo.tickerid, periode3_mapped, periode_ema)
tendance_periode4 = f_tendance(syminfo.tickerid, periode4_mapped, periode_ema)
// Fonction pour obtenir le nom du ticker actuel
f_ticker_actuel() =>
syminfo.ticker
// Obtenir le ticker actuel
ticker_actuel = f_ticker_actuel()
// Affichage du tableau
if afficher_tableau
// Création du tableau
var table mon_tableau = table.new(position=position.top_right, columns=2, rows=7, bgcolor=color.new(color.black, 0), frame_color=color.new(color.gray, 0), frame_width=1)
if barstate.isfirst
// Première colonne (libellés)
table.cell(table_id=mon_tableau, row=0, column=0, text="Session actuelle:", text_color=color.white, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=1, column=0, text="Tendance:", text_color=color.white, bgcolor=bg_color_odd, text_halign=text.align_right)
table.cell(table_id=mon_tableau, row=6, column=0, text="BTC (" + btc_periode_tendance + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=2, column=0, text= ticker_actuel + " (" + periode1 + "):", text_color=color.white, bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=3, column=0, text="(" + periode2 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=4, column=0, text="(" + periode3 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=5, column=0, text="(" + periode4 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
// Définir les couleurs de fond pour les cellules de tendance
trend_btc_color = tendance_btc == "Haussier" ? color.green : color.red
trend_periode1_color = tendance_periode1 == "Haussier" ? color.green : color.red
trend_periode2_color = tendance_periode2 == "Haussier" ? color.green : color.red
trend_periode3_color = tendance_periode3 == "Haussier" ? color.green : color.red
trend_periode4_color = tendance_periode4 == "Haussier" ? color.green : color.red
// Mise à jour des valeurs avec les couleurs appropriées
table.cell(table_id=mon_tableau, row=0, column=1, text=session_actuelle, text_color=color.yellow, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=1, column=1, text="", bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=6, column=1, text=tendance_btc, text_color=color.white, bgcolor=trend_btc_color)
table.cell(table_id=mon_tableau, row=2, column=1, text=tendance_periode1, text_color=color.white, bgcolor=trend_periode1_color)
table.cell(table_id=mon_tableau, row=3, column=1, text=tendance_periode2, text_color=color.white, bgcolor=trend_periode2_color)
table.cell(table_id=mon_tableau, row=4, column=1, text=tendance_periode3, text_color=color.white, bgcolor=trend_periode3_color)
table.cell(table_id=mon_tableau, row=5, column=1, text=tendance_periode4, text_color=color.white, bgcolor=trend_periode4_color)
// Optionnel : Ajouter une étiquette de débogage pour vérifier la session actuelle
// label.new(bar_index, high, text="Session: " + session_actuelle, style=label.style_label_down, color=color.blue, textcolor=color.white, size=size.small, yloc=yloc.abovebar)
PHAI GIAU NHAT VN)
positive and negative are recreated each bar using nz(... ) to keep the old value if no new signal is present.
The line p_mom ? true : nz(positive , false) ensures the variable keeps the correct state across bars.
Clearly displays "UP" and "DOWN" signals.
Horizontal Lines from ArrayMy Love
//@version=5
indicator("Horizontal Lines from Array", overlay=true)
// Mảng chứa các mức giá cần vẽ đường ngang
// Nhập chuỗi giá cách nhau bằng dấu phẩy
input_str = input.string("3380,3370", "Mức giá (phẩy giữa các giá)")
// Hàm tách chuỗi thành mảng (tối đa 10 phần tử)
split_str_to_float_array(str) =>
str_array = str.split(str, ",")
result = array.new_float()
for i = 0 to array.size(str_array) - 1
s = array.get(str_array, i)
f = str.tonumber(s)
if not na(f)
array.push(result, f)
result
levels = split_str_to_float_array(input_str)
// Lặp và vẽ các đường ngang
for i = 0 to array.size(levels) - 1
y = array.get(levels, i)
line.new( x1 = bar_index,y1 = y, x2 = bar_index + 1,y2 = y,color = color.blue,style = line.style_dashed,width = 1,extend=extend.both)
RSI + MACD AL SinyaliIt creates a buy signal using RSI and MACD in the daily watch list. Signals give better results on the daily.
Nirvana Mode PRO v2//@version=5
strategy("Nirvana Mode PRO v2", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_every_tick=true)
// === İndikator ===
emaFast = ta.ema(close, 8)
emaSlow = ta.ema(close, 21)
rsi = ta.rsi(close, 14)
= ta.supertrend(2.0, 10)
volAvg = ta.sma(volume, 10)
volSpike = volume > volAvg * 1.5
ORB Breakout Indicator// @version=5
indicator("ORB Breakout Indicator", overlay=true)
// Input parameters
range_minutes = input.int(15, "Opening Range Period (minutes)", minval=1)
session_start = input.string("0930-0945", "Session Time", options= )
threshold_percent = input.float(0.1, "Breakout Threshold (% of Range)", minval=0.05, step=0.05)
use_trend_filter = input.bool(true, "Use EMA Trend Filter")
use_volume_filter = input.bool(true, "Use Volume Filter")
volume_lookback = input.int(20, "Volume Lookback Period", minval=5)
// Session logic
is_in_session = time(timeframe.period, session_start + ":" + str.tostring(range_minutes))
is_first_bar = ta.change(is_in_session) and is_in_session
// Calculate opening range
var float range_high = 0.0
var float range_low = 0.0
var bool range_set = false
if is_first_bar
range_high := high
range_low := low
range_set := true
else if is_in_session and range_set
range_high := math.max(range_high, high)
range_low := math.min(range_low, low)
// Plot range lines after session ends
plot(range_set and not is_in_session ? range_high : na, "Range High", color=color.green, linewidth=2)
plot(range_set and not is_in_session ? range_low : na, "Range Low", color=color.red, linewidth=2)
// Trend filter (50/200 EMA)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
bull_trend = ema50 > ema200
bear_trend = ema50 < ema200
// Volume filter
avg_volume = ta.sma(volume, volume_lookback)
high_volume = volume > avg_volume
// Breakout detection (signal 1 minute before close)
range_width = range_high - range_low
threshold = range_width * (threshold_percent / 100)
buy_condition = close > range_high - threshold and close < range_high and high_volume
sell_condition = close < range_low + threshold and close > range_low and high_volume
// Apply trend filter if enabled
buy_signal = buy_condition and (not use_trend_filter or bull_trend)
sell_signal = sell_condition and (not use_trend_filter or bear_trend)
// Plot signals
if buy_signal
label.new(bar_index, high, "BUY", color=color.green, style=label.style_label_down, textcolor=color.white)
if sell_signal
label.new(bar_index, low, "SELL", color=color.red, style=label.style_label_up, textcolor=color.white)
// Alerts
alertcondition(buy_signal, title="ORB Buy Signal", message="ORB Buy Signal on {{ticker}} at {{close}}")
alertcondition(sell_signal, title="ORB Sell Signal", message="ORB Sell Signal on {{ticker}} at {{close}}")
CryptoQuebec Suite// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// Crypto Quebec & StefB.
//@version=6
indicator("CryptoQuebec Suite", overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, max_bars_back = 500)
//strategy("UT BOT Amélioré pour le Day Trading Crypto", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Version 2.0 order block ajustable colors
// Version 2.1 draw swing High/low
// Version 2.2 Changed the wording of "Area of interest" for "Premium Zone" and "Discount Zone"
// Version 2.3 Added the price to the auto fib levels.
// Version 2.4 Correction. Added 3 digits after the dot of the auto fib. This was lost when the price has been added.
// Version 2.4.01 Added few fib levels. (0, -0.272, -0.414, -0.618).
// Version 2.4.02 Added few fib levels. (1, 1.272, 1.414, 1.618).
// Version 2.4.03 Made a small change in the label of 240L, 240H, DL and DH. Change 240 for 4h and H/L for Lo/Hi
// Version 2.4.04 Added digits after the dot for more price precision into the Fib levels.
// Version 2.4.05 Added Entry long/short indicator base on EMA. Also added the trailing stop line.
// Version 2.4.06 Added Trail Stop enable/disable option. Moved the Buy/Sell label farther from the candles.
// Version 2.4.07 Added Trend info table with active trading session
// Version 2.4.08 Small adjustment in the trend table and FIB lines more visible.
// Version 2.4.09 Changed the indicator name for CryptoQuebe Suite.
//---------------------------------------------------------------------------------------------------------------------
//CONSTANTS & STRINGS & INPUTS
//---------------------------------------------------------------------------------------------------------------------
BULLISH = +1
BEARISH = -1
showHighLowSwingsTooltip = 'Highlight most recent strong and weak high/low points on the chart'
bullC = input.color(defval = #14D990, title = "Bull Color", group = "Smart Money Concepts", inline = "7")
bearC = input.color(defval = #F24968, title = "Bear Color", group = "Smart Money Concepts", inline = "7")
showInt = input.bool(defval = true, title = "Show Internals", group = "Smart Money Concepts")
intSens = input.int(3, "Internals Sensitivity", options = , group = "Smart Money Concepts", inline = "20")
intStru = input.string(defval = "All", title = "Internal Structure", options = , inline = "30", group = "Smart Money Concepts")
showExt = input.bool(defval = true, title = "Show Externals" ,group = "Smart Money Concepts")
extSens = input.int(25, "Externals Sensitivity", options = ,group = "Smart Money Concepts", inline = "21")
extStru = input.string(defval = "All", title = "External Structure", options = , inline = "31", group = "Smart Money Concepts")
showOB = input.bool(defval = true, title = "Show Order Blocks" ,group = "Swing Blocks")
//----------------------------------------------
//showHighLowSwingsInput = input(true, 'Show Strong/Weak High/Low', group = "Smart Money Concepts", tooltip = showHighLowSwingsTooltip)
BullOBColor = input.color(color.new(#3179f5, 80), 'Internal Bullish OB',group = "Swing Blocks")
BearOBColor = input.color(color.new(#f77c80, 80), 'Internal Bearish OB',group = "Swing Blocks")
//---------------------------------------------------------------------------
showLast = input.int(defval = 10, title = "Swing Order Blocks", minval = 0, group = "Swing Blocks")
showHHLH = input.bool(defval = true, title = "Show HH/LH", group = "Swing Blocks")
showHLLL = input.bool(defval = true, title = "Show LH/LL", group = "Swing Blocks")
showAOE = input.bool(defval = true, title = "Show Premium/Discount", group = "Swing Blocks")
//showAOE = input.bool(defval = true, title = "Show Area of Interest", group = "Swing Blocks")
show1D = input.bool(defval = true, title = "Show Previous Day High", group = "High/Low")
show1DLab = input.bool(defval = true, title = "Show 1 Day Labels", group = "High/Low")
show4H = input.bool(defval = true, title = "Show 4 Hour High", group = "High/Low")
show4hLab = input.bool(defval = true, title = "Show 4 Hour Labels", group = "High/Low")
showFVG = input.bool(defval = true, title = "Show Fair Value Gaps", group = "FVG")
contract = input.bool(defval = false, title = "Contract Violated FVG", group = "FVG")
closeOnly = input.bool(defval = false, title = "Show Closest Up/Down FVG Only", group = "FVG")
fvgcol = input.color(defval = #F2B807, title = "FVG Color", group = "FVG")
fvgtra = input.int(defval = 80, minval = 0, maxval = 100, title = "FVG Transparency", group = "FVG")
showFibs = input.bool(defval = true, title = "Show Auto Fibs", group = "Auto Fibs")
// extSensFibs = input.int(25, "Fibs Sensitivity", options = , group = "Auto Fibs", inline = "22")
show0_618 = input.bool(defval = true, title = "", inline = "1", group = "Auto Fibs")
show0_414 = input.bool(defval = true, title = "", inline = "2", group = "Auto Fibs")
show0_272 = input.bool(defval = true, title = "", inline = "3", group = "Auto Fibs")
show0 = input.bool(defval = true, title = "", inline = "4", group = "Auto Fibs")
show236 = input.bool(defval = true, title = "", inline = "5", group = "Auto Fibs")
show382 = input.bool(defval = true, title = "", inline = "6", group = "Auto Fibs")
show5 = input.bool(defval = true, title = "", inline = "7", group = "Auto Fibs")
show618 = input.bool(defval = true, title = "", inline = "8", group = "Auto Fibs")
show65 = input.bool(defval = true, title = "", inline = "9", group = "Auto Fibs")
show786 = input.bool(defval = true, title = "", inline = "10", group = "Auto Fibs")
show1 = input.bool(defval = true, title = "", inline = "11", group = "Auto Fibs")
show1_272 = input.bool(defval = true, title = "", inline = "12", group = "Auto Fibs")
show1_414 = input.bool(defval = true, title = "", inline = "13", group = "Auto Fibs")
show1_618 = input.bool(defval = true, title = "", inline = "14", group = "Auto Fibs")
fib1 = input.float(defval = -0.618, title = "", minval = -0.618, step = 0.01, inline = "1", group = "Auto Fibs")
fib2 = input.float(defval = -0.414, title = "", minval = -0.618, step = 0.01, inline = "2", group = "Auto Fibs")
fib3 = input.float(defval = -0.272, title = "", minval = -0.618, step = 0.01, inline = "3", group = "Auto Fibs")
fib4 = input.float(defval = 0, title = "", minval = 0, step = 0.01, inline = "4", group = "Auto Fibs")
fib5 = input.float(defval = .236, title = "", minval = 0, step = 0.01, inline = "5", group = "Auto Fibs")
fib6 = input.float(defval = .382, title = "", minval = 0, step = 0.01, inline = "6", group = "Auto Fibs")
fib7 = input.float(defval = .5, title = "", minval = 0, step = 0.01, inline = "7", group = "Auto Fibs")
fib8 = input.float(defval = .618, title = "", minval = 0, step = 0.01, inline = "8", group = "Auto Fibs")
fib9 = input.float(defval = .65, title = "", minval = 0, step = 0.01, inline = "9", group = "Auto Fibs")
fib10 = input.float(defval = .786, title = "", minval = 0, step = 0.01, inline = "10", group = "Auto Fibs")
fib11 = input.float(defval = 1, title = "", minval = 0, step = 0.01, inline = "11", group = "Auto Fibs")
fib12 = input.float(defval = 1.272, title = "", minval = 0, step = 0.01, inline = "12", group = "Auto Fibs")
fib13 = input.float(defval = 1.414, title = "", minval = 0, step = 0.01, inline = "13", group = "Auto Fibs")
fib14 = input.float(defval = 1.618, title = "", minval = 0, step = 0.01, inline = "14", group = "Auto Fibs")
fib1col = input.color(title = "", defval = color.orange, inline = "1", group = "Auto Fibs")
fib2col = input.color(title = "", defval = color.orange, inline = "2", group = "Auto Fibs")
fib3col = input.color(title = "", defval = color.orange, inline = "3", group = "Auto Fibs")
fib4col = input.color(title = "", defval = color.gray, inline = "4", group = "Auto Fibs")
fib5col = input.color(title = "", defval = color.white, inline = "5", group = "Auto Fibs")
fib6col = input.color(title = "", defval = color.white, inline = "6", group = "Auto Fibs")
fib7col = input.color(title = "", defval = color.red, inline = "7", group = "Auto Fibs")
fib8col = input.color(title = "", defval = color.green, inline = "8", group = "Auto Fibs")
fib9col = input.color(title = "", defval = color.green, inline = "9", group = "Auto Fibs")
fib10col = input.color(title = "", defval = color.white, inline = "10", group = "Auto Fibs")
fib11col = input.color(title = "", defval = color.gray, inline = "11", group = "Auto Fibs")
fib12col = input.color(title = "", defval = color.orange, inline = "12", group = "Auto Fibs")
fib13col = input.color(title = "", defval = color.orange, inline = "13", group = "Auto Fibs")
fib14col = input.color(title = "", defval = color.orange, inline = "14", group = "Auto Fibs")
//---------------------------------------------------------------------------------------------------------------------
//DATA STRUCTURES & VARIABLES
//---------------------------------------------------------------------------------------------------------------------
// @type UDT representing last swing extremes (top & bottom)
// @field top last top swing price
// @field bottom last bottom swing price
// @field barTime last swing bar time
// @field barIndex last swing bar index
// @field lastTopTime last top swing time
// @field lastBottomTime last bottom swing time
type trailingExtremes
float top
float bottom
int barTime
int barIndex
int lastTopTime
int lastBottomTime
// @type UDT representing trend bias
// @field bias BULLISH or BEARISH
type trend
int bias
var bigData = map.new()
// @variable swing trend bias
var trend swingTrend = trend.new(0)
// @variable last trailing swing high and low
var trailingExtremes trailing = trailingExtremes.new()
// @variable color for swing bullish structures
var swingBullishColor = color.green //styleInput == MONOCHROME ? MONO_BULLISH : swingBullColorInput
// @variable color for swing bearish structures
var swingBearishColor = color.red //styleInput == MONOCHROME ? MONO_BEARISH : swingBearColorInput
if bigData.size() == 0
bigData.put("moving", 0)
bigData.put("upaxis", 0.0)
bigData.put("upaxis2", 0)
bigData.put("dnaxis", 0.0)
bigData.put("dnaxis2", 0)
bigData.put("upside", 1)
bigData.put("downside", 1)
= request.security(syminfo.tickerid, "1D", [high , low , high, low, time , time])
var highArr = array.new_float(), var lowArr = array.new_float()
var timeArr = array.new_int (), var volArr = array.new_float()
var closeArr = array.new_float(), var openArr = array.new_float()
highArr.unshift(high), lowArr.unshift(low)
timeArr.unshift(time), volArr.unshift(volume)
closeArr.unshift(close), openArr.unshift(open)
type rollingTF
float highTF = 0
float lowTF = 1e8
int highTFt = 0
int lowTFt = 0
float volTF = 0
map rTFdraw
map rTFlabel
// Convert time period in text
f_convert_tf_to_text(tf) =>
tf == "240" ? "H4" : tf == "1D" ? "D" : tf == "60" ? "1h" : tf == "15" ? "15m" : tf
// Create the labels fo each level
offset = 10 // Ajustez cette valeur selon le décalage souhaité
// Ajust the label position in case of overide
f_adjust_label_position(x, offset) =>
x + offset
// @function tfDraw
// @param tfDiff Specifies the timeframe difference for the high/low calculations.
// @param showRollingLab Indicates whether to display rolling labels for timeframes.
// @param tf Specifies the timeframe as a string.
// @param showLevels Determines if the high/low levels for the timeframe should be shown.
// @returns A tuple with the total volume (TFhrdata.volTF) and the rolling volume array (volRolling).
method tfDraw(int tfDiff, bool showRollingLab, string tf, bool showLevels) =>
TFhrdata = rollingTF.new(), var volRolling = array.new()
if highArr.size() > tfDiff
for i = 0 to tfDiff
if showLevels and barstate.islast
getHigh = highArr.get(i), getLow = lowArr.get(i),
getTime = timeArr.get(i)
TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh)
TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow )
if TFhrdata.highTF == getHigh
TFhrdata.highTFt := timeArr.get(i)
if TFhrdata.lowTF == getLow
TFhrdata.lowTFt := timeArr.get(i)
TFhrdata.volTF += volArr.get(i)
volRolling.push(TFhrdata.volTF)
var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new())
if showLevels
switch lineDraw.rTFdraw.size() == 0
true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF,
xloc = xloc.bar_time, color = color.aqua)),
lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF ,
xloc = xloc.bar_time, color = color.aqua))
=> lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF),
lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF),
lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF),
lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF)
if showRollingLab
switch lineDraw.rTFlabel.size() == 0
true => lineDraw.rTFlabel.put("High", label.new(f_adjust_label_position(bar_index, offset), TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Hi", style = label.style_label_left, size = size.normal, color = #00000000)),
lineDraw.rTFlabel.put("Low", label.new(f_adjust_label_position(bar_index, offset), TFhrdata.lowTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Lo", style = label.style_label_left, size = size.normal, color = #00000000))
=> lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF),
lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF)
// @function tfDrawLower
// @param showRollingLab Indicates whether to display rolling labels for lower timeframes.
// @param tf Specifies the lower timeframe as a string.
// @param showLevels Determines if the high/low levels for the lower timeframe should be shown.
// @returns (volume and volume array)
tfDrawLower(bool showRollingLab, simple string tf, bool showLevels) =>
simple int end = switch tf
"240" => 240
"1D" => 1440
= request.security_lower_tf(syminfo.tickerid, "1", )
var oArr = array.new_float()
var hArr = array.new_float()
var lArr = array.new_float()
var cArr = array.new_float()
var vArr = array.new_float()
var tArr = array.new_int()
TFhrdata = rollingTF.new(), var volRolling = array.new()
if h.size() > 0
for i = 0 to h.size() - 1
oArr.push(o.get(i))
hArr.push(h.get(i))
lArr.push(l.get(i))
cArr.push(c.get(i))
vArr.push(v.get(i))
tArr.push(t.get(i))
if hArr.size() > end
oArr.shift()
hArr.shift()
lArr.shift()
cArr.shift()
vArr.shift()
tArr.shift()
for i = 0 to hArr.size() - 1
if showLevels
getHigh = hArr.get(i), getLow = lArr.get(i),
getTime = tArr.get(i)
TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh)
TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow)
if TFhrdata.highTF == getHigh
TFhrdata.highTFt := tArr.get(i)
if TFhrdata.lowTF == getLow
TFhrdata.lowTFt := tArr.get(i)
TFhrdata.volTF += vArr.get(i)
volRolling.push(TFhrdata.volTF)
var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new())
if showLevels
switch lineDraw.rTFdraw.size() == 0
true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF,
xloc = xloc.bar_time, color = color.aqua)),
lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF ,
xloc = xloc.bar_time, color = color.aqua))
=> lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF),
lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF),
lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF),
lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF)
if showRollingLab
switch lineDraw.rTFlabel.size() == 0
true => lineDraw.rTFlabel.put("High", label.new(f_adjust_label_position(bar_index, 0), TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Hi", style = label.style_label_left, size = size.normal, color = #00000000)),
lineDraw.rTFlabel.put("Low" , label.new(f_adjust_label_position(bar_index, 0), TFhrdata.lowTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Lo", style = label.style_label_left, size = size.normal, color = #00000000))
=> lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF),
lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF)
var r4hrbars = math.floor(timeframe.in_seconds("240") / timeframe.in_seconds(timeframe.period))
var rDbars = math.floor(timeframe.in_seconds("1D") / timeframe.in_seconds(timeframe.period))
= switch
timeframe.in_seconds() <= 60 => r4hrbars.tfDraw(show4hLab, "240", show4H)
=> tfDrawLower(show4hLab, "240", show4H)
= switch
timeframe.in_seconds() <= 60 => rDbars.tfDraw(show1DLab, "1D", show1D)
=> tfDrawLower(show1DLab, "1D", show1D)
// @function calculatePivots
// @param length Specifies the lookback length for high/low pivot calculations.
// @returns A tuple with top and bottom swing values.
calculatePivots(length)=>
var int intraCalc = 0
if bar_index > length + 1
up = highArr.slice(0, length).max()
dn = lowArr .slice(0, length).min()
cHi = highArr.get(length)
cLo = lowArr .get(length)
intraCalc := switch
cHi > up => 0
cLo < dn => 1
=> intraCalc
topSwing = switch
intraCalc == 0 and intraCalc != 0 => cHi
=> 0
botSwing = switch
intraCalc == 1 and intraCalc != 1 => cLo
=> 0
= calculatePivots(extSens)
= calculatePivots(intSens)
var label upLabel = array.new_label(1)
var label dnLabel = array.new_label(1)
var box highBlock = array.new_box()
var box lowBlock = array.new_box()
drawChar(x, y, str, col, down) =>
style = switch down
true => label.style_label_down
=> label.style_label_up
line.new (int(x), y, bar_index, y, color = col, style = line.style_dashed)
label.new(math.round(math.avg(x, bar_index)), y, str, color = #00000000, textcolor = col, style = style, size = size.small)
// @function drawStructureExt
// @returns Counter indicating the structure direction: 1 for bullish, -1 for bearish, 0 for neutral.
drawStructureExt() =>
var int counter = 0
if bigUpper != 0
bigData.put("upside", 1)
x1 = bar_index - extSens
txt = switch bigUpper > bigData.get("upaxis")
true => 'HH'
=> 'LH'
if showHHLH
upLabel.set(0, label.new(x1, bigUpper, txt,
color = color.new(color.white, 100),
textcolor = bearC,
style = label.style_label_down,
size = size.small
))
if showOB
highBlock.push(box.new(x1, bigUpper, last_bar_index + 5, bigUpper * .998, border_color = BearOBColor, bgcolor = BearOBColor))
bigData.put("upaxis" , bigUpper)
bigData.put("upaxis2", x1)
counter := 1
if bigLower != 0
bigData.put("downside", 1)
x1 = bar_index - extSens
txt = switch bigLower < bigData.get("dnaxis")
true => "LL"
=> "HL"
if showHLLL == true
dnLabel.set(0, label.new(x1, bigLower, txt, color = #ffffff00,
textcolor = bullC,
style = label.style_label_up,
size = size.small
))
if showOB
lowBlock.push(box.new(x1, bigLower, last_bar_index + 5, bigLower * 1.002, border_color = BullOBColor, bgcolor = BullOBColor))
//border_color = color.new(color.blue, 60),//75),
//bgcolor = color.new(color.blue, 70)//95)
//))
bigData.put("dnaxis" , bigLower)
bigData.put("dnaxis2", x1)
counter := -1
if showExt
if ta.crossover(close, bigData.get("upaxis"))
if bigData.get("upside") != 0
str = switch bigData.get("moving") < 0
true => extStru != "BoS" ? 'CHoCH' : ""
=> extStru != 'CHoCH' ? 'BoS' : ""
if extStru == "All" or str.contains(extStru, str)
drawChar(bigData.get("upaxis2"), bigData.get("upaxis"), str, bullC, true)
bigData.put("upside", 0)
bigData.put("moving", 1)
if ta.crossunder(close, bigData.get("dnaxis"))
if bigData.get("downside") != 0
str = switch bigData.get("moving") > 0
true => extStru != "BoS" ? 'CHoCH' : ""
=> extStru != 'CHoCH' ? 'BoS' : ""
if extStru == "All" or str.contains(extStru, str)
drawChar(bigData.get("dnaxis2"), bigData.get("dnaxis"), str, bearC, false)
bigData.put("downside", 0)
bigData.put("moving", -1)
counter
counter = drawStructureExt()
// @function updateBox
// @param id Array of boxes to update based on the bar index.
// @returns void
method updateBox(array id) =>
if id.size() > 0
for i = 0 to id.size() - 1
id.get(i).set_right(last_bar_index + 5)
method cleanseLevel(array id, bool isHighBlock) =>
if id.size() > 0
for i = id.size() - 1 to 0
condition = switch isHighBlock
true => close >= id.get(i).get_top()
=> close <= id.get(i).get_bottom()
if condition
id.remove(i).delete()
if id.size() > showLast and showLast != 0
for i = id.size() - showLast to 0
id.remove(i).delete()
highBlock.cleanseLevel(true)
lowBlock .cleanseLevel(false)
if barstate.islast
highBlock.updateBox()
lowBlock .updateBox()
// @function updateMain
// @param id Line object for updating based on price structure pivots.
// @returns void
// @description Updates the main line indicator to match the latest high/low price levels.
method updateMain(line id) =>
hi = 0.0
lo = 1e8
if showFibs
= calculatePivots(25)
var int counterFibs = 0
if bigUpperFibs != 0
counterFibs := 1
if bigLowerFibs != 0
counterFibs := -1
if counterFibs == 1
hi := 0.0
id.set_xy1(int(bigData.get("upaxis2")), bigData.get("upaxis"))
for i = 0 to bar_index - int(bigData.get("dnaxis2"))
getLow = lowArr.get(i)
lo := math.min(getLow, lo)
if lo == getLow
id.set_xy2(bar_index - i, lo)
else if counterFibs == -1
lo := 1e8
id.set_xy1(int(bigData.get("dnaxis2")), bigData.get("dnaxis"))
for i = 0 to bar_index - bigData.get("upaxis2")
getHigh = highArr.get(i)
hi := math.max(highArr.get(i), hi)
if hi == getHigh
id.set_xy2(bar_index - i, hi)
if id.get_x2() < id.get_x1()
x2 = id.get_x2(), x1 = id.get_x1()
y2 = id.get_y2(), y1 = id.get_y1(),
id.set_xy2(x1, y1),
id.set_xy1(x2, y2)
switch id.get_y2() < id.get_y1()
true => id.set_color(#F24968)
=> id.set_color(#14D990)
0
var main = line.new(dnLabel.first().get_x(), dnLabel.first().get_y(), upLabel.first().get_x(), upLabel.first().get_y(),
style = line.style_dashed,
width = 2
)
main.updateMain()
//-----------------------------------FIB----------------------------------------------------------
// @function quickLine
// @param getX2 The x-coordinate for the endpoint of the line.
// @param y The y-coordinate for the line’s position.
// @param color The color of the line to be drawn.
// @returns void
// @description Draws a horizontal line on the chart with specific attributes.
quickLine(getX2, y, color) =>
line.new(getX2, y, bar_index + 5, y, color = color.new(color, 50))
// @function quickLabel
// @param y The y-coordinate for the label’s position.
// @param txt Text content of the label.
// @param color The text color of the label.
// @returns void
// @description Places a label with given text and color at a specified y-coordinate.
quickLabel(y, txt, color) =>
label.new(bar_index + 5, y, text = str.tostring(txt), color = #00000000, style = label.style_label_left, textcolor = color)
// @function drawFibs
// @returns void
// @description Draws Fibonacci retracement levels based on recent price action.
drawFibs() =>
if barstate.islast
var fibLine = array.new(14)
var fibLab = array.new(14)
if fibLine.size() > 0
for i = 0 to fibLine.size() - 1
fibLine .get(i).delete()
fibLab .get(i).delete()
if showFibs
getY2 = main.get_y2(), sub = main.get_y1() - getY2,
getX1 = main.get_x1(), getX2 = main.get_x2()
for i = 0 to fibLine.size() - 1
mod = i % fibLine.size() - 1
= switch mod
0 =>
1 =>
2 =>
3 =>
4 =>
5 =>
6 =>
7 =>
8 =>
9 =>
10 =>
11 =>
12 =>
13 =>
fibLine.set(i, quickLine (getX2, y, col))
// Combine text level and price
priceLabel = str.tostring(y, "#.#####")
combinedText = txt + " (" + priceLabel + ")" // Prix entre parenthèses
fibLab.set(i, quickLabel(y, combinedText, col))
drawFibs()
// @function drawStructureInternals
// @returns void
// @description Draws internal structures for smaller price swings based on user-defined settings.
drawStructureInternals() =>
if showInt
var keyValues = map.new()
if keyValues.size() == 0
keyValues.put("movingSmall", 0)
if smallUpper != 0
keyValues.put("upsideSmall", 1)
keyValues.put("upaxisSmall", smallUpper)
keyValues.put("upaxis2Small", bar_index - intSens)
if smallLower != 0
keyValues.put("downsideSmall", 1)
keyValues.put("dnaxisSmall", smallLower)
keyValues.put("dnaxis2Small", bar_index - intSens)
if ta.crossover(close, keyValues.get("upaxisSmall"))
if keyValues.get("upsideSmall") != 0
str = switch
keyValues.get("movingSmall") < 0 => intStru != "BoS" ? 'I-CHoCH' : ""
=> intStru != "CHoCH" ? 'I-BoS' : ""
if intStru == "All" or str.contains(str, intStru)
drawChar(keyValues.get("upaxis2Small"), keyValues.get("upaxisSmall"), str, bullC, true)
keyValues.put("upsideSmall", 0)
keyValues.put("movingSmall", 1)
if ta.crossunder(close, keyValues.get("dnaxisSmall"))
if keyValues.get("downsideSmall") != 0
str = switch
keyValues.get("movingSmall") > 0 => intStru != "BoS" ? 'I-CHoCH' : ""
=> intStru != "CHoCH" ? 'I-BoS' : ""
if intStru == "All" or str.contains(str, intStru)
drawChar(keyValues.get("dnaxis2Small"), keyValues.get("dnaxisSmall"), str, bearC, false)
keyValues.put("downsideSmall", 0)
keyValues.put("movingSmall", -1)
drawStructureInternals()
// @function drawAOE
// @returns void
// @description Draws the Premium and Discount Zones on the chart based on recent highs and lows.
drawAOE() =>
atr = ta.atr(14)
if showAOE
if closeArr.size() > 50
aoi = closeArr.slice(0, 50)
aoi2 = openArr .slice(0, 50)
maxaoiH = math.max(aoi.max(), aoi2.max())
minaoiL = math.min(aoi.min(), aoi2.min())
var aoeLevels = map.new()
if aoeLevels.size() == 0
aoeLevels.put("High",
box.new(bar_index , maxaoiH * 1.01, bar_index + 5, maxaoiH,
border_color = #00000000,
bgcolor = color.new(#F24968, 90),
text = "Premium Zone", //"Area of Interest" ,
text_size = size.normal,//.small,
text_color = color.new(#F24968, 33)
))
aoeLevels.put("Low",
box.new(bar_index , minaoiL, bar_index + 5, minaoiL * .99,
border_color = #00000000,
bgcolor = color.new(#14D990, 90),
text = "Discount Zone", //"Area of Interest" ,
text_size = size.normal,//size.small,
text_color = color.new(#14D990, 33)
))
getHighBox = aoeLevels.get("High")
if close <= getHighBox.get_top() * 1.01
getHighBox.set_lefttop (bar_index , maxaoiH + atr)
getHighBox.set_rightbottom (bar_index + 5, maxaoiH)
getHighBox.set_text ("Premium Zone") //"Area of Interest")
else
getHighBox.set_lefttop (bar_index + 5, maxaoiH + atr)
getHighBox.set_rightbottom (bar_index + 5, maxaoiH + atr)
getHighBox.set_text ("")
getLowBox = aoeLevels.get("Low")
if close >= getLowBox.get_bottom() * .99
getLowBox.set_lefttop (bar_index , minaoiL)
getLowBox.set_rightbottom (bar_index + 5, minaoiL - atr)
getLowBox.set_text ("Discount Zone") //"Area of Interest")
else
getLowBox.set_lefttop (bar_index + 5, minaoiL)
getLowBox.set_rightbottom (bar_index + 5, - atr)
getLowBox.set_text ("")
drawAOE()
var table tab2 = table.new(position.top_right, 13, 13, bgcolor = #20222C, border_color = #363843, frame_color = #363843, border_width = 1, frame_width = 1)
nyHour = hour (timenow, "America/New_York")
nyMinute = minute(timenow, "America/New_York")
// @function fvg
// @param direction Determines the direction for fair value gap (FVG) detection: positive for up, negative for down.
// @returns An array of FVG boxes in the specified direction.
// @description Identifies fair value gaps (FVGs) and stores them in an array of boxes for visual representation.
fvg(direction) =>
var fvgMat = matrix.new(5), var fvgDrawings = array.new()
fvgMat.add_col(0, array.from(math.sign(close - open), close, high, low, time))
if fvgMat.columns() > 3
fvgMat.remove_col(fvgMat.columns() - 1)
if fvgMat.row(0).sum() == direction
getDir = math.sign(direction)
= switch getDir
-1 =>
=>
col = switch closeOnly
true => #00000000
=> color.new(fvgcol, fvgtra)
fvgDrawings.push(
box.new(int(fvgMat.get(4, 1)),y, last_bar_time, y1, xloc = xloc.bar_time,
border_color = col, bgcolor = col)
)
fvgDrawings
if showFVG
fvgDn = fvg(-3)
fvgUp = fvg(3)
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getfvg = fvgDn.get(i)
if high >= getfvg.get_top()
getfvg.delete()
fvgDn.remove(i)
else if contract
if high > getfvg.get_bottom()
getfvg.set_bottom(high)
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getfvg = fvgUp.get(i)
if low <= getfvg.get_bottom()
getfvg.delete()
fvgUp.remove(i)
else if contract
if low < getfvg.get_top()
getfvg.set_top(low)
if closeOnly and barstate.islast
minDist = matrix.new(1, 2, 20e20)
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getBottom = fvgDn.get(i).get_bottom()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getBottom)))
if math.abs(close - getBottom) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgDn.get(i).set_right(fvgDn.get(i).get_left())
fvgDn.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_right(last_bar_time)
minDist.set(0, 0, 0)
minDist.set(0, 1, 20e20)
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getTop = fvgUp.get(i).get_top()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getTop)))
if math.abs(close - getTop) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgUp.get(i).set_right(fvgUp.get(i).get_left())
fvgUp.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_right(last_bar_time)
// @function calculateTimeDifference
// @param timestamp1 The starting timestamp for time difference calculation.
// @param timestamp2 The ending timestamp for time difference calculation.
// @returns A tuple containing hours and minutes as integers.
// @description Calculates the time difference between two timestamps, outputting hours and minutes.
//calculateTimeDifference(timestamp1, timestamp2) =>
// timeDifference = timestamp2 - timestamp1
// hours = math.floor(timeDifference / 3600000)
// minutes = math.floor((timeDifference % 3600000) / 60000)
//
//dayAdjustment = (hour(timenow, "America/New_York") < 2) ? dayofmonth(timenow) + 1 : dayofmonth(timenow)
//dayAdjustment2 = nyHour >= 20 or nyHour < 2 ? dayofmonth(timenow) + 1 : dayofmonth(timenow)
// @function timeIsInRange
// @param startHour The start hour of the time range.
// @param startMinute The start minute of the time range.
// @param endHour The end hour of the time range.
// @param endMinute The end minute of the time range.
// @returns Boolean indicating if the current time is within the specified range.
// @description Checks if the current time falls within a specified range based on New York timezone.
//timeIsInRange(startHour, startMinute, endHour, endMinute) =>
// (nyHour > startHour or (nyHour == startHour and nyMinute >= startMinute)) and (nyHour < endHour or (nyHour == endHour and nyMinute <= endMinute))
// = switch
// timeIsInRange(9, 30, 16, 0) =>
// timeIsInRange(20, 0, 2 , 0) =>
// timeIsInRange(3, 0, 11, 30) =>
// =>
// = calculateTimeDifference(timenow, timetilchange)
//timetilchange2 = switch
// timeIsInRange(9, 30, 16, 0) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 20, 0, 0)
// timeIsInRange(20, 0, 2 , 0) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 3, 0, 0)
// timeIsInRange(3, 0, 11, 30) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 9, 30, 0)
// => na
//if na(timetilchange2)
// timetilchange2 := switch
// nyHour < 9 or (nyHour == 9 and nyMinute < 30) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 9, 30, 0)
// nyHour < 20 or (nyHour >= 16 and nyHour < 20) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 20, 0, 0)
// nyHour < 3 or (nyHour >= 2 and nyHour < 3) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 3, 0, 0)
// => na
// = calculateTimeDifference(timenow, timetilchange2)
//method getActivity(array id, float id2) =>
// if id.size() > 0
// volPerc1 = id.percentile_nearest_rank(10)
// volPerc2 = id.percentile_nearest_rank(33)
// volPerc3 = id.percentile_nearest_rank(50)
// volPerc4 = id.percentile_nearest_rank(66)
// volPerc5 = id.percentile_nearest_rank(90)
// log.warning(str.tostring(volPerc1) + " " + str.tostring(volPerc2) + " " + str.tostring(volPerc3) + " " + str.tostring(volPerc4) + " " + str.tostring(volPerc5))
// activity = switch
// id2 <= volPerc1 => "Very Low"
// id2 <= volPerc2 => "Low"
// id2 <= volPerc3 => "Average"
// id2 <= volPerc4 => "High"
// => "Very High"
// activity
//if barstate.islast
// hr4Act = vol4hrArr.getActivity(vol4hr)
// D1Act = vol1DArr .getActivity(vol1D)
// str = str.tostring(timetilchange)
// ch = str.substring(str, str.pos(str, ".") + 1, str.length(str))
// nu = str.tonumber(ch) * 6
// nu2 = str.substring(str.tostring(nu), 0, 2)
// table.cell(tab2, 0, 2, text = "Session:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 3, text = "Session Close:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 4, text = "Next Session:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 5, text = "Next Session Open:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 6, text = "4-Hr Volume:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 7, text = "24-Hr Volume:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 1, 2, text = stringCol , text_color = color.white)
// table.cell(tab2, 1, 3, text = stringCol != "Dead Zone" ? str.tostring(hours)+ "h" + str.tostring(minutes) + "m": "Dead Zone", text_color = color.white)
// table.cell(tab2, 1, 4, text =stringCol2, text_color = color.white)
// table.cell(tab2, 1, 5, text = str.tostring(hours2) + "h:" + str.tostring(minutes2) + "m", text_color = color.white)
// table.cell(tab2, 1, 6, text = hr4Act, text_color = color.white)
// table.cell(tab2, 1, 7, text = D1Act, text_color = color.white)
nyHour2 = hour (time, "America/New_York")
nyMinute2 = minute(time, "America/New_York")
// @function timeIsInRange2
// @param startHour The starting hour for checking the time range.
// @param startMinute The starting minute within the hour.
// @param endHour The ending hour for checking the time range.
// @param endMinute The ending minute within the hour.
// @returns Boolean indicating if the current time is within the specified range.
// @description Checks if the current chart time falls within a specified time range.
timeIsInRange2(startHour, startMinute, endHour, endMinute) =>
if endHour >= startHour
(nyHour2 > startHour or (nyHour2 == startHour and nyMinute2 >= startMinute)) and
(nyHour2 < endHour or (nyHour2 == endHour and nyMinute2 <= endMinute))
else
(nyHour2 > startHour or (nyHour2 == startHour and nyMinute2 >= startMinute)) or
(nyHour2 < endHour or (nyHour2 == endHour and nyMinute2 <= endMinute))
nyCol = input.color(defval = #f24968, title = "NY Color")
asCol = input.color(defval = #14D990, title = "Asia Color")
loCol = input.color(defval = #F2B807, title = "London Color")
tra = input.int(defval = 98, minval = 0, maxval = 100, title = "Transparency")
bgcolor(timeIsInRange2(9, 30, 16, 0) ? color.new(nyCol, tra) : na)
bgcolor(timeIsInRange2(20, 0, 2 , 0) ? color.new(asCol, tra) : na)
bgcolor(timeIsInRange2(3, 0, 11, 30) ? color.new(loCol, tra) : na)
//---------------------------------------Entry/Exit-------------------------------------------------------
// "Entry/Exit signal"
Entry_exit_ena = input.bool(defval = true, title = "Entry/Exit Signal" ,group = "Entry/exit Signal")
a = input.float(1.5, title="Key Value. 'This changes the sensitivity'", group = "Entry/exit Signal")
c = input.int(7, title="ATR Period", group = "Entry/exit Signal")
ma_length = input.int(50, minval=1, title="Période de la Moyenne Mobile", group = "Entry/exit Signal")
Trail_Stop_ENA = input.bool(defval = true, title = "Trail Stop" ,group = "Entry/exit Signal")
Trail_stop_col = input.color(title = "Trailing stop color", defval = color.yellow, group = "Entry/exit Signal")
//if Entry_exit_ena
// Paramètres de la Moyenne Mobile (Filtre de Tendance)
// Calculs de base
xATR = ta.atr(c)
nLoss = a * xATR
src = close
// Calcul de l'UT BOT Trailing Stop
var float xATRTrailingStop = 0.0
xATRTrailingStop := if src > nz(xATRTrailingStop ) and src > nz(xATRTrailingStop )
math.max(nz(xATRTrailingStop ), src - nLoss)
else if src < nz(xATRTrailingStop ) and src < nz(xATRTrailingStop )
math.min(nz(xATRTrailingStop ), src + nLoss)
else if src > nz(xATRTrailingStop )
src - nLoss
else
src + nLoss
// Calcul de la Moyenne Mobile
ma = ta.ema(close, ma_length)
// Condition de tendance
is_uptrend = close > ma
is_downtrend = close < ma
// Signaux d'achat et de vente selon le trend
buy = ta.crossover(src, xATRTrailingStop) and is_uptrend
sell = ta.crossunder(src, xATRTrailingStop) and is_downtrend
// Tracé de l'UT BOT Trailing Stop
plot(Trail_Stop_ENA ? xATRTrailingStop : na, color=buy ? color.green : sell ? color.red : Trail_stop_col, linewidth=2, title="Trailing Stop Style")
// Indication des signaux sur le graphique
if buy and Entry_exit_ena
label.new(bar_index, low, text='Buy', style=label.style_label_up, yloc=yloc.belowbar ,color=color.green, textcolor=color.white, size=size.small)
if sell and Entry_exit_ena
label.new(bar_index, high, text='Sell', style=label.style_label_down, yloc=yloc.abovebar, color=color.red, textcolor=color.white, size=size.small)
alertcondition(buy, "Buy/Long", "Buy Long")
alertcondition(sell, "Sell/Short", "Sell/Short")
// ----------------------------------------Trend table-----------------------------------------------
// Paramètres utilisateur
afficher_tableau = input.bool(true, "Afficher le tableau", group="Trend Table")
periode_ema = input.int(200, minval=1, title="Période EMA pour les tendances", group="Trend Table")
periode_ema_btc = input.int(200, minval=1, title="Période EMA pour la tendance BTC", group="Trend Table")
// Configuration des périodes de tendance avec un menu déroulant lisible
periode1 = input.string("15m", "Période de tendance 1", options= , group="Trend Table")
periode2 = input.string("1h", "Période de tendance 2", options= , group="Trend Table")
periode3 = input.string("4h", "Période de tendance 3", options= , group="Trend Table")
periode4 = input.string("Day", "Période de tendance 4", options= , group="Trend Table")
// Période de tendance pour le BTC
btc_periode_tendance = input.string("4h", "Période de tendance BTC", options= , group="Trend Table")
// Couleurs pour les tendances
color_haussier = color.green
color_baissier = color.red
// Couleurs de fond alternées pour les lignes (définies globalement)
bg_color_odd = color.new(color.gray, 90) // Gris très clair pour les lignes impaires
bg_color_even = color.new(color.gray, 70) // Gris clair pour les lignes paires
// Fonction de mapping des périodes lisibles en valeurs temporelles standard
f_mapper_periode(timeframe_lisible) =>
switch timeframe_lisible
"5m" => "5"
"15m" => "15"
"1h" => "60"
"4h" => "240"
"8h" => "480"
"12h" => "720"
"Day" => "D"
=> timeframe_lisible // Cas par défaut si aucune correspondance n'est trouvée
// Mapper les périodes sélectionnées
periode1_mapped = f_mapper_periode(periode1)
periode2_mapped = f_mapper_periode(periode2)
periode3_mapped = f_mapper_periode(periode3)
periode4_mapped = f_mapper_periode(periode4)
btc_periode_tendance_mapped = f_mapper_periode(btc_periode_tendance)
// Fonction pour déterminer la session actuelle en utilisant l'heure du graphique (UTC-5)
f_session_actuelle() =>
heure = hour(time)
minute_ = minute(time)
heure_mod = heure * 60 + minute_
sessions_actives = ""
// Définir les plages horaires des sessions en UTC-5
// Session Asie (19:00 - 04:00)
if (heure_mod >= (19 * 60) or heure_mod < (4 * 60))
sessions_actives := sessions_actives + "Asie, "
// Session Londres (03:00 - 12:00)
if (heure_mod >= (3 * 60) and heure_mod < (12 * 60))
sessions_actives := sessions_actives + "Londres, "
// Session New York (08:00 - 17:00)
if (heure_mod >= (8 * 60) and heure_mod < (17 * 60))
sessions_actives := sessions_actives + "NY, "
// Nettoyer la chaîne de caractères pour enlever la virgule finale
if (str.endswith(sessions_actives, ", "))
sessions_actives := str.substring(sessions_actives, 0, str.length(sessions_actives) - 2)
// Si aucune session n'est active
sessions_actives := sessions_actives == "" ? "Hors session" : sessions_actives
sessions_actives
session_actuelle = f_session_actuelle()
// Fonction pour calculer la tendance basée sur l'EMA sans lookahead
f_tendance(symbole, timeframe_tendance, periode_ema) =>
= request.security(symbole, timeframe_tendance, , barmerge.gaps_off, barmerge.lookahead_off)
tendance = cours > ema_valeur ? "Haussier" : "Baissier"
tendance
// Calcul de la tendance du BTC
tendance_btc = f_tendance("BINANCE:BTCUSDT", btc_periode_tendance_mapped, periode_ema_btc)
// Calcul des tendances pour les périodes spécifiées
tendance_periode1 = f_tendance(syminfo.tickerid, periode1_mapped, periode_ema)
tendance_periode2 = f_tendance(syminfo.tickerid, periode2_mapped, periode_ema)
tendance_periode3 = f_tendance(syminfo.tickerid, periode3_mapped, periode_ema)
tendance_periode4 = f_tendance(syminfo.tickerid, periode4_mapped, periode_ema)
// Fonction pour obtenir le nom du ticker actuel
f_ticker_actuel() =>
syminfo.ticker
// Obtenir le ticker actuel
ticker_actuel = f_ticker_actuel()
// Affichage du tableau
if afficher_tableau
// Création du tableau
var table mon_tableau = table.new(position=position.top_right, columns=2, rows=7, bgcolor=color.new(color.black, 0), frame_color=color.new(color.gray, 0), frame_width=1)
if barstate.isfirst
// Première colonne (libellés)
table.cell(table_id=mon_tableau, row=0, column=0, text="Session actuelle:", text_color=color.white, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=1, column=0, text="Tendance:", text_color=color.white, bgcolor=bg_color_odd, text_halign=text.align_right)
table.cell(table_id=mon_tableau, row=6, column=0, text="BTC (" + btc_periode_tendance + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=2, column=0, text= ticker_actuel + " (" + periode1 + "):", text_color=color.white, bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=3, column=0, text="(" + periode2 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=4, column=0, text="(" + periode3 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=5, column=0, text="(" + periode4 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
// Définir les couleurs de fond pour les cellules de tendance
trend_btc_color = tendance_btc == "Haussier" ? color.green : color.red
trend_periode1_color = tendance_periode1 == "Haussier" ? color.green : color.red
trend_periode2_color = tendance_periode2 == "Haussier" ? color.green : color.red
trend_periode3_color = tendance_periode3 == "Haussier" ? color.green : color.red
trend_periode4_color = tendance_periode4 == "Haussier" ? color.green : color.red
// Mise à jour des valeurs avec les couleurs appropriées
table.cell(table_id=mon_tableau, row=0, column=1, text=session_actuelle, text_color=color.yellow, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=1, column=1, text="", bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=6, column=1, text=tendance_btc, text_color=color.white, bgcolor=trend_btc_color)
table.cell(table_id=mon_tableau, row=2, column=1, text=tendance_periode1, text_color=color.white, bgcolor=trend_periode1_color)
table.cell(table_id=mon_tableau, row=3, column=1, text=tendance_periode2, text_color=color.white, bgcolor=trend_periode2_color)
table.cell(table_id=mon_tableau, row=4, column=1, text=tendance_periode3, text_color=color.white, bgcolor=trend_periode3_color)
table.cell(table_id=mon_tableau, row=5, column=1, text=tendance_periode4, text_color=color.white, bgcolor=trend_periode4_color)
// Optionnel : Ajouter une étiquette de débogage pour vérifier la session actuelle
// label.new(bar_index, high, text="Session: " + session_actuelle, style=label.style_label_down, color=color.blue, textcolor=color.white, size=size.small, yloc=yloc.abovebar)
EMA (25, 50, 100)Three EMA (25, 50, 100) with three color (red, orange and yellow) with tre different line widht.
BTC 雙MACD 背離策略(基礎共振 / 適用15分鐘 / 多空自動)📌 Strategy Name: BTC Dual MACD Divergence Strategy (15min, Auto Long & Short)
🔍 Overview:
This strategy uses a dual MACD divergence signal (fast and slow MACD) combined with a proximity filter to the 28-period Simple Moving Average (SMA28) to detect potential trend reversals with stronger confirmation.
🧠 Entry Conditions:
Bullish or Bearish divergence detected on both fast and slow MACD.
Price must be within ±1.5% of the SMA28 (proximity condition).
Long and short entries are allowed automatically.
🎯 Exit Conditions:
Fixed Risk-to-Reward ratio of 1:1.5.
Take Profit: +1.5% from entry price.
Stop Loss: -1.0% from entry price.
⏱ Timeframe:
Optimized for 15-minute charts.
Can be integrated with auto-trading bots via alerts/webhooks.
⚠️ Notes:
This strategy is designed for technical validation and automation testing.
Please backtest thoroughly and use proper risk management before applying in live trading.
Ideal for pairing with platforms like WunderTrading, 3Commas, or other webhook-based bot systems.
Advanced Crypto Scalper ComboIncluded Tools (Advanced Combo):
MACD with Histogram Reversal Detection – momentum shift entry
Bollinger Band Squeeze Breakout – pre-breakout warning
ATR-Based Dynamic TP/SL – for volatility-based risk
RSI/MACD Divergence Detection – reversal confirmation
Order Block / Supply & Demand Zones – smart money zones
Features You’ll See on Chart:
Bollinger Bands and Squeeze background
MACD Cross signals with histogram confirmation
Bullish/Bearish RSI divergence detection
Dynamic Take-Profit / Stop-Loss using ATR
Visual markers for simple demand/supply zones
Micro Channel Alert Pro//@version=6
indicator("Micro Channel Alert Pro", overlay=true)
// === تنظیمات
len = input.int(7, "Micro Channel Length", minval=3, maxval=10)
emaLength = input.int(20, "EMA Length")
minTrendStrength = input.float(0.002, "Min Trend Strength (%)", step=0.0001)
angleThreshold = input.float(25.0, "Min Channel Angle (degrees)")
cooldownBars = input.int(10, "Cooldown after Signal", minval=1)
// === محاسبه EMA و قدرت روند
ema = ta.ema(close, emaLength)
trendStrength = math.abs(ema - ema ) / ema
isTrending = trendStrength > minTrendStrength
// === محاسبه زاویه رگرسیون (به درجه)
regNow = ta.linreg(close, len, 0)
regPrev = ta.linreg(close, len, 1)
angleClose = math.atan(regNow - regPrev) * 180 / math.pi
// === بررسی ساختار HL یا LH
isHL = true
isLH = true
for i = 1 to len - 1
isHL := isHL and (low > low ) and (high > high )
isLH := isLH and (low < low ) and (high < high )
// === بررسی نوسان پایین (کندلهای کوچک)
avgRange = ta.sma(high - low, len)
avgBody = ta.sma(math.abs(close - open), len)
lowVolatility = avgBody / avgRange < 0.6
// === شرایط سیگنال
microUp = isTrending and isLH and angleClose > angleThreshold and lowVolatility and close > high
microDn = isTrending and isHL and angleClose < -angleThreshold and lowVolatility and close < low
// === جلوگیری از سیگنال تکراری
var int lastSignalBar = na
cooldownOk = na(lastSignalBar) or (bar_index - lastSignalBar > cooldownBars)
signalUp = microUp and cooldownOk
signalDn = microDn and cooldownOk
if signalUp or signalDn
lastSignalBar := bar_index
// === نمایش روی چارت
plotshape(signalUp, title="Micro Up", location=location.belowbar, style=shape.labelup, color=color.green, text="Micro ↑")
plotshape(signalDn, title="Micro Down", location=location.abovebar, style=shape.labeldown, color=color.red, text="Micro ↓")
// === آلارم
alertcondition(signalUp, title="Micro Channel Up Alert", message="Micro Channel Up Detected!")
alertcondition(signalDn, title="Micro Channel Down Alert", message="Micro Channel Down Detected!")
BRKT SMART - VWAPVolumeCVDOI (Agg BINANCE OKX)This script is a powerful breakout detection tool designed to capture real market intent by combining VWAP structure, volume surges, and derivatives market data from multiple top-tier exchanges (BINANCE + OKX).
It identifies:
✅ True breakouts with confirmation from volume, Open Interest delta (OIΔ), and directional aggression (CVD)
⚠️ Fake breakouts (traps) where the market lacks new commitment (negative OIΔ and counter-pressure)
🔁 Retests after breakout to help time re-entries or add-ons
🔍 Key Features:
🧠 Aggregated OI & Volume from BINANCE and OKX for a more accurate picture of institutional activity
⚙️ Fully customizable thresholds for volume, OIΔ, and CVD delta
🎯 Optional cooldown between signals to avoid noise
📉 Visual markers for:
Breakouts (BRK↑ / BRK↓)
Traps (FAL↑ / FAL↓)
Retests (Ret↑ / Ret↓)
🟦 VWAP as central structure reference
🔧 Parameters You Can Adjust:
Volume strength (x times the average)
Minimum/maximum thresholds for OIΔ and CVD
Cooldown time between signals
Pullback detection window