Ultimate BAMF Indicator

indicator("Ultimate BAMF Indicator", overlay=true)
// =============================================================================
// Section 1: OHLC Annotations
// =============================================================================
// Input to toggle OHLC annotations
ohlc_show = input.bool(true, title="Show OHLC Annotations", group="OHLC Settings")
// Adjustable colors and transparency for resistance (tops)
ohlc_high_body_color = input.color(color.red, title="Body High Color (Resistance)", group="OHLC Colors")
ohlc_high_body_transparency = input.int(50, title="Body High Transparency (0-100)", minval=0, maxval=100, group="OHLC Colors")
ohlc_high_wick_color = input.color(color.new(color.red, 20), title="Wick High Color (Resistance)", group="OHLC Colors")
ohlc_high_wick_transparency = input.int(50, title="Wick High Transparency (0-100)", minval=0, maxval=100, group="OHLC Colors")
ohlc_high_shade_color = input.color(color.red, title="Resistance Shade Color", group="OHLC Colors")
ohlc_high_shade_transparency = input.int(80, title="Resistance Shade Transparency (0-100)", minval=0, maxval=100, group="OHLC Colors")
// Adjustable colors and transparency for support (bottoms)
ohlc_low_wick_color = input.color(color.green, title="Wick Low Color (Support)", group="OHLC Colors")
ohlc_low_wick_transparency = input.int(50, title="Wick Low Transparency (0-100)", minval=0, maxval=100, group="OHLC Colors")
ohlc_low_body_color = input.color(color.new(color.green, 20), title="Body Low Color (Support)", group="OHLC Colors")
ohlc_low_body_transparency = input.int(50, title="Body Low Transparency (0-100)", minval=0, maxval=100, group="OHLC Colors")
ohlc_low_shade_color = input.color(color.green, title="Support Shade Color", group="OHLC Colors")
ohlc_low_shade_transparency = input.int(80, title="Support Shade Transparency (0-100)", minval=0, maxval=100, group="OHLC Colors")
// Variables to store lines, boxes, and labels for deletion
var line ohlc_body_high_line = na
var line ohlc_wick_high_line = na
var box ohlc_high_shade_box = na
var label ohlc_body_high_label = na
var label ohlc_wick_high_label = na
var label ohlc_wick_low_label = na
var label ohlc_body_low_label = na
var box ohlc_low_shade_box = na
// Variables to control circle visibility
var float ohlc_wick_low_shape = na
var float ohlc_body_low_shape = na
// Extend lines and boxes to the right edge of the chart (within 500-bar limit)
ohlc_right_edge = bar_index + 500 // Limit to 500 bars into the future to avoid runtime error
// Detect when a new bar starts using time comparison (store result in global variable)
ohlc_is_new_bar = ta.change(time) != 0
// Use the global variable in the condition
if ohlc_show and ohlc_is_new_bar
// Delete previous lines, boxes, and labels
if not na(ohlc_body_high_line)
line.delete(ohlc_body_high_line[1])
if not na(ohlc_wick_high_line)
line.delete(ohlc_wick_high_line[1])
if not na(ohlc_high_shade_box)
box.delete(ohlc_high_shade_box[1])
if not na(ohlc_body_high_label)
label.delete(ohlc_body_high_label[1])
if not na(ohlc_wick_high_label)
label.delete(ohlc_wick_high_label[1])
if not na(ohlc_wick_low_label)
label.delete(ohlc_wick_low_label[1])
if not na(ohlc_body_low_label)
label.delete(ohlc_body_low_label[1])
if not na(ohlc_low_shade_box)
box.delete(ohlc_low_shade_box[1])
// Clear previous circles
ohlc_wick_low_shape := na
ohlc_body_low_shape := na
// Calculate OHLC values for the previous candle
ohlc_prev_open = open[1]
ohlc_prev_close = close[1]
ohlc_prev_high = high[1]
ohlc_prev_low = low[1]
// Determine body high and body low for the previous candle
ohlc_prev_body_high = math.max(ohlc_prev_open, ohlc_prev_close)
ohlc_prev_body_low = math.min(ohlc_prev_open, ohlc_prev_close)
// Draw shaded area between body high and wick high (resistance)
if ohlc_prev_body_high < ohlc_prev_high
ohlc_high_shade_box := box.new(bar_index[1], ohlc_prev_body_high, ohlc_right_edge, ohlc_prev_high, border_color=na, bgcolor=color.new(ohlc_high_shade_color, ohlc_high_shade_transparency))
else
ohlc_high_shade_box := box.new(bar_index[1], ohlc_prev_high, ohlc_right_edge, ohlc_prev_body_high, border_color=na, bgcolor=color.new(ohlc_high_shade_color, ohlc_high_shade_transparency))
// Draw horizontal lines for body high and wick high with adjustable transparency
ohlc_body_high_line := line.new(bar_index[1], ohlc_prev_body_high, ohlc_right_edge, ohlc_prev_body_high, color=color.new(ohlc_high_body_color, ohlc_high_body_transparency), style=line.style_solid)
ohlc_wick_high_line := line.new(bar_index[1], ohlc_prev_high, ohlc_right_edge, ohlc_prev_high, color=color.new(ohlc_high_wick_color, ohlc_high_wick_transparency), style=line.style_dotted)
// Draw shaded area between wick low and body low (support)
if ohlc_prev_low < ohlc_prev_body_low
ohlc_low_shade_box := box.new(bar_index[1], ohlc_prev_low, ohlc_right_edge, ohlc_prev_body_low, border_color=na, bgcolor=color.new(ohlc_low_shade_color, ohlc_low_shade_transparency))
else
ohlc_low_shade_box := box.new(bar_index[1], ohlc_prev_body_low, ohlc_right_edge, ohlc_prev_low, border_color=na, bgcolor=color.new(ohlc_low_shade_color, ohlc_low_shade_transparency))
// Circles for wick low and body low with adjustable transparency
ohlc_wick_low_shape := ohlc_prev_low
ohlc_body_low_shape := ohlc_prev_body_low
// Labels for the previous bar's values with matching colors and adjustable transparency
ohlc_body_high_label := label.new(bar_index[1], ohlc_prev_body_high, text="H: " + str.tostring(ohlc_prev_body_high, format.mintick), color=color.new(ohlc_high_body_color, 70), textcolor=color.white, style=label.style_label_left, textalign=text.align_left)
ohlc_wick_high_label := label.new(bar_index[1], ohlc_prev_high, text="H: " + str.tostring(ohlc_prev_high, format.mintick), color=color.new(ohlc_high_wick_color, 70), textcolor=color.white, style=label.style_label_left, textalign=text.align_left)
ohlc_wick_low_label := label.new(bar_index[1], ohlc_prev_low, text="L: " + str.tostring(ohlc_prev_low, format.mintick), color=color.new(ohlc_low_wick_color, 70), textcolor=color.white, style=label.style_label_up, textalign=text.align_center)
ohlc_body_low_label := label.new(bar_index[1], ohlc_prev_body_low, text="L: " + str.tostring(ohlc_prev_body_low, format.mintick), color=color.new(ohlc_low_body_color, 70), textcolor=color.white, style=label.style_label_up, textalign=text.align_center)
// Plot circles for wick low and body low with adjustable transparency
plotshape(ohlc_wick_low_shape, style=shape.circle, location=location.absolute, color=color.new(ohlc_low_wick_color, ohlc_low_wick_transparency), size=size.tiny)
plotshape(ohlc_body_low_shape, style=shape.circle, location=location.absolute, color=color.new(ohlc_low_body_color, ohlc_low_body_transparency), size=size.tiny)
// =============================================================================
// Section 2: Real-Time Stock Analysis with Trade Automation Signals
// =============================================================================
// --- Inputs ---
rt_smaLength = input.int(10, "SMA Length for Trend", group="Real-Time Analysis Settings")
rt_rsiLength = input.int(9, "RSI Length", group="Real-Time Analysis Settings")
rt_macdFast = input.int(12, "MACD Fast Length", group="Real-Time Analysis Settings")
rt_macdSlow = input.int(26, "MACD Slow Length", group="Real-Time Analysis Settings")
rt_macdSignal = input.int(9, "MACD Signal Length", group="Real-Time Analysis Settings")
rt_bbLength = input.int(20, "Bollinger Bands Length", group="Real-Time Analysis Settings")
rt_bbMult = input.float(2.0, "Bollinger Bands Multiplier", group="Real-Time Analysis Settings")
rt_volumeThreshold = input.float(0.8, "Volume Threshold (x Average)", group="Real-Time Analysis Settings")
// --- Trend Analysis (SMC-like) for Current Timeframe ---
rt_sma = ta.sma(close, rt_smaLength)
rt_trendBias = close > rt_sma ? "Bullish" : close < rt_sma ? "Bearish" : "Neutral"
// --- MTF Trend Analysis ---
f_getTrendBias(tf) =>
close_tf = request.security(symbol=syminfo.tickerid, timeframe=tf, expression=close, gaps=barmerge.gaps_off)
sma_tf = ta.sma(close_tf, rt_smaLength)
trend = close_tf > sma_tf ? "Bullish" : close_tf < sma_tf ? "Bearish" : "Neutral"
trend
rt_trendBias_30m = f_getTrendBias("30")
rt_trendBias_1h = f_getTrendBias("60")
rt_trendBias_4h = f_getTrendBias("240")
// --- Volume Analysis ---
rt_avgVolume = ta.sma(volume, 20)
rt_volumeRatio = volume / rt_avgVolume
rt_volumeStatus = rt_volumeRatio >= rt_volumeThreshold ? "High Vol" : "Thin Vol"
// --- RSI ---
rt_rsi = ta.rsi(close, rt_rsiLength)
rt_rsiStatus = rt_rsi > 70 ? "Overbought" : rt_rsi < 30 ? "Oversold" : "Neutral"
// --- MACD ---
[rt_macdLine, rt_signalLine, rt_hist] = ta.macd(close, rt_macdFast, rt_macdSlow, rt_macdSignal)
rt_macdStatus1 = rt_macdLine > rt_signalLine ? "Bullish" : "Bearish"
rt_macdStatus2 = rt_macdLine > 0 ? "Bullish" : "Bearish"
rt_macdStatus3 = rt_hist > 0 ? "Bullish" : "Bearish"
rt_macdStatus = rt_macdStatus1 + ", " + rt_macdStatus2 + ", " + rt_macdStatus3
// --- Bollinger Bands ---
rt_basis = ta.sma(close, rt_bbLength)
rt_dev = rt_bbMult * ta.stdev(close, rt_bbLength)
rt_upperBB = rt_basis + rt_dev
rt_lowerBB = rt_basis - rt_dev
rt_bbStatus = close > rt_upperBB ? "Above Upper" : close < rt_lowerBB ? "Below Lower" : "Within"
// --- Improved Candle Analysis ---
rt_bodySize = math.abs(close - open)
rt_avgBodySize = ta.sma(rt_bodySize, 10)
rt_isSignificantCandle = rt_bodySize > 0.5 * rt_avgBodySize
rt_candleDirection = close > open ? "Bullish" : close < open ? "Bearish" : "Neutral"
var string rt_prevCandleDirection = "Neutral"
rt_candleStatus = rt_isSignificantCandle ? (rt_candleDirection != rt_prevCandleDirection ? rt_candleDirection + " Change" : rt_candleDirection) : "Neutral"
rt_prevCandleDirection := rt_candleDirection
// --- Enhanced Target Zone & Stop-Loss ---
rt_swingHigh = ta.highest(high, 10)
rt_swingLow = ta.lowest(low, 10)
rt_prevSwingHigh = ta.highest(high[10], 10)
rt_prevSwingLow = ta.lowest(low[10], 10)
rt_marketStructure = rt_swingHigh > rt_prevSwingHigh and rt_swingLow > rt_prevSwingLow ? "Bullish" : rt_swingHigh < rt_prevSwingHigh and rt_swingLow < rt_prevSwingLow ? "Bearish" : "Ranging"
// Define Target and Stop-Loss based on market structure
rt_targetZone = rt_marketStructure == "Bullish" ? rt_swingHigh : rt_marketStructure == "Bearish" ? rt_swingLow : na
rt_stopLoss = rt_marketStructure == "Bullish" ? rt_swingLow : rt_marketStructure == "Bearish" ? rt_swingHigh : na
// Ensure 3:1 RRR by adjusting target if needed
rt_entryPrice = close
rt_distanceToStop = math.abs(rt_entryPrice - rt_stopLoss)
rt_targetZone := rt_marketStructure == "Bullish" ? rt_entryPrice + 3 * rt_distanceToStop : rt_marketStructure == "Bearish" ? rt_entryPrice - 3 * rt_distanceToStop : rt_targetZone
// RRR Calculation
rt_denominator = rt_distanceToStop
rt_rrr = math.abs(rt_denominator) > 0.01 ? (rt_targetZone - rt_entryPrice) / rt_denominator : na
rt_rrrText = not na(rt_rrr) ? str.tostring(math.round(rt_rrr, 1), "#.#") : "N/A"
// --- Momentum (Rate of Change) ---
rt_roc = ta.roc(close, 5)
rt_momentumBullish = rt_roc > 0
rt_momentumBearish = rt_roc < 0
// --- Market Structure Analysis ---
rt_marketTrendBias = rt_trendBias
rt_trendStrength = rt_rsi > 50 and rt_macdLine > rt_signalLine ? "Strong Bullish" : rt_rsi < 50 and rt_macdLine < rt_signalLine ? "Strong Bearish" : "Neutral"
rt_whatToWatch = "Price may stall if vol weak\nHold > " + str.tostring(math.round(close * 0.95, 2), "#.##") + " = continue\nBreak < " + str.tostring(math.round(close * 0.85, 2), "#.##") + " = invalid\nTrail stops if in profit"
// --- Mini Gauge Metrics ---
rt_heat = rt_trendStrength == "Strong Bullish" ? "Strong Bull" : rt_trendStrength == "Strong Bearish" ? "Strong Bear" : "Neutral"
rt_trendScore = rt_rsi > 70 ? "5/5" : rt_rsi > 60 ? "4/5" : rt_rsi > 50 ? "3/5" : rt_rsi > 40 ? "2/5" : "1/5"
rt_choppy = ta.stdev(close, 20) > ta.stdev(close[20], 20) ? "Trending" : "Choppy"
rt_entryFilter = rt_rsi > 70 or rt_rsi < 30 ? "Not worth risk" : "Potential entry"
rt_exitNote = "Monitor key lvl or momentum"
rt_miniTradeSuggestion = "Momentum favors " + (rt_trendBias == "Bullish" ? "bulls" : "bears") + ". Await CHOCH/BOS"
// --- Trade Signals ---
rt_buySignal = rt_momentumBullish and rt_volumeRatio >= rt_volumeThreshold and rt_marketStructure == "Bullish"
rt_sellSignal = rt_momentumBearish and rt_volumeRatio >= rt_volumeThreshold and rt_marketStructure == "Bearish"
rt_setupStatus = rt_buySignal ? "Long/Call Active" : rt_sellSignal ? "Short/Put Active" : "No Signal"
// --- Colors ---
rt_red = color.red
rt_green = color.green
rt_blue = color.blue
rt_gray = color.gray
rt_yellow = color.yellow
rt_white = color.white
rt_black = color.black
rt_sectionHeaderColor = color.new(rt_gray, 70)
// --- Precompute Colors for Dashboard ---
rt_trendColor = rt_trendBias == "Bullish" ? rt_green : rt_trendBias == "Bearish" ? rt_red : rt_yellow
rt_trendColor_30m = rt_trendBias_30m == "Bullish" ? rt_green : rt_trendBias_30m == "Bearish" ? rt_red : rt_yellow
rt_trendColor_1h = rt_trendBias_1h == "Bullish" ? rt_green : rt_trendBias_1h == "Bearish" ? rt_red : rt_yellow
rt_trendColor_4h = rt_trendBias_4h == "Bullish" ? rt_green : rt_trendBias_4h == "Bearish" ? rt_red : rt_yellow
rt_volumeColor = rt_green
rt_macdColor = rt_macdStatus1 == "Bullish" ? rt_green : rt_red
rt_tradeColor = rt_buySignal ? rt_green : rt_sellSignal ? rt_red : rt_yellow
rt_trendStrengthColor = rt_trendStrength == "Strong Bullish" ? rt_yellow : rt_trendStrength == "Strong Bearish" ? rt_red : rt_white
rt_heatColor = rt_heat == "Strong Bull" ? rt_yellow : rt_heat == "Strong Bear" ? rt_red : rt_white
rt_structureColor = rt_marketStructure == "Bullish" ? rt_green : rt_marketStructure == "Bearish" ? rt_red : rt_yellow
// --- Consolidated Table for Real-Time Analysis ---
var table rt_dashboardTable = table.new(position.top_right, 2, 23, border_width=2)
if ta.change(time) != 0
// Market Scan Section
table.cell(rt_dashboardTable, 0, 0, "MARKET SCAN", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 1, 0, "", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 0, 1, "Trend Bias", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 1, rt_marketTrendBias, text_color=rt_trendColor, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 2, "30m Trend", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 2, rt_trendBias_30m, text_color=rt_trendColor_30m, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 3, "1h Trend", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 3, rt_trendBias_1h, text_color=rt_trendColor_1h, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 4, "4h Trend", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 4, rt_trendBias_4h, text_color=rt_trendColor_4h, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 5, "Setup", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 5, rt_setupStatus, text_color=rt_tradeColor, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 6, "Trend Strength", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 6, rt_trendStrength, text_color=rt_trendStrengthColor, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 7, "Structure", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 7, rt_marketStructure, text_color=rt_structureColor, bgcolor=color.new(rt_black, 90))
// Signal Engine Section
table.cell(rt_dashboardTable, 0, 8, "SIGNAL ENGINE", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 1, 8, "", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 0, 9, "Volume", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 9, rt_volumeStatus + " (" + str.tostring(rt_volumeRatio, "#.##") + "x)", text_color=rt_volumeColor, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 10, "Candle", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 10, rt_candleStatus, text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 11, "RSI, MACD, BBP", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 11, rt_rsiStatus + ", " + rt_macdStatus1 + ", " + rt_bbStatus, text_color=rt_macdColor, bgcolor=color.new(rt_black, 90))
// Target Zone Section
table.cell(rt_dashboardTable, 0, 12, "TARGET ZONE", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 1, 12, "", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 0, 13, "Target", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 13, str.tostring(rt_targetZone, "#.##") + " (RRR: " + rt_rrrText + ")", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 14, "Stop Loss", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 14, str.tostring(rt_stopLoss, "#.##"), text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 15, "Watch", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 15, rt_whatToWatch, text_color=rt_white, bgcolor=color.new(rt_black, 90))
// Mini Gauge Section
table.cell(rt_dashboardTable, 0, 16, "MINI GAUGE", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 1, 16, "", text_color=rt_white, bgcolor=rt_sectionHeaderColor)
table.cell(rt_dashboardTable, 0, 17, "Heat", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 17, rt_heat, text_color=rt_heatColor, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 18, "Trend Score", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 18, rt_trendScore, text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 19, "Choppy", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 19, rt_choppy, text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 20, "Entry Filter", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 20, rt_entryFilter, text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 21, "Exit Note", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 21, rt_exitNote, text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 0, 22, "Trade Suggest", text_color=rt_white, bgcolor=color.new(rt_black, 90))
table.cell(rt_dashboardTable, 1, 22, rt_miniTradeSuggestion, text_color=rt_white, bgcolor=color.new(rt_black, 90))
// --- Plotting ---
plot(rt_sma, "SMA", color=rt_blue)
plot(rt_upperBB, "Upper BB", color=rt_gray)
plot(rt_lowerBB, "Lower BB", color=rt_gray)
plot(rt_targetZone, "Target", color=rt_green, style=plot.style_circles)
plot(rt_stopLoss, "Stop-Loss", color=rt_red, style=plot.style_circles)
// =============================================================================
// Section 3: Fair Value Gaps (5M & 1M)
// =============================================================================
// Inputs for enabling/disabling timeframes and aesthetics
fvg_show_5m = input.bool(true, "Show 5M FVGs", group="FVG Settings")
fvg_show_1m = input.bool(true, "Show 1M FVGs", group="FVG Settings")
fvg_extend_bars = input.int(10, "Extend FVG Bars", minval=1, group="FVG Settings")
fvg_bull_color = input.color(color.new(#2962FF, 85), "Bullish FVG Color", group="FVG Colors")
fvg_bear_color = input.color(color.new(#E91E63, 85), "Bearish FVG Color", group="FVG Colors")
// Function to identify FVGs on a given timeframe
f_fvg_data(string timeframe) =>
fvg_high_tf = request.security(syminfo.tickerid, timeframe, high, gaps=barmerge.gaps_off)
fvg_low_tf = request.security(syminfo.tickerid, timeframe, low, gaps=barmerge.gaps_off)
fvg_high_tf_2 = request.security(syminfo.tickerid, timeframe, high[2], gaps=barmerge.gaps_off)
fvg_low_tf_2 = request.security(syminfo.tickerid, timeframe, low[2], gaps=barmerge.gaps_off)
// Detect Bullish FVG: Current low > high[2]
fvg_bull_fvg = fvg_low_tf > fvg_high_tf_2
fvg_bull_top = fvg_low_tf
fvg_bull_bottom = fvg_high_tf_2
// Detect Bearish FVG: Current high < low[2]
fvg_bear_fvg = fvg_high_tf < fvg_low_tf_2
fvg_bear_top = fvg_low_tf_2
fvg_bear_bottom = fvg_high_tf
[fvg_bull_fvg, fvg_bull_top, fvg_bull_bottom, fvg_bear_fvg, fvg_bear_top, fvg_bear_bottom]
// Identify FVGs on 5M and 1M timeframes
[fvg_bull_fvg_5m, fvg_bull_top_5m, fvg_bull_bottom_5m, fvg_bear_fvg_5m, fvg_bear_top_5m, fvg_bear_bottom_5m] = f_fvg_data("5")
[fvg_bull_fvg_1m, fvg_bull_top_1m, fvg_bull_bottom_1m, fvg_bear_fvg_1m, fvg_bear_top_1m, fvg_bear_bottom_1m] = f_fvg_data("1")
// Plot FVGs as background boxes (transparent, no text)
if fvg_show_5m and fvg_bull_fvg_5m and not na(fvg_bull_top_5m) and not na(fvg_bull_bottom_5m)
box.new(left=bar_index[2], top=fvg_bull_top_5m, right=bar_index + fvg_extend_bars, bottom=fvg_bull_bottom_5m, border_color=color.new(color.gray, 100), bgcolor=fvg_bull_color)
if fvg_show_5m and fvg_bear_fvg_5m and not na(fvg_bear_top_5m) and not na(fvg_bear_bottom_5m)
box.new(left=bar_index[2], top=fvg_bear_top_5m, right=bar_index + fvg_extend_bars, bottom=fvg_bear_bottom_5m, border_color=color.new(color.gray, 100), bgcolor=fvg_bear_color)
if fvg_show_1m and fvg_bull_fvg_1m and not na(fvg_bull_top_1m) and not na(fvg_bull_bottom_1m)
box.new(left=bar_index[2], top=fvg_bull_top_1m, right=bar_index + fvg_extend_bars, bottom=fvg_bull_bottom_1m, border_color=color.new(color.gray, 100), bgcolor=fvg_bull_color)
if fvg_show_1m and fvg_bear_fvg_1m and not na(fvg_bear_top_1m) and not na(fvg_bear_bottom_1m)
box.new(left=bar_index[2], top=fvg_bear_top_1m, right=bar_index + fvg_extend_bars, bottom=fvg_bear_bottom_1m, border_color=color.new(color.gray, 100), bgcolor=fvg_bear_color)
// Plot the candlestick chart (shared across all sections)
plotcandle(open, high, low, close, "Candles", color.green, color.red)
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi mmrivera21 secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.
Penafian
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi mmrivera21 secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.