ICT Fractal Model, HTF Candles, CISD & C2 Targets
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «indicator ict fractal model, htf candles, cisd & c2 targets for tradingview.pine» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
Данный индикатор отображает на графике модель ICT Fractal, построенную на основе свечей более высокого таймфрейма, формируемых из закрытых баров текущего графика. Индикатор отслеживает трёхсвечную модель: свеча C1, свеча C2, которая забирает максимум или минимум C1, и свеча C3, разворачивающаяся в противоположную сторону. Подтверждение модели осуществляется через изменение состояния поставки (CISD) на таймфрейме графика.
При обнаружении модели индикатор проецирует цели: T1 — уровень эквивалента C1 и T2 — противоположная сторона диапазона C1, а также уровень инвалидации за свечой C2. Все стадии, CISD, попадания в цели и отказы определяются только на закрытых барах, что обеспечивает отсутствие перерисовки.
Индикатор включает информационную панель с текущим состоянием модели и историей попаданий в цели для данного символа, а также набор условий для оповещений TradingView: на захват C1, CISD, подтверждение модели, попадание в цель и завершение или отказ модели. Доступны настраиваемые визуальные стили, включая неоновые свечи с эффектом свечения.
Настройки программы
| Настройка | Описание |
|---|---|
| htfMode | Выбор таймфрейма более высокого уровня: автоматическая пара по умолчанию или фиксированный выбор (15, 60, 240, D, W). |
| needClose | При включении модель считается действительной только при условии, что свеча C2 закрылась внутри диапазона свечи C1 после захвата. При выключении сам захват запускает модель. |
| showHtf | Включает или отключает отображение свечей более высокого таймфрейма справа на графике. |
| htfCount | Количество свечей более высокого таймфрейма, отображаемых справа на графике. |
| showSep | Включает или отключает разделители между свечами более высокого таймфрейма. |
| showTgt | Включает или отключает отображение линий целей и уровня инвалидации на графике. |
| keepN | Количество завершённых моделей, оставляемых на графике. Более старые модели удаляются, но статистика сохраняет все из них. |
| lblSize | Размер меток на графике: малый, нормальный или большой. |
| showTbl | Включает или отключает информационную панель с данными о модели и статистикой. |
| tblPos | Позиция информационной панели на графике: верхний правый, нижний правый, верхний левый или нижний левый угол. |
| tblSize | Размер текста в информационной панели: малый, нормальный или большой. |
| alSweep | Включает или отключает оповещение при захвате экстремума свечи C1 свечой C2. |
| alCisd | Включает или отключает оповещение при обнаружении изменения состояния поставки (CISD) в рамках модели. |
| alLive | Включает или отключает оповещение при подтверждении модели — когда свеча C2 закрылась внутри диапазона свечи C1. |
| alRes | Включает или отключает оповещения при попадании в цель, завершении или отказе модели. |
| candOn_ | Включает или отключает отображение неоновых свечей на графике. |
| candGlw | Включает или отключает эффект свечения свечей — тело рисуется в нескольких полосах, яркость которых возрастает к закрытию. |
Поиск по коду файла
indicator("ICT Fractal Model, HTF Candles, CISD & C2 Targets", "Fractal Model [",
overlay = true, max_lines_count = 300, max_labels_count = 300, max_boxes_count = 120)
gM = "Model"
htfMode = input.string("Auto", "Higher timeframe", options = ["Auto", "15", "60", "240", "D", "W"], group = gM,
tooltip = "Auto pairs the chart with the classic fractal timeframe: 1m → 15m, 5m → 1H, 15m → 4H, 1H → Daily, 4H → Weekly.")
needClose = input.bool(true, "Require C2 to close back inside C1", group = gM,
tooltip = "On: the model is valid only when candle 2 closes back inside candle 1's range after the sweep. Off: the sweep alone starts the model.")
gD = "Drawing"
showHtf = input.bool(true, "HTF candles on the right", group = gD)
htfCount = input.int(4, "HTF candles shown", minval = 2, maxval = 8, group = gD)
showSep = input.bool(true, "HTF candle separators", group = gD)
showTgt = input.bool(true, "Targets and invalidation", group = gD)
keepN = input.int(3, "Models drawn", minval = 1, maxval = 20, group = gD, tooltip = "Finished models older than this are removed from the chart. The track record keeps all of them.")
lblSize = input.string("Normal", "Label size", options = ["Small", "Normal", "Large"], group = gD)
gP = "Panel"
showTbl = input.bool(true, "Show panel", group = gP)
tblPos = input.string("Top Right", "Position", options = ["Top Right", "Bottom Right", "Top Left", "Bottom Left"], group = gP)
tblSize = input.string("Normal", "Text size", options = ["Small", "Normal", "Large"], group = gP)
gA = "Alerts"
alSweep = input.bool(true, "Alert: C1 swept", group = gA)
alCisd = input.bool(true, "Alert: CISD", group = gA)
alLive = input.bool(true, "Alert: model confirmed (C2 closed inside)", group = gA)
alRes = input.bool(true, "Alert: target hit / complete / failed", group = gA)
candOn_ = input.bool(true, "Neon candles", group = "Visuals")
candGlw = input.bool(true, "Glow candles", group = "Visuals", tooltip = "Each body is drawn in four bands that brighten towards the close, so the candle reads in the direction it moved. Off = flat translucent bodies.")
bgLum = 0.2126 * color.r(chart.bg_color) + 0.7152 * color.g(chart.bg_color) + 0.0722 * color.b(chart.bg_color)
isLight = bgLum > 128
UP = isLight ? #0097A7 : #00E5FF // aqua: bullish
DN = isLight ? #5B2BD9 : #7C4DFF // ultraviolet: bearish
TGT = isLight ? #C2189B : #FF4FD8 // neon pink: C1 range and targets
TGTX = isLight ? #A0127F : #FF9BEA // light pink for text
GREY = isLight ? #8A8F9C : #6B7080
TXT = isLight ? #1A1D24 : #E8EAF0
MUTE = isLight ? #5E6472 : #9AA0AE
PANEL = isLight ? #FFFFFF : #0B0E14
ROW = isLight ? #F1F3F7 : #141823
INK = #0B0E14
NONE = color.new(color.black, 100)
lSize = lblSize == "Small" ? size.small : lblSize == "Large" ? size.large : size.normal
tSize = tblSize == "Small" ? size.small : tblSize == "Large" ? size.large : size.normal
px(float v) =>
str.tostring(v, format.mintick)
pct(int a, int b) =>
b > 0 ? str.tostring(a * 100.0 / b, "0") + "%" : "—"
tfSec = timeframe.in_seconds()
autoHtf = tfSec <= 60 ? "15" : tfSec <= 300 ? "60" : tfSec <= 1800 ? "240" : tfSec <= 3600 ? "D" : tfSec <= 14400 ? "W" : "M"
htf = htfMode == "Auto" ? autoHtf : htfMode
htfOk = timeframe.in_seconds(htf) > tfSec
htfName = htf == "15" ? "15m" : htf == "60" ? "1H" : htf == "240" ? "4H" : htf == "D" ? "Daily" : htf == "W" ? "Weekly" : htf == "M" ? "Monthly" : htf
newH = timeframe.change(htf)
htfEnd = time_close(htf)
var float hO = na
var float hH = na
var float hL = na
var int hS = na
var array<float> cO = array.new_float()
var array<float> cH = array.new_float()
var array<float> cL = array.new_float()
var array<float> cC = array.new_float()
var array<int> cS = array.new_int()
var array<int> cE = array.new_int()
var array<line> seps = array.new_line()
htfClosed = false
if newH and not na(hO)
array.push(cO, hO)
array.push(cH, hH)
array.push(cL, hL)
array.push(cC, close[1])
array.push(cS, hS)
array.push(cE, bar_index - 1)
if array.size(cO) > 12
array.shift(cO)
array.shift(cH)
array.shift(cL)
array.shift(cC)
array.shift(cS)
array.shift(cE)
htfClosed := true
if newH or na(hO)
hO := open
hH := high
hL := low
hS := bar_index
if showSep and htfOk and newH
array.push(seps, line.new(bar_index, low, bar_index, high, extend = extend.both, color = color.new(GREY, 82), style = line.style_dotted))
if array.size(seps) > 40
line.delete(array.shift(seps))
else
hH := math.max(hH, high)
hL := math.min(hL, low)
var float dnRunOpen = na // open of the latest run of down-closing candles
var int dnRunBar = na
var float upRunOpen = na
var int upRunBar = na
if close < open and not (close[1] < open[1])
dnRunOpen := open
dnRunBar := bar_index
if close > open and not (close[1] > open[1])
upRunOpen := open
upRunBar := bar_index
var int stage = 0
var int dir = 0
var float c1H = na
var float c1L = na
var int c1S = na
var float swX = na // sweep extreme
var int swBar = na
var float cisdLvl = na
var int cisdLvlBar = na
var bool cisdOn = false
var bool cisdEarly = false // CISD printed before C2 closed — the only CISD that counts in the record
var int cisdBar = na
var float t1 = na
var float t2 = na
var float inv = na
var int liveBar = na
var int hitMax = 0
var box c1Bx = na
var label swLb = na
var line t1Ln = na
var line t2Ln = na
var line invLn = na
var label t1Lb = na
var label t2Lb = na
var label invLb = na
var array<int> rN = array.new_int(2, 0)
var array<int> rT1 = array.new_int(2, 0)
var array<int> rT2 = array.new_int(2, 0)
var array<int> rFail = array.new_int(2, 0)
var array<int> rCisd = array.new_int(2, 0) // models with a CISD
var array<int> rCisdT2 = array.new_int(2, 0) // ...that reached T2
var array<int> rBars = array.new_int(2, 0)
var int mid = 0
var array<line> gLn = array.new<line>()
var array<int> gLnI = array.new_int()
var array<label> gLb = array.new<label>()
var array<int> gLbI = array.new_int()
var array<box> gBx = array.new<box>()
var array<int> gBxI = array.new_int()
bump(array<int> a, int i, int add) =>
array.set(a, i, array.get(a, i) + add)
regLn(line o) =>
array.push(gLn, o)
array.push(gLnI, mid)
regLb(label o) =>
array.push(gLb, o)
array.push(gLbI, mid)
regBx(box o) =>
array.push(gBx, o)
array.push(gBxI, mid)
prune(int upTo) =>
while array.size(gLnI) > 0 and array.get(gLnI, 0) <= upTo
line.delete(array.shift(gLn))
array.shift(gLnI)
while array.size(gLbI) > 0 and array.get(gLbI, 0) <= upTo
label.delete(array.shift(gLb))
array.shift(gLbI)
while array.size(gBxI) > 0 and array.get(gBxI, 0) <= upTo
box.delete(array.shift(gBx))
array.shift(gBxI)
var array<line> tmpLn = array.new<line>()
var array<label> tmpLb = array.new<label>()
dropTmp() =>
for o in tmpLn
line.delete(o)
for o in tmpLb
label.delete(o)
array.clear(tmpLn)
array.clear(tmpLb)
keepTmp() =>
for o in tmpLn
regLn(o)
for o in tmpLb
regLb(o)
array.clear(tmpLn)
array.clear(tmpLb)
evSweep = false
evCisd = false
evLive = false
evHit = 0
evFrom = 0
evDone = false
evFail = false
evEnd = false
finish(int d, bool failed) =>
bump(rN, d, 1)
bump(rT1, d, hitMax >= 1 ? 1 : 0)
bump(rT2, d, hitMax >= 2 ? 1 : 0)
bump(rFail, d, failed ? 1 : 0)
bump(rCisd, d, cisdEarly ? 1 : 0)
bump(rCisdT2, d, cisdEarly and hitMax >= 2 ? 1 : 0)
bump(rBars, d, hitMax >= 2 ? bar_index - liveBar : 0)
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 barstate.isconfirmed and htfOk
if stage >= 1 and not cisdOn and not na(cisdLvl)
if dir == 1 ? close > cisdLvl : close < cisdLvl
cisdOn := true
cisdBar := bar_index
evCisd := true
cc = dir == 1 ? UP : DN
ln = line.new(cisdLvlBar, cisdLvl, bar_index, cisdLvl, color = cc, width = 2)
lb = label.new(bar_index, cisdLvl, "CISD", style = label.style_label_left, color = NONE, textcolor = cc, size = size.small)
if stage == 1
array.push(tmpLn, ln)
array.push(tmpLb, lb)
else
regLn(ln)
regLb(lb)
if stage == 2
evFrom := hitMax
failNow = dir == 1 ? low < inv : high > inv
if failNow
evFail := true
else
for k = 1 to 2
tk = k == 1 ? t1 : t2
if hitMax == k - 1 and (dir == 1 ? high >= tk : low <= tk)
hitMax := k
evHit := k
expired = htfClosed and bar_index > liveBar // C3 itself has closed
if evFail or hitMax == 2 or expired
finish(dir == 1 ? 0 : 1, evFail)
evDone := hitMax == 2
evEnd := true
resTxt = hitMax == 2 ? "✓ MODEL COMPLETE · " + str.tostring(bar_index - liveBar) + " bars" : evFail ? "✕ MODEL FAILED" + (hitMax > 0 ? " · T1 reached" : "") : "C3 CLOSED" + (hitMax > 0 ? " · T1 reached" : " · no target")
regLb(label.new(bar_index, dir == 1 ? high : low, resTxt, style = dir == 1 ? label.style_label_down : label.style_label_up,
color = hitMax == 2 ? TGT : color.new(GREY, 0), textcolor = hitMax == 2 ? color.white : INK, size = lSize))
box.set_right(c1Bx, bar_index)
prune(mid - keepN)
stage := 0
dir := 0
if stage == 1
if htfClosed
c2C = array.get(cC, array.size(cC) - 1)
c2H = array.get(cH, array.size(cH) - 1)
c2L = array.get(cL, array.size(cL) - 1)
bothSides = c2H > c1H and c2L < c1L
inside = c2C > c1L and c2C < c1H
if not bothSides and (inside or not needClose)
stage := 2
evLive := true
cisdEarly := cisdOn
mid += 1
liveBar := bar_index
hitMax := 0
t1 := (c1H + c1L) / 2
t2 := dir == 1 ? c1H : c1L
inv := swX
if dir == 1 ? c2C >= t1 : c2C <= t1
hitMax := 1
regBx(c1Bx)
regLb(swLb)
keepTmp()
if showTgt
t1Ln := line.new(bar_index, t1, bar_index + 1, t1, color = color.new(TGT, 30), width = 1, style = line.style_dotted)
t2Ln := line.new(bar_index, t2, bar_index + 1, t2, color = TGT, width = 2)
invLn := line.new(bar_index, inv, bar_index + 1, inv, color = color.new(dir == 1 ? DN : UP, 20), width = 1, style = line.style_dashed)
t1Lb := label.new(bar_index + 1, t1, (hitMax >= 1 ? "✓ " : "") + "T1 · C1 EQ " + px(t1), style = label.style_label_left, color = color.new(PANEL, 10), textcolor = TGTX, size = size.small)
t2Lb := label.new(bar_index + 1, t2, "T2 · C1 " + (dir == 1 ? "HIGH " : "LOW ") + px(t2), style = label.style_label_left, color = TGT, textcolor = color.white, size = size.small)
invLb := label.new(bar_index + 1, inv, "INVALID " + px(inv), style = label.style_label_left, color = color.new(PANEL, 10), textcolor = dir == 1 ? DN : UP, size = size.small)
regLn(t1Ln)
regLn(t2Ln)
regLn(invLn)
regLb(t1Lb)
regLb(t2Lb)
regLb(invLb)
label.set_text(swLb, (dir == 1 ? "C2 SWEPT C1 LOW" : "C2 SWEPT C1 HIGH") + (cisdOn ? " · CISD ✓" : ""))
else
box.delete(c1Bx)
label.delete(swLb)
dropTmp()
stage := 0
dir := 0
else
deeper = dir == 1 ? low < swX : high > swX
if deeper
swX := dir == 1 ? low : high
swBar := bar_index
cisdLvl := dir == 1 ? dnRunOpen : upRunOpen
cisdLvlBar := dir == 1 ? dnRunBar : upRunПоказано первые 50% кода (символов: 17912)