← К каталогу
Исходный код · ID 4180

<[SMC-FVG] + [HL Reversals]>

indicator smc-fvg + hl reversals for tradingview.pine
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

Индикатор для TradingView на Pine Script v6, совмещающий визуализацию зон справедливой стоимости (FVG) и уровней разворотов HL на одном графике. Обнаруживает бычьи и медвежьи зоны FVG по трёхсвечной модели и отображает их прямоугольниками с возможностью мультитаймфреймового анализа на трёх настраиваемых таймфреймах. Зоны автоматически закрываются при касании или прохождении цены, с опциональным переключением в пунктирный режим после частичного касания. Вторая часть индикатора строит уровни поддержки и сопротивления на основе разворотов ценовых экстремумов, отображая маркеры и линии более высоких и нижних максимумов и минимумов с настройками отображения каналов, точки пивота и символов пробоя фракталов.

Настройки программы

НастройкаОписание
showFVG Показывать SMC-FVG — Главный переключатель, включающий или отключающий отображение всех зон FVG на графике
showReversals Показывать HL Reversals — Главный переключатель, включающий или отключающий отображение уровней разворотов и связанных маркеров
fvg_length Длина отображения FVG — Определяет горизонтальную длину прямоугольников зон FVG в количестве баров
show_fvg Показывать FVG — Включает отображение прямоугольников FVG на текущем таймфрейме; активен только при включённом переключателе Show SMC-FVG
strict_mode Строгий режим — При активации зона FVG закрывается при касании ценой области зоны, при деактивации — при полном прохождении цены через зону
show_dashed_after_touch Показывать пунктир после частичного касания — Преобразует границу и заливку зоны FVG в пунктир при частичном касании ценой
mtf_1 MTF 1 — Первый таймфрейм для мультитаймфреймового обнаружения зон FVG
show_mtf_1 Показать MTF 1 — Включает отображение зон FVG на первом мультитаймфрейме; активен только при включённом переключателе Show SMC-FVG
mtf_2 MTF 2 — Второй таймфрейм для мультитаймфреймового обнаружения зон FVG
show_mtf_2 Показать MTF 2 — Включает отображение зон FVG на втором мультитаймфрейме; активен только при включённом переключателе Show SMC-FVG
mtf_3 MTF 3 — Третий таймфрейм для мультитаймфреймового обнаружения зон FVG
show_mtf_3 Показать MTF 3 — Включает отображение зон FVG на третьем мультитаймфрейме; активен только при включённом переключателе Show SMC-FVG
bullish_fvg_color Цвет бычьей FVG — Задаёт цвет заливки прямоугольников зон FVG, образующихся при бычьей конфигурации
bearish_fvg_color Цвет медвежьей FVG — Задаёт цвет заливки прямоугольников зон FVG, образующихся при медвежьей конфигурации
srcH Источник максимумов — Источник данных для расчёта разворотов по максимумам
leftLenH Левый период максимумов — Количество баров слева от потенциального максимума для подтверждения пивота
rightLenH Правый период максимумов — Количество баров справа от потенциального максимума для подтверждения пивота
H Цвет максимумов — Цвет маркеров и линий для уровней по максимумам
srcL Источник минимумов — Источник данных для расчёта разворотов по минимумам
leftLenL Левый период минимумов — Количество баров слева от потенциального минимума для подтверждения пивота
rightLenL Правый период минимумов — Количество баров справа от потенциального минимума для подтверждения пивота
L Цвет минимумов — Цвет маркеров и линий для уровней по минимумам
showlevelhh Показать Higher High — Отображает уровень более высокого максимума; активен только при включённом переключателе Show HL Reversals
showlevellh Показать Lower High — Отображает уровень более низкого максимума; активен только при включённом переключателе Show HL Reversals
showlevelhl Показать Higher Low — Отображает уровень более высокого минимума; активен только при включённом переключателе Show HL Reversals
showlevelll Показать Lower Low — Отображает уровень более низкого минимума; активен только при включённом переключателе Show HL Reversals
showhh Маркер Higher High — Отображает маркер разворота более высокого максимума; активен только при включённом переключателе Show HL Reversals
showlh Маркер Lower High — Отображает маркер разворота более низкого максимума; активен только при включённом переключателе Show HL Reversals
showhl Маркер Higher Low — Отображает маркер разворота более высокого минимума; активен только при включённом переключателе Show HL Reversals
showll Маркер Lower Low — Отображает маркер разворота более низкого минимума; активен только при включённом переключателе Show HL Reversals
maxBarsBack Макс. баров для отображения — Ограничивает количество баров назад, на которых отображаются уровни и маркеры; 0 означает без ограничения
maxLvlLen Макс. длина уровней — Ограничивает максимальную длину отображаемых уровней поддержки и сопротивления в барах; 0 означает без ограничения
ShowChannel Показывать как канал — Отображает уровни максимумов и минимумов в виде канала вместо отдельных точек
showCL Показывать среднюю точку пивота — Отображает линию среднего значения между ближайшими пивотами максимума и минимума; активен только при включённом переключателе Show HL Reversals
ShowFB Показывать символы пробоя фрактала — Отображает графические символы при пробое уровней фрактальных разворотов; активен только при включённом переключателе Show HL Reversals
Получить полный код

Поиск по коду файла

indicator("<[SMC-FVG] + [HL Reversals]>", "<[SMC-FVG] + [HL Reversals]>" , overlay=true, max_boxes_count=500, max_labels_count=500)

showFVG = input.bool(true, "Show SMC-FVG", group = "Indicator Toggles")
showReversals = input.bool(true, "Show HL Reversals", group = "Indicator Toggles")

int fvg_length = input.int(20, "FVG Display Length", minval=1, maxval=100)
bool show_fvg = input.bool(true, "Show FVG", inline="MitigationOptions") and showFVG
bool show_until_mitigated = true // Always on, not shown in settings
bool strict_mode = input.bool(true, "Strict Mode", tooltip="Strict mitigation: FVG ends when candle touches FVG area", inline="MitigationOptions")
bool show_dashed_after_touch = input.bool(true, "Show dashed line after partial touch", tooltip="Convert to dashed lines upon partial FVG touch", inline="MitigationOptions")

string mtf_1 = input.timeframe("15", "MTF 1", inline="MTF1")
bool show_mtf_1 = input.bool(false, "Show", inline="MTF1") and showFVG
string mtf_2 = input.timeframe("60", "MTF 2", inline="MTF2") 
bool show_mtf_2 = input.bool(false, "Show", inline="MTF2") and showFVG
string mtf_3 = input.timeframe("240", "MTF 3", inline="MTF3")
bool show_mtf_3 = input.bool(false, "Show", inline="MTF3") and showFVG

color bullish_fvg_color = input.color(color.new(color.green, 80), "Bullish FVG Color")
color bearish_fvg_color = input.color(color.new(color.red, 80), "Bearish FVG Color")

color bullish_mtf_color = color.new(color.green, 85)
color bearish_mtf_color = color.new(color.red, 85)

detect_fvg() =>

    bool bullish_fvg = high[2] < low[0] and close[1] > open[1]
    float bullish_fvg_top = low[0]     // Top boundary = low of current candle
    float bullish_fvg_bottom = high[2] // Bottom boundary = high of left candle

    bool bearish_fvg = low[2] > high[0] and close[1] < open[1]
    float bearish_fvg_top = low[2]     // Top boundary = low of left candle
    float bearish_fvg_bottom = high[0] // Bottom boundary = high of current candle

    [bullish_fvg, bullish_fvg_top, bullish_fvg_bottom, bearish_fvg, bearish_fvg_top, bearish_fvg_bottom]

detect_mtf_fvg(tf) =>

    mtf_high_0 = request.security(syminfo.tickerid, tf, high, lookahead=barmerge.lookahead_off)
    mtf_low_0 = request.security(syminfo.tickerid, tf, low, lookahead=barmerge.lookahead_off)
    mtf_open_1 = request.security(syminfo.tickerid, tf, open[1], lookahead=barmerge.lookahead_off)
    mtf_close_1 = request.security(syminfo.tickerid, tf, close[1], lookahead=barmerge.lookahead_off)
    mtf_high_2 = request.security(syminfo.tickerid, tf, high[2], lookahead=barmerge.lookahead_off)
    mtf_low_2 = request.security(syminfo.tickerid, tf, low[2], lookahead=barmerge.lookahead_off)
    mtf_time_1 = request.security(syminfo.tickerid, tf, time[1], lookahead=barmerge.lookahead_off)

    bool mtf_bullish_fvg = mtf_high_2 < mtf_low_0 and mtf_close_1 > mtf_open_1
    float mtf_bullish_top = mtf_low_0
    float mtf_bullish_bottom = mtf_high_2

    bool mtf_bearish_fvg = mtf_low_2 > mtf_high_0 and mtf_close_1 < mtf_open_1
    float mtf_bearish_top = mtf_low_2
    float mtf_bearish_bottom = mtf_high_0

    [mtf_bullish_fvg, mtf_bullish_top, mtf_bullish_bottom, mtf_bearish_fvg, mtf_bearish_top, mtf_bearish_bottom, mtf_time_1]

var box[] bullish_fvg_boxes = array.new<box>(0)
var box[] bearish_fvg_boxes = array.new<box>(0)
var float[] bullish_fvg_tops = array.new<float>(0)
var float[] bullish_fvg_bottoms = array.new<float>(0)
var float[] bearish_fvg_tops = array.new<float>(0)
var float[] bearish_fvg_bottoms = array.new<float>(0)
var int[] bullish_fvg_indices = array.new<int>(0)
var int[] bearish_fvg_indices = array.new<int>(0)
var bool[] bullish_fvg_mitigated = array.new<bool>(0)
var bool[] bearish_fvg_mitigated = array.new<bool>(0)
var bool[] bullish_fvg_touched = array.new<bool>(0)
var bool[] bearish_fvg_touched = array.new<bool>(0)

var box[] mtf1_bullish_boxes = array.new<box>(0)
var box[] mtf1_bearish_boxes = array.new<box>(0)
var int[] mtf1_last_processed_time = array.new<int>(0) // Tracking last processed time
var float[] mtf1_bullish_tops = array.new<float>(0)
var float[] mtf1_bullish_bottoms = array.new<float>(0)
var float[] mtf1_bearish_tops = array.new<float>(0)
var float[] mtf1_bearish_bottoms = array.new<float>(0)
var bool[] mtf1_bullish_mitigated = array.new<bool>(0)
var bool[] mtf1_bearish_mitigated = array.new<bool>(0)
var bool[] mtf1_bullish_touched = array.new<bool>(0)
var bool[] mtf1_bearish_touched = array.new<bool>(0)

var box[] mtf2_bullish_boxes = array.new<box>(0)
var box[] mtf2_bearish_boxes = array.new<box>(0)
var int[] mtf2_last_processed_time = array.new<int>(0)
var float[] mtf2_bullish_tops = array.new<float>(0)
var float[] mtf2_bullish_bottoms = array.new<float>(0)
var float[] mtf2_bearish_tops = array.new<float>(0)
var float[] mtf2_bearish_bottoms = array.new<float>(0)
var bool[] mtf2_bullish_mitigated = array.new<bool>(0)
var bool[] mtf2_bearish_mitigated = array.new<bool>(0)
var bool[] mtf2_bullish_touched = array.new<bool>(0)
var bool[] mtf2_bearish_touched = array.new<bool>(0)

var box[] mtf3_bullish_boxes = array.new<box>(0)
var box[] mtf3_bearish_boxes = array.new<box>(0)
var int[] mtf3_last_processed_time = array.new<int>(0)
var float[] mtf3_bullish_tops = array.new<float>(0)
var float[] mtf3_bullish_bottoms = array.new<float>(0)
var float[] mtf3_bearish_tops = array.new<float>(0)
var float[] mtf3_bearish_bottoms = array.new<float>(0)
var bool[] mtf3_bullish_mitigated = array.new<bool>(0)
var bool[] mtf3_bearish_mitigated = array.new<bool>(0)
var bool[] mtf3_bullish_touched = array.new<bool>(0)
var bool[] mtf3_bearish_touched = array.new<bool>(0)

[bull_fvg, bull_top, bull_bottom, bear_fvg, bear_top, bear_bottom] = detect_fvg()

if show_fvg

    if bull_fvg
        box fvg_box = box.new(bar_index[1], bull_top, bar_index + fvg_length, bull_bottom,
                              border_color=color.new(color.green, 50),
                              bgcolor=bullish_fvg_color,
                              text="FVG",
                              text_color=color.green,
                              text_size=size.small)
        array.push(bullish_fvg_boxes, fvg_box)
        array.push(bullish_fvg_tops, bull_top)
        array.push(bullish_fvg_bottoms, bull_bottom)
        array.push(bullish_fvg_indices, bar_index[1])
        array.push(bullish_fvg_mitigated, false)
        array.push(bullish_fvg_touched, false)

        if array.size(bullish_fvg_boxes) > 50
            box.delete(array.shift(bullish_fvg_boxes))
            array.shift(bullish_fvg_tops)
            array.shift(bullish_fvg_bottoms)
            array.shift(bullish_fvg_indices)
            array.shift(bullish_fvg_mitigated)
            array.shift(bullish_fvg_touched)

    if bear_fvg
        box fvg_box = box.new(bar_index[1], bear_top, bar_index + fvg_length, bear_bottom,
                             border_color=color.new(color.red, 30),
                             bgcolor=bearish_fvg_color,
                             text="FVG",
                             text_color=color.red,
                             text_size=size.small)
        array.push(bearish_fvg_boxes, fvg_box)
        array.push(bearish_fvg_tops, bear_top)
        array.push(bearish_fvg_bottoms, bear_bottom)
        array.push(bearish_fvg_indices, bar_index[1])
        array.push(bearish_fvg_mitigated, false)
        array.push(bearish_fvg_touched, false)

        if array.size(bearish_fvg_boxes) > 50
            box.delete(array.shift(bearish_fvg_boxes))
            array.shift(bearish_fvg_tops)
            array.shift(bearish_fvg_bottoms)
            array.shift(bearish_fvg_indices)
            array.shift(bearish_fvg_mitigated)
            array.shift(bearish_fvg_touched)

if show_fvg

    if array.size(bullish_fvg_boxes) > 0
        for i = array.size(bullish_fvg_boxes) - 1 to 0 by 1
            float top = array.get(bullish_fvg_tops, i)
            float bottom = array.get(bullish_fvg_bottoms, i)
            int creation_index = array.get(bullish_fvg_indices, i)
            bool mitigated = array.get(bullish_fvg_mitigated, i)
            bool touched = array.get(bullish_fvg_touched, i)

            if not mitigated and bar_index > creation_index
                bool is_mitigated = false
                bool is_touched = false

                if high > bottom and low < top
                    is_touched := true

                if show_until_mitigated
                    if strict_mode

                        if is_touched
                            is_mitigated := true
                    else

                        if low <= bottom
                            is_mitigated := true

                if show_dashed_after_touch and is_touched and not touched
                    array.set(bullish_fvg_touched, i, true)

                    box.set_border_style(array.get(bullish_fvg_boxes, i), line.style_dashed)
                    box.set_bgcolor(array.get(bullish_fvg_boxes, i), color.new(color.green, 90))

                if is_mitigated
                    box.set_right(array.get(bullish_fvg_boxes, i), bar_index)
                    array.set(bullish_fvg_mitigated, i, true)
                else
                    box.set_right(array.get(bullish_fvg_boxes, i), bar_index + fvg_length)

    if array.size(bearish_fvg_boxes) > 0
        for i = array.size(bearish_fvg_boxes) - 1 to 0 by 1
            float top = array.get(bearish_fvg_tops, i)
            float bottom = array.get(bearish_fvg_bottoms, i)
            int creation_index = array.get(bearish_fvg_indices, i)
            bool mitigated = array.get(bearish_fvg_mitigated, i)
            bool touched = array.get(bearish_fvg_touched, i)

            if not mitigated and bar_index > creation_index
                bool is_mitigated = false
                bool is_touched = false

                if high > bottom and low < top
                    is_touched := true

                if show_until_mitigated
                    if strict_mode

                        if is_touched
                            is_mitigated := true
                    else

                        if high >= top
                            is_mitigated := true

                if show_dashed_after_touch and is_touched and not touched
                    array.set(bearish_fvg_touched, i, true)

                    box.set_border_style(array.get(bearish_fvg_boxes, i), line.style_dashed)
                    box.set_bgcolor(array.get(bearish_fvg_boxes, i), color.new(color.red, 90))

                if is_mitigated
                    box.set_right(array.get(bearish_fvg_boxes, i), bar_index)
                    array.set(bearish_fvg_mitigated, i, true)
                else
                    box.set_right(array.get(bearish_fvg_boxes, i), bar_index + fvg_length)

if show_mtf_1 and mtf_1 != "" and mtf_1 != timeframe.period

    current_mtf_time = request.security(syminfo.tickerid, mtf_1, time, lookahead=barmerge.lookahead_off)

    bool is_new_mtf_bar = false
    if array.size(mtf1_last_processed_time) == 0
        array.push(mtf1_last_processed_time, current_mtf_time)
        is_new_mtf_bar := true
    else
        last_time = array.get(mtf1_last_processed_time, 0)
        if current_mtf_time != last_time
            array.set(mtf1_last_processed_time, 0, current_mtf_time)
            is_new_mtf_bar := true

    if is_new_mtf_bar
        [mtf1_bull_fvg, mtf1_bull_top, mtf1_bull_bottom, mtf1_bear_fvg, mtf1_bear_top, mtf1_bear_bottom, mtf1_creation_time] = detect_mtf_fvg(mtf_1)

        if mtf1_bull_fvg and not na(mtf1_bull_top) and not na(mtf1_bull_bottom) and not na(mtf1_creation_time)

            mtf1_seconds = timeframe.in_seconds(mtf_1) * 1000
            end_time = mtf1_creation_time + mtf1_seconds * fvg_length

            box mtf_box = box.new(mtf1_creation_time, mtf1_bull_top, end_time, mtf1_bull_bottom,
                                 border_color=color.new(color.green, 30),
                                 bgcolor=bullish_mtf_color,
                                 text="FVG " + mtf_1,
                                 text_color=color.green,
                                 text_size=size.tiny,
                                 xloc=xloc.bar_time)
            array.push(mtf1_bullish_boxes, mtf_box)
            array.push(mtf1_bullish_tops, mtf1_bull_top)
            array.push(mtf1_bullish_bottoms, mtf1_bull_bottom)
            array.push(mtf1_bullish_mitigated, false)
            array.push(mtf1_bullish_touched, false)

        if mtf1_bear_fvg and not na(mtf1_bear_top) and not na(mtf1_bear_bottom) and not na(mtf1_creation_time)

            mtf1_seconds = timeframe.in_seconds(mtf_1) * 1000
            end_time = mtf1_creation_time + mtf1_seconds * fvg_length

            box mtf_box = box.new(mtf1_creation_time, mtf1_bear_top, end_time, mtf1_bear_bottom,
                                 border_color=color.new(color.red, 30),
                                 bgcolor=bearish_mtf_color,
                                 text="FVG " + mtf_1,
                                 text_color=color.red,
                                 text_size=size.tiny,
                                 xloc=xloc.bar_time)
            array.push(mtf1_bearish_boxes, mtf_box)
            array.push(mtf1_bearish_tops, mtf1_bear_top)
            array.push(mtf1_bearish_bottoms, mtf1_bear_bottom)
            array.push(mtf1_bearish_mitigated, false)
            array.push(mtf1_bearish_touched, false)
var table wm = table.new(position.bottom_right, 1, 1)
if barstate.isfirst
    table.cell(wm, 0, 0, "Telegram @SimpleForexTools", text_color = color.new(color.gray, 70), text_size = size.large)

if show_mtf_2 and mtf_2 != "" and mtf

Показано первые 50% кода (символов: 20685)

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
2 068,50₽ ≈ $25.28