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

ICT HTF FVG + IFVG + CISD

indicator ict htf fvg + ltf ifvg + ltf cisd for tradingview.pine
Вы автор или правообладатель?

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

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

О программе

Данный индикатор для TradingView объединяет три инструмента визуального анализа: обнаружение фейр-вэлли-гэпов (FVG) на множестве таймфреймов, инвертированные FVG с определением отторжений и отслеживание уровней CISD. Программа отрисовывает на графике блоки, линии, графические отметки и таблицы, используя данные текущего и старших таймфреймов.

Первый модуль анализирует шесть настраиваемых таймфреймов (от 5 минут до 1 недели), выявляя зоны ценовых дисбалансов и отображая их в виде цветных блоков с возможностью обозначения смитигированных зон. Второй модуль работает с инвертированными FVG на выбранном интервале, определяя отторжения через пивоты и генерируя условия для оповещений. Третий модуль отслеживает активные уровни CISD, рисуя горизонтальные линии и подписи при смене направления, а также опционально выводя таблицу трендов по нескольким таймфреймам.

Индикатор полностью настраивается через параметры: цвета, размеры, стили отображения, количество отображаемых объектов и позиции элементов. Поддерживаются пользовательские оповещения для ключевых событий.

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

НастройкаОписание
htf_1 Временной интервал первого таймфрейма для обнаружения и отображения FVG (по умолчанию 5 минут).
htf_2 Временной интервал второго таймфрейма для обнаружения и отображения FVG (по умолчанию 15 минут).
htf_3 Временной интервал третьего таймфрейма для обнаружения и отображения FVG (по умолчанию 60 минут).
htf_4 Временной интервал четвёртого таймфрейма для обнаружения и отображения FVG (по умолчанию 4 часа).
htf_5 Временной интервал пятого таймфрейма для обнаружения и отображения FVG (по умолчанию 1 день).
htf_6 Временной интервал шестого таймфрейма для обнаружения и отображения FVG (по умолчанию 1 неделя).
tfo_show_rfvg Отображение регулярных FVG на графике в виде цветных блоков и линий.
tfo_show_ifvg Отображение инвертированных FVG на графике в виде цветных блоков и линий.
tfo_extend_right Продление блоков FVG и линий вправо от точки создания до текущего бара.
tfo_rfvg_color Цвет блоков и линий регулярных FVG.
tfo_ifvg_color Цвет блоков и линий инвертированных FVG.
tfo_tf Временной интервал для анализа инвертированных FVG и отторжений.
tfo_disp_x Множитель смещения для проверки минимального размера FVG перед отрисовкой. Большее значение требует более крупные гэпы.
tfo_disp_limit Максимальное количество FVG и инвертированных FVG, отображаемых одновременно на графике.
tfo_session Сессионный фильтр: FVG сохраняются и отображаются только в указанный торговый период.
tfo_ps Период пивотов для определения отторжений. Большее значение требует более выраженных свинг-точек.
tfo_show_rrj Отображение маркеров отторжений внутри регулярных FVG.
tfo_show_irj Отображение маркеров отторжений внутри инвертированных FVG.
tfo_show_brj Отображение графических маркеров отторжений, затрагивающих одновременно регулярные и инвертированные FVG.
tfo_rrj_color Цвет графических маркеров отторжений в регулярных FVG.
tfo_irj_color Цвет графических маркеров отторжений в инвертированных FVG.
tfo_brj_color Цвет графических маркеров отторжений в обоих типах FVG (регулярных и инвертированных).
cisd_magic_wand_toggle Отображение активного уровня CISD в виде горизонтальной линии на графике.
cisd_drama_filter Фильтр отображения сработавших уровней CISD: оба направления, только бычьи, только медвежьи или без отображения.
cisd_amnesia_mode Ограничивает количество отображаемых исторических линий CISD при активном состоянии.
cisd_short_term_memory Максимальное количество линий CISD, отображаемых на графике при активном режиме ограничения.
cisd_elasticity_factor Количество баров для продления линий CISD вправо от текущего момента. Ноль — без продления.
cisd_yell_at_me Отображение текстовых подписей при активном или сработавшем уровне CISD.
cisd_stage_direction Позиция подписи CISD относительно уровня: слева, по центру или справа.
cisd_girth_units Толщина линий CISD в пикселях.
cisd_scream_volume Размер подписей CISD: крошечный, малый, нормальный или большой.
cisd_hipster_font_toggle Шрифт для подписей и линий CISD: стандартный или моноширинный.
cisd_fashion_choice Стиль линий, рисуемых при срабатывании уровня CISD: сплошной, пунктирный или точечный.
cisd_shrek_mode Цвет линий и подписей для бычьего направления CISD.
cisd_blood_bath Цвет линий и подписей для медвежьего направления CISD.
cisd_paranoia_switch Включает отображение дополнительной отладочной линии порога цены CISD.
cisd_stalker_mode Отображение таблицы с трендами CISD по нескольким таймфреймам в последнем баре.
cisd_feng_shui Позиция таблицы трендов по таймфреймам на графике: верхний правый, средний правый, нижний правый или нижний левый угол.
cisd_eye_test Размер таблицы трендов по таймфреймам: крошечный, малый, нормальный или большой.
Получить полный код

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

indicator("ICT HTF FVG + IFVG + CISD", overlay=true, max_bars_back = 5000, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500)

type Settings 
    bool    CE_show
    string  CE_style
    color   CE_color
    bool    Border_show
    bool    mitigated_show
    string  mitigated_type
    color   mitigated_color_bull
    color   mitigated_color_bear
    bool    ltf_hide
    bool    label_show
    color   label_color
    color   label_bgcolor
    string  label_size
    int     padding
    int     buffer

type Imbalance_Settings
    bool    show
    string  htf
    color   color_bull
    color   color_bear
    int     max_count

type Imbalance
    int     open_time
    int     close_time
    float   open
    float   middle
    float   close
    bool    mitigated
    int     mitigated_time
    line    line_middle
    label   lbl
    box     box

type ImbalanceStructure
    Imbalance[]         imbalance
    Imbalance_Settings  settings

type Helper
    string name         = "Helper"

Settings_Group = "Global Settings [FVG]"

Settings settings = Settings.new()
Imbalance_Settings HTF_1_Settings = Imbalance_Settings.new()
Imbalance_Settings HTF_2_Settings = Imbalance_Settings.new()
Imbalance_Settings HTF_3_Settings = Imbalance_Settings.new()
Imbalance_Settings HTF_4_Settings = Imbalance_Settings.new()
Imbalance_Settings HTF_5_Settings = Imbalance_Settings.new()
Imbalance_Settings HTF_6_Settings = Imbalance_Settings.new()

string tooltip1 = "HTF FVG Settings"
string tooltip2 = "Mitigated FVG Settings"

HTF_1_Settings.show := input.bool(false, "", inline="htf1")
htf_1 = input.timeframe("5", "", inline="htf1")
HTF_1_Settings.htf := htf_1
HTF_1_Settings.color_bull := input.color(color.new(color.green,90), "", inline="htf1")
HTF_1_Settings.color_bear := input.color(color.new(color.blue,90), "", inline="htf1")
HTF_1_Settings.max_count := input.int(2, "", inline="htf1", tooltip = tooltip1)

HTF_2_Settings.show := input.bool(true, "15m FVG", inline="htf2")
htf_2 = input.timeframe("15", "", inline="htf2")
HTF_2_Settings.htf := htf_2
HTF_2_Settings.color_bull := input.color(color.new(color.green,80), "", inline="htf2")
HTF_2_Settings.color_bear := input.color(color.new(color.blue,80), "", inline="htf2")
HTF_2_Settings.max_count := input.int(2, "", inline="htf2", tooltip = tooltip1)

HTF_3_Settings.show := input.bool(false, "", inline="htf3")
htf_3 = input.timeframe("60", "", inline="htf3")
HTF_3_Settings.htf := htf_3
HTF_3_Settings.color_bull := input.color(color.new(color.green,90), "", inline="htf3")
HTF_3_Settings.color_bear := input.color(color.new(color.blue,90), "", inline="htf3")
HTF_3_Settings.max_count := input.int(2, "", inline="htf3", tooltip = tooltip1)

HTF_4_Settings.show := input.bool(false, "", inline="htf4")
htf_4 = input.timeframe("240", "", inline="htf4")
HTF_4_Settings.htf := htf_4
HTF_4_Settings.color_bull := input.color(color.new(color.green,90), "", inline="htf4")
HTF_4_Settings.color_bear := input.color(color.new(color.blue,90), "", inline="htf4")
HTF_4_Settings.max_count := input.int(2, "", inline="htf4", tooltip = tooltip1)

HTF_5_Settings.show := input.bool(false, "", inline="htf5")
htf_5 = input.timeframe("1D", "", inline="htf5")
HTF_5_Settings.htf := htf_5
HTF_5_Settings.color_bull := input.color(color.new(color.green,90), "", inline="htf5")
HTF_5_Settings.color_bear := input.color(color.new(color.blue,90), "", inline="htf5")
HTF_5_Settings.max_count := input.int(2, "", inline="htf5", tooltip = tooltip1)

HTF_6_Settings.show := input.bool(false, "", inline="htf6")
htf_6 = input.timeframe("1W", "", inline="htf6")
HTF_6_Settings.htf := htf_6
HTF_6_Settings.color_bull := input.color(color.new(color.green,90), "", inline="htf6")
HTF_6_Settings.color_bear := input.color(color.new(color.blue,90), "", inline="htf6")
HTF_6_Settings.max_count := input.int(2, "", inline="htf6", tooltip = tooltip1)

settings.ltf_hide := input.bool(true, "Hide Lower Timeframes")
settings.Border_show := input.bool(false, "Show Border", group=Settings_Group)
settings.mitigated_show := input.bool(false, "Show Mitigated", group=Settings_Group)
settings.mitigated_color_bull := input.color(color.new(color.gray,95), "", group=Settings_Group)
settings.mitigated_color_bear := input.color(color.new(color.gray,95), "", group=Settings_Group)
settings.mitigated_type := input.string('Wick filled', 'when', options = ['None', 'Wick filled', 'Body filled'], group=Settings_Group, tooltip=tooltip2)
settings.CE_show := input.bool(false, "Show C.E.", group=Settings_Group)
settings.CE_color := input.color(color.new(color.black,60), "", group=Settings_Group)
settings.CE_style := input.string('····', '', options = ['⎯⎯', '----', '····'], group=Settings_Group)
settings.label_show := input.bool(false, "Show Label", group=Settings_Group)
settings.label_color := input.color(color.new(color.black, 10), "", group=Settings_Group)
settings.label_bgcolor := input.color(color.new(color.white, 100), "", group=Settings_Group)
settings.label_size := input.string(size.small, "", [size.tiny, size.small, size.normal, size.large], group=Settings_Group)
settings.padding := input.int(4, "Distance from current candle", minval=0)
settings.buffer := input.int(6, "Spacing between timeframes", minval=0)

color color_transparent = #ffffff00
Helper helper = Helper.new()

var ImbalanceStructure FVG_1 = ImbalanceStructure.new()
var ImbalanceStructure FVG_2 = ImbalanceStructure.new()
var ImbalanceStructure FVG_3 = ImbalanceStructure.new()
var ImbalanceStructure FVG_4 = ImbalanceStructure.new()
var ImbalanceStructure FVG_5 = ImbalanceStructure.new()
var ImbalanceStructure FVG_6 = ImbalanceStructure.new()

var Imbalance[] FVGs_1 = array.new<Imbalance>()
var Imbalance[] FVGs_2 = array.new<Imbalance>()
var Imbalance[] FVGs_3 = array.new<Imbalance>()
var Imbalance[] FVGs_4 = array.new<Imbalance>()
var Imbalance[] FVGs_5 = array.new<Imbalance>()
var Imbalance[] FVGs_6 = array.new<Imbalance>()

FVG_1.imbalance := FVGs_1
FVG_1.settings := HTF_1_Settings
FVG_2.imbalance := FVGs_2
FVG_2.settings := HTF_2_Settings
FVG_3.imbalance := FVGs_3
FVG_3.settings := HTF_3_Settings
FVG_4.imbalance := FVGs_4
FVG_4.settings := HTF_4_Settings
FVG_5.imbalance := FVGs_5
FVG_5.settings := HTF_5_Settings
FVG_6.imbalance := FVGs_6
FVG_6.settings := HTF_6_Settings

var int TF_1 = 0
var int TF_2 = 0
var int TF_3 = 0
var int TF_4 = 0
var int TF_5 = 0
var int TF_6 = 0
var float daily = 0
var float monthly = 0

method LineStyle(Helper helper, string style) =>
    helper.name := style
    out = switch style
        '----' => line.style_dashed
        '····' => line.style_dotted
        => line.style_solid
    out

method Gethtftext(Helper helper, string htf) =>
    helper.name := htf
    formatted = htf
    seconds = timeframe.in_seconds(htf)
    if seconds < 60
        formatted := str.tostring(seconds) + "s"
    else if (seconds / 60) < 60
        formatted := str.tostring((seconds/60)) + "m"
    else if (seconds/60/60) < 24
        formatted := str.tostring((seconds/60/60)) + "H"
    formatted

method Validtimeframe(Helper helper, tf) =>
    helper.name := tf
    n1 = timeframe.in_seconds()
    n2 = timeframe.in_seconds(tf)
    n1 < n2

method ProximityRange(Helper helper, tf) =>
    helper.name := tf
    float range_high = 0
    float range_low = 0
    if timeframe.isseconds or timeframe.isminutes
        range_high := close + daily
        range_low := close - daily
    if timeframe.isdaily
        range_high := close + monthly*3
        range_low := close - monthly*3
    if timeframe.isweekly
        range_high := close + monthly*12
        range_low := close - monthly*12
    [range_low, range_high]

method AddZone(ImbalanceStructure IS, Imbalance imb, int step) =>
    bool visible = true
    if IS.settings.show
        int buffer = time+((time-time[1])*(settings.padding+1+(settings.buffer*(step-1))))
        if na(imb.box)
            imb.box := box.new(imb.open_time, imb.open, buffer, imb.close, settings.Border_show ? imb.open < imb.close ? color.new(IS.settings.color_bull, color.t(IS.settings.color_bull)/ 3) : color.new(IS.settings.color_bear, color.t(IS.settings.color_bear)/ 3) : color_transparent, settings.Border_show ? 1 : 0, bgcolor = imb.open < imb.close ? IS.settings.color_bull : IS.settings.color_bear, xloc=xloc.bar_time)
            if settings.label_show
                imb.lbl := label.new(buffer, imb.middle, text=helper.Gethtftext(IS.settings.htf), xloc=xloc.bar_time, textcolor=settings.label_color, style=label.style_label_left, color=settings.label_bgcolor, size = settings.label_size)
            if settings.CE_show
                imb.line_middle := line.new(imb.open_time, imb.middle, buffer, imb.middle, xloc=xloc.bar_time, style=helper.LineStyle(settings.CE_style), color=settings.CE_color)
        else
            box.set_right(imb.box, imb.mitigated ? imb.mitigated_time : buffer)
            box.set_bgcolor(imb.box, imb.open < imb.close ? imb.mitigated ? settings.mitigated_color_bull : IS.settings.color_bull : imb.mitigated ? settings.mitigated_color_bear : IS.settings.color_bear)
            box.set_border_color(imb.box, settings.Border_show ? imb.open < imb.close ? color.new(settings.mitigated_color_bull, color.t(settings.mitigated_color_bull)/ 3) : color.new(settings.mitigated_color_bear, color.t(settings.mitigated_color_bear)/ 3) : color_transparent)
            label.set_x(imb.lbl, imb.mitigated ? imb.mitigated_time : buffer)
            if settings.CE_show
                line.set_x2(imb.line_middle, imb.mitigated ? imb.mitigated_time : buffer)
        if imb.mitigated and not settings.mitigated_show
            if not na(imb.box)
                box.delete(imb.box)
                line.delete(imb.line_middle)
                label.delete(imb.lbl)
                visible := false
    visible

method AddImbalance(ImbalanceStructure IS, float o, float c, int o_time) =>
    Imbalance imb = Imbalance.new()
    imb.open_time := o_time
    imb.open := o
    imb.middle := (o+c)/2
    imb.close := c
    IS.imbalance.unshift(imb)
    if IS.imbalance.size() > 100
        temp = IS.imbalance.pop()
        if not na(temp.box)
            box.delete(temp.box)
            line.delete(temp.line_middle)
            label.delete(temp.lbl)
    IS

method CheckMitigated(ImbalanceStructure IS, o, h, l, c) =>
    if IS.imbalance.size() > 0
        for i = IS.imbalance.size() - 1 to 0
            imb = IS.imbalance.get(i)
            if not imb.mitigated
                switch settings.mitigated_type
                    "None" =>
                        imb.mitigated := false
                    'Wick filled' =>
                        imb.mitigated := imb.open <= imb.close ? low <= imb.open : high >= imb.open
                    'Body filled' =>
                        imb.mitigated := imb.open < imb.close ? math.min(o, c) <= imb.open : math.max(o, c) >= imb.open
                    'Wick filled half' =>
                        imb.mitigated := imb.open <= imb.close ? low <= imb.middle : high >= imb.middle
                    'Body filled half' =>
                        imb.mitigated := imb.open <= imb.close ? math.min(o, c) <= imb.middle : math.max(o, c) >= imb.middle
                if imb.mitigated
                    if not settings.mitigated_show
                        if not na(imb.box)
                            box.delete(imb.box)
                            line.delete(imb.line_middle)
                            label.delete(imb.lbl)
                        IS.imbalance.remove(i)
                    else
                        imb.mitigated_time := time
    IS

method AdjustMargins(ImbalanceStructure IS, int step) =>
    int count = 0
    if IS.imbalance.size() > 0
        int buffer = time+((time-time[1])*(settings.padding+1+(settings.buffer*(step-1))))
        [rl, rh] = helper.ProximityRange(IS.settings.htf)
        for i = 0 to IS.imbalance.size() - 1
            imb = IS.imbalance.get(i)
            if ((math.max(imb.open, imb.close) > rl) and (math.min(imb.open, imb.close) < rh)) and count < IS.settings.max_count
                if IS.AddZone(imb, step)
                    count := count+1
            else
                if not na(imb.box)
                    box.delete(imb.box)
                    label.delete(imb.lbl)
                    line.delete((imb.line_middle))
    IS

method FindImbalance(ImbalanceStructure IS, o, h, l, c, t, o1, h1, l1, c1, t1, o2, h2, l2, c2, t2) =>
    if IS.settings.show and (h < l2 or l > h2) 
        o = h < l2 ? l2 : h2
        c = h < l2 ? h : l
        if IS.imbalance.size() == 0 
            IS.AddImbalance(o, c, t2)
        else
            if IS.imbalance.first().open_time < t2
                IS.AddImbalance(o, c, t2)
    IS

method Process(ImbalanceStructure IS, float o, float h, float l, float c, int t, float o1, float h1, float l1, float c1, int t1, float o2, float h2, float l2, float c2, int t2) =>
    var int visible = 0
    if IS.settings.show
        if not settings.ltf_hide or (settings.ltf_hide and helper.Validtimeframe(IS.settings.htf))
            if IS.settings.show
                IS.FindImbalance(o, h, l, c, t, o1, h1, l1, c1, t1, o2, h2, l2, c2, t2)
                visible := 1
        IS.CheckMitigated(o, h, l, c)
    visible

daily := request.security(syminfo.tickerid, "1D", ta.atr(14))
monthly := request.security(syminfo.tickerid, "1M", ta.atr(14))

[o_1, h_1, l_1, c_1, t_1] = request.security(syminfo.tickerid, htf_1, [open[1], high[1], low[1], close[1], time[1]])
[o1_1, h1_1, l1_1, c1_1, t1_1] = request.security(syminfo.tickerid, htf_1, [open[2], high[2], low[2], close[2], time[2]])
[o2_1, h2_1, l2_1, c2_1, t2_1] = request.security(syminfo.tickerid, htf_1, [open[3], high[3], low[3], close[3], time[3]])
TF_1 := FVG_1.Process(o_1, h_1, l_1, c_1, t_1, o1_1, h1_1, l1_1, c1_1, t1_1, o2_1, h2_1, l2_1, c2_1, t2_1)
FVG_1.AdjustMargins(TF_1)

[o_2, h_2, l_2, c_2, t_2] = request.security(syminfo.tickerid, htf_2, [open[1], high[1], low[1], close[1], time[1]])
[o1_2, h1_2, l1_2, c1_2, t1_2] = request.security(syminfo.tickerid, htf_2, [open[2], high[2], low[2], close[2], time[2]])
[o2_2, h2_2, l2_2, c2_2, t2_2] = request.security(syminfo.tickerid, htf_2, [open[3], high[3], low[3], close[3], time[3]])
TF_2 := TF_1 + FVG_2.Process(o_2, h_2, l_2, c_2, t_2, o1_2, h1_2, l1_2, c1_2, t1_2, o2_2, h2_2, l2_2, c2_2, t2_2)
FVG_2.AdjustMargins(TF_2)

[o_3, h_3, l_3, c_3, t_3] = request.security(syminfo.tickerid, htf_3, [open[1], high[1], low[1], close[1], time[1]])
[o1_3, h1_3, l1_3, c1_3, t1_3] = request.security(syminfo.tickerid, htf_3, [open[2], high[2], low[2], close[2], time[2]])
[o2_3, h2_3, l2_3, c2_3, t2_3] = request.security(syminfo.tickerid, htf_3, [open[3], high[3], low[3], close[3], time[3]])
TF_3 := TF_2 + FVG_3.Process(o_3, h_3, l_3, c_3, t_3, o1_3, h1_3, l1_3, c1_3, t1_3, o2_3, h2_3, l2_3, c2_3, t2_3)
FVG_3.AdjustMargins(TF_3)

[o_4, h_4, l_4, c_4, t_4] = request.security(syminfo.tickerid, htf_4, [open[1], high[1], low[1], close[1], time[1]])
[o1_4, h1_4, l1_4, c1_4, t1_4] = request.security(syminfo.tickerid, htf_4, [open[2], high[2], low[2], close[2], time[2]])
[o2_4, h2_4, l2_4, c2_4, t2_4] = request.security(syminfo.tickerid, htf_4, [open[3], high[3], low[3], close[3], time[3]])
TF_4 := TF_3 + FVG_4.Process(o_4, h_4, l_4, c_4, t_4, o1_4, h1_4, l1_4, c1_4, t1_4, o2_4, h2_4, l2_4, c2_4, t2_4)
FVG_4.AdjustMargins(TF_4)

[o_5, h_5, l_5, c_5, t_5] = request.security(syminfo.tickerid, htf_5, [open[1], high[1], low[1], close[1], time[1]])
[o1_5, h1_5, l1_5, c1_5, t1_5] = request.security(syminfo.tickerid, htf_5, [open[2], high[2], low[2], close[2], time[2]])
[o2_5, h2_5, l2_5, c2_5, t2_5] = request.security(syminfo.tickerid, htf_5, [open[3], high[3], low[3], close[3], time[3]])
TF_5 := TF_4 + FVG_5.Process(o_5, h_5, l_5, c_5, t_5, o1_5, h1_5, l1_5, c1_5, t1_5, o2_5, h2_5, l2_5, c2_5, t2_5)
FVG_5.AdjustMargins(TF_5)

[o_6, h_6, l_6, c_6, t_6] = request.security(syminfo.tickerid, htf_6, [open[1], high[1], low[1], close[1], time[1]])
[o1_6, h1_6, l1_6, c1_6, t1_6] = request.security(syminfo.tickerid, htf_6, [open[2], high[2], low[2], close[2], time[2]])
[o2_6, h2_6, l2_6, c2_6, t2_6] = request.security(syminfo.tickerid, htf_6, [open[3], high[3], low[3], close[3], time[3]])
TF_6 := TF_5 + FVG_6.Process(o_6, h_6, l_6, c_6, t_6, o1_6, h1_6, l1_6, c1_6, t1_6, o2_6, h2_6, l2_6, c2_6, t2_6)
FVG_6.AdjustMargins(TF_6)
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)

var tfo_g_SET = "Settings [IFVG]"
tfo_show_rfvg = input.bool(false, "Show Regular FVG", inline = "RFVG", group = tfo_g_SET)
tfo_show_ifvg = input.bool(true, "Show Inverse FVG", inline = "IFVG", group = tfo_g_SET)
tfo_extend_right = input.bool(true, "Extend Boxes", group = tfo_g_SET)

tfo_rfvg_color = input.color(color.new(#2962ff, 60), "", inline = "RFVG", group = tfo_g_SET)
tfo_ifvg_color = input.color(color.new(#f23645, 60), "", inline = "IFVG", group = tfo_g_SET)

tfo_tf = input.timeframe("", "Timeframe [IFVG]", group = tfo_g_SET)
tfo_disp_x = input.int(3, "Displacement", 1, 10, tooltip = "Larger Displacement will require larger FVGs", group = tfo_g_SET)
tfo_disp_limit = input.int(2, "Display Limit", 1, 50, tooltip = "The maximum amount of FVGs and IFVGs to display", group = tfo_g_SET)

tfo_session = input.session("0000-0000", "Session [IFVG]", tooltip = "FVGs will only be saved if they are created within this time period", group = tfo_g_SET)

var tfo_g_RJ = "Rejections [IFVG]"
tfo_ps = input.int(1, "Rejection Strength", tooltip = "Larger values will require larger fractals/swing pivots to justify as rejections", group = tfo_g_RJ) 

tfo_show_rrj = input.bool(false, "Regular FVG", inline = "RRJ", tooltip = "Show rejections made within regular FVGs", group = tfo_g_RJ)
tfo_show_irj = input.bool(false, "Inverse FVG", inline = "IRJ", tooltip = "Show rejections made within inverse FVGs", group = tfo_g_RJ)
tfo_show_brj = input.bool(false, "Regular + Inverse FVG", inline = "BRJ", tooltip = "Show rejections made within both regular and inverse FVGs", group = tfo_g_RJ)

tfo_rrj_color = input.color(#2962ff, "", inline = "RRJ", group = tfo_g_RJ)
tfo_irj_color = input.color(#f23645, "", inline = "IRJ", group = tfo_g_RJ)
tfo_brj_color = input.color(color.black, "", inline = "BRJ", group = tfo_g_RJ)

tfo_t = not na(time(tfo_tf, tfo_session, "America/New_York"))

[tfo_o, tfo_h, tfo_l, tfo_c, tfo_ti] = request.security(syminfo.tickerid, tfo_tf, [open[1], high[1], low[1], close[1], time[1]], lookahead = barmerge.lookahead_on, gaps = barmerge.gaps_off)

var tfo_tf_o = array.new_float()
var tfo_tf_h = array.new_float()
var tfo_tf_l = array.new_float()
var tfo_tf_c = array.new_float()
var tfo_tf_time = array.new_int()
var tfo_tf_t = array.new_bool()

var tfo_reg_fvg = array.new_box()
var tfo_reg_fvg_ce = array.new_line()
var tfo_reg_fvg_side = array.new_string()

var tfo_inv_fvg = array.new_box()
var tfo_inv_fvg_ce = array.new_line()
var tfo_inv_fvg_side = array.new_string()

tfo_reg_rj_bear = false
tfo_reg_rj_bull = false
tfo_inv_rj_bear = false
tfo_inv_rj_bull = false

tfo_solid_color(color x) =>
    color.new(x, 0)

tfo_avg_over(float[] h_arr, float[] l_arr, int len) =>
    sum = 0.0
    for i = 0 to len
        sum += (h_arr.get(i) - l_arr.get(i))
    sum / len

var tfo_tf_new = false

if timeframe.change(tfo_tf) and timeframe.in_seconds(tfo_tf) >= timeframe.in_seconds(timeframe.period)
    tfo_tf_o.unshift(tfo_o)
    tfo_tf_h.unshift(tfo_h)
    tfo_tf_l.unshift(tfo_l)
    tfo_tf_c.unshift(tfo_c)
    tfo_tf_t.unshift(tfo_t[1])
    tfo_tf_time.unshift(tfo_ti)
    tfo_tf_new := true

    if tfo_tf_o.size() > 300
        tfo_tf_o.pop()
        tfo_tf_h.pop()
        tfo_tf_l.pop()
        tfo_tf_c.pop()
        tfo_tf_t.pop()
        tfo_tf_time.pop()

if not tfo_extend_right
    if tfo_reg_fvg.size() > 0
        for i = 0 to tfo_reg_fvg.size() - 1
            tfo_reg_fvg.get(i).set_right(time)
            tfo_reg_fvg_ce.get(i).set_x2(time)

    if tfo_inv_fvg.size() > 0
        for i = 0 to tfo_inv_fvg.size() - 1
            tfo_inv_fvg.get(i).set_right(time)
            tfo_inv_fvg_ce.get(i).set_x2(time)

if tfo_tf_o.size() > 20 and tfo_tf_new
    tfo_bull = tfo_tf_c.get(1) > tfo_tf_o.get(1)
    tfo_fvg = tfo_bull ? (tfo_tf_h.get(2) < tfo_tf_l.get(0) and tfo_tf_l.get(1) <= tfo_tf_h.get(2) and tfo_tf_h.get(1) >= tfo_tf_l.get(0)) : (tfo_tf_l.get(2) > tfo_tf_h.get(0) and tfo_tf_l.get(1) <= tfo_tf_h.get(0) and tfo_tf_l.get(2) <= tfo_tf_h.get(1))
    tfo_fvg_len = tfo_bull ? tfo_tf_l.get(0) - tfo_tf_h.get(2) : tfo_tf_l.get(2) - tfo_tf_h.get(0)
    tfo_atr_check = tfo_fvg_len > tfo_avg_over(tfo_tf_h, tfo_tf_l, 20) * tfo_disp_x / 10

    if tfo_tf_t.get(2) and tfo_fvg and tfo_atr_check
        tfo_top = tfo_bull ? tfo_tf_l.get(0) : tfo_tf_l.get(2)
   

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

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

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

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

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

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

Стоимость полного кода
3 413,50₽ ≈ $41.72