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

Premium_SUPER_Scalping Killer Algo

premium_super_scalping killer algo.pine

Похожие материалы по тегам

pro +.pineTradingView · 3 общих теговofada_gold_trader_v230.mq5MQL5 / MetaTrader 5 · 3 общих теговmulti strategy algo combined by enigma mode.pineTradingView · 3 общих теговmelona ob strategy 6th update (by 3dots).pineTradingView · 3 общих теговsmc+ict+indicators+scalping master.pineTradingView · 3 общих тегов2 to 1 strategy with signals.pineTradingView · 3 общих тегов
Вы автор или правообладатель?

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

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

О программе

Premium_SUPER_Scalping Killer Algo — это индикатор для TradingView (Pine Script v5), предназначенный для отображения различных технических уровней и торговых сигналов на графике. Основная функциональность включает отрисовку ежедневных и недельных CPR-уровней (Pivot, Support, Resistance, Top/Bottom of Range) с возможностью выбора отображения для сегодняшних, завтрашних и исторических данных.

Индикатор также реализует ряд классических технических инструментов: SuperTrend с сигналами покупки/продажи и метками, Parabolic SAR, RSI с цветовой индикацией баров, MACD-сигналальную линию, а также каналы (Bollinger / Donchian / Envelope) с выбором типа. Отображается VWAP и скользящиеся средние.

Дополнительно присутствуют модули обнаружения ордер-блоков на основе ROC, ZigZag с определением структурных пробоев рынка (Market Structure Break) с отрисовкой ордер-блоков и уровней, таблица ADX по нескольким таймфреймам, расхождение RSI с пивотами, профиль объёма (Volume Profile) с точкой контроля и гистограммой объёма, а также расчёт стандартных отклонений от цены расчёта (Settlement). Все элементы отображаются графически и сопровождаются настраиваемыми условиями оповещений.

Индикатор использует данные текущего и других таймфреймов через запросы безопасности, позволяет настраивать отображение каждого компонента индивидуально и поддерживает систему алертов TradingView для ключевых событий.

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

НастройкаОписание
showTomorrowCPR Отображать CPR завтра — Отображение CPR завтрашнего дня.
showHistoricalCPR Отображать исторические CPR — Отображение исторических CPR-уровней.
showWeeklyCPR Отображать недельные CPR — Отображение недельных CPR-уровней.
showR3wS3w Отображать недельные R3w и S3w — Отображение недельных R3w и S3w.
showR3S3 Отображать R3 и S3 — Отображение уровней R3 и S3.
showPDHL Отображать предыдущий High & Low — Отображение предыдущего максимума и минимума (PD High & Low).
showPDC Отображать предыдущее закрытие — Отображение предыдущего закрытия (PD Close).
PlotVWAP Отображать VWAP — Отображение линии VWAP на графике.
VWAPSource Источник VWAP — Источник данных для расчёта VWAP.
length Длина — Длина для расчёта.
mult Множитель ATR — Множитель ATR для SuperTrend.
src Источник SuperTrend — Источник данных для SuperTrend.
wicks Учитывать фитиль — Учитывать фитиль (High/Low) при расчёте SuperTrend.
showLabels Отображать метки SuperTrend — Отображение меток Buy/Sell SuperTrend.
highlightState Подсветка состояния SuperTrend — Подсветка состояния SuperTrend.
start2 Начальное значение PSAR — Начальное значение Parabolic SAR.
increment Инкремент PSAR — Инкремент Parabolic SAR.
maximum Максимум PSAR — Максимальное значение Parabolic SAR.
width1 Ширина точек PSAR — Ширина точек Parabolic SAR.
highlightStartPoints Подсветка начальных точек — Подсветка начальных точек Parabolic SAR.
showLabels1 Отображать метки PSAR — Отображение меток Buy/Sell Parabolic SAR.
highlightState1 Подсветка состояния PSAR — Подсветка состояния Parabolic SAR.
len Период ATR — Период ATR для SuperTrend.
len1 Уровень перекупленности — Уровень перекупленности RSI.
len2 Уровень перепроданности — Уровень перепроданности RSI.
len11 Очень высокая перекупленность — Очень высокий уровень перекупленности RSI.
len22 Очень низкая перепроданность — Очень низкий уровень перепроданности RSI.
fastLength Быстрая длина — Быстрая длина для MACD.
slowLength Медленная длина — Медленная длина для MACD.
signalLength Длина сигнальной линии — Длина сигнальной линии MACD.
lookback Отложенный цветовой период — Период цветового отложенного сигнала MACD (0 — отключено).
len10 Длина канала — Длина канала/период EMA для Bollinger.
channelType Тип канала — Тип канала: Bollinger, Donchian, Envelope или NONE.
channelLen Длина канала — Длина канала.
envPer Процент Envelope — Процент для расчёта Envelope.
amplitude Амплитуда — Амплитуда для индикатора Xtrend.
channelDeviation Отклонение канала — Отклонение канала для Xtrend.
showArrows Отображать стрелки — Отображение стрелок Xtrend.
showChannels Отображать каналы — Отображение каналов Xtrend.
_v Версия — Версия скрипта.
sens Чувствительность — Чувствительность для обнаружения ордер-блоков.
OBMitigationType Тип митигации ОБ — Тип митигации ордер-блоков: по закрытию или по свечи.
col_bullish Цвет границы бычьего ОБ — Цвет границы бычьего ордер-блока.
col_bullish_ob Цвет фона бычьего ОБ — Цвет фона бычьего ордер-блока.
col_bearish Цвет границы медвежьего ОБ — Цвет границы медвежьего ордер-блока.
col_bearish_ob Цвет фона медвежьего ОБ — Цвет фона медвежьего ордер-блока.
buy_alert Сигнал покупки — Включение оповещения при сигнале покупки.
sell_alert Сигнал продажи — Включение оповещения при сигнале продажи.
zigzag_len Длина ZigZag — Длина ZigZag.
show_zigzag Отображать ZigZag — Отображение ZigZag.
fib_factor Коэффициент Фибоначчи — Коэффициент Фибоначчи для подтверждения пробоя.
time_frame Таймфрейм — Таймфрейм для ZigZag и структурных уровней.
text_size Размер текста — Размер текста для ZigZag-меток.
bu_ob_color Цвет Bu-OB — Цвет бычьих ордер-блоков.
bu_ob_border_color Цвет границы Bu-OB — Цвет границы бычьих ордер-блоков.
bu_ob_text_color Цвет текста Bu-OB — Цвет текста бычьих ордер-блоков.
be_ob_color Цвет Be-OB — Цвет медвежьих ордер-блоков.
be_ob_border_color Цвет границы Be-OB — Цвет границы медвежьих ордер-блоков.
be_ob_text_color Цвет текста Be-OB — Цвет текста медвежьих ордер-блоков.
bu_bb_color Цвет Bu-BB — Цвет бычьих BB/MB.
bu_bb_border_color Цвет границы Bu-BB — Цвет границы бычьих BB/MB.
bu_bb_text_color Цвет текста Bu-BB — Цвет текста бычьих BB/MB.
be_bb_color Цвет Be-BB — Цвет медвежьих BB/MB.
be_bb_border_color Цвет границы Be-BB — Цвет границы медвежьих BB/MB.
be_bb_text_color Цвет текста Be-BB — Цвет текста медвежьих BB/MB.
adxlen Сглаживание ADX — Сглаживание ADX.
dilen Длина DI — Длина DI для расчёта ADX.
i_TriggerBGColor Фон триггерного времени — Цвет фона для триггерного времени.
i_TriggerTxtColor Текст триггерного времени — Цвет текста для триггерного времени.
i_TradingBGColor Фон торгового времени — Цвет фона для торгового времени.
i_TradingTxtColor Текст торгового времени — Цвет текста для торгового времени.
i_OtherBGColor Фон прочего времени — Цвет фона для прочего времени.
i_OtherTxtColor Текст прочего времени — Цвет текста для прочего времени.
i_decimal Десятичные знаки — Количество десятичных знаков в таблице ADX.
rb Правые бары для пивотов — Количество правых баров для пивотов RSI.
lb Левые бары для пивотов — Количество левых баров для пивотов RSI.
sph Источник пивотов для медвежьих расхождений — Источник пивотов для медвежьих расхождений.
spl Источник пивотов для бычьих расхождений — Источник пивотов для бычьих расхождений.
len15 Длина RSI — Длина RSI.
ob Перекупленность RSI — Уровень перекупленности RSI.
os Перепроданность RSI — Уровень перепроданности RSI.
showph Отображать пивот-хаи — Отображение пивот-хаев RSI.
showpl Отображать пивот-лоу — Отображение пивот-лоу RSI.
lvl Уровень отката для расхождений — Уровень отката для расхождения RSI.
volumeProfile Профиль объёма — Включение профиля объёма (Price by Volume).
lookbackLength Длина отката — Длина отката для профиля объёма.
profileLevels Количество строк — Количество строк в профиле объёма.
profileDisplay Режим отображения объёма — Режим отображения объёма: Up/Down или Total.
pointOfControl Отображать точку контроля — Отображение точки контроля (Point of Control) в профиле объёма.
bullBearStr Отображать силу бычьего/медвежьего объёма — Отображение силы бычьего/медвежьего объёма.
priceLevels Отображать ценовые уровни — Отображение ценовых уровней в профиле объёма.
profilePlacement Расположение профиля — Расположение профиля объёма: Right или Left.
profileWidth Ширина профиля — Ширина профиля объёма.
horizontalOffset Горизонтальное смещение — Горизонтальное смещение профиля объёма.
volumeHistogram Отображать гистограмму объёма — Отображение гистограммы объёма.
volumePlacement Расположение гистограммы — Расположение гистограммы объёма: Top или Bottom.
volumeMA Отображать MA объёма — Отображение скользящей средней объёма.
volumeMALength Длина MA объёма — Длина скользящей средней объёма.
vwcb Раскрашивать бары по объёму — Раскраска баров по объёму (Volume Weighted Colored Bars).
useDaily Использовать дневные данные для HV — Использовать дневные данные для расчёта HV (по умолчанию), иначе таймфрейм графика.
Получить полный код

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

indicator('Premium_SUPER_Scalping Killer Algo', shorttitle='Premium_SUPER_Scalping Killer Algo', overlay=true,max_lines_count=500, max_bars_back=2000, max_boxes_count=500)

showTomorrowCPR = input(title='Show tomorrow\'s CPR', defval=true)
showHistoricalCPR = input(title='Show historical CPR', defval=true)
showWeeklyCPR = input(title='Show Weekly CPR', defval=true)
showR3wS3w = input(title='Show R3w & S3w', defval=true)
showR3S3 = input(title='Show R3 & S3', defval=true)
showPDHL = input(title='Show previous day\'s High & Low', defval=true)
showPDC = input(title='Show previous day\'s Close', defval=true)

cprColor = #FF6EFF
rColor = color.red
sColor = color.green
cColor = #3eecd5
wcprcolor = color.white

lStyle = plot.style_circles
lTransp = 35

fTransp = 95

noOfHolidays = 12

IsHoliday(_date) =>
    iff_1 = _date == timestamp(2020, 12, 25, 09, 15) ? true : false
    iff_2 = _date == timestamp(2020, 11, 30, 09, 15) ? true : iff_1
    iff_3 = _date == timestamp(2020, 11, 16, 09, 15) ? true : iff_2
    iff_4 = _date == timestamp(2020, 10, 02, 09, 15) ? true : iff_3
    iff_5 = _date == timestamp(2020, 05, 25, 09, 15) ? true : iff_4
    iff_6 = _date == timestamp(2020, 05, 01, 09, 15) ? true : iff_5
    iff_7 = _date == timestamp(2020, 04, 14, 09, 15) ? true : iff_6
    iff_8 = _date == timestamp(2020, 04, 10, 09, 15) ? true : iff_7
    iff_9 = _date == timestamp(2020, 04, 06, 09, 15) ? true : iff_8
    iff_10 = _date == timestamp(2020, 04, 02, 09, 15) ? true : iff_9
    iff_11 = _date == timestamp(2020, 03, 10, 09, 15) ? true : iff_10
    _date == timestamp(2020, 02, 21, 09, 15) ? true : iff_11

IsWeekend(_date) =>
    dayofweek(_date) == 7 or dayofweek(_date) == 1

SkipWeekend(_date) =>
    _d = dayofweek(_date)
    _mul = _d == 6 ? 3 : _d == 7 ? 2 : 1

    _date + _mul * 86400000

GetNextWorkingDay(_date) =>
    _dt = SkipWeekend(_date)

    for i = 1 to noOfHolidays by 1
        if IsHoliday(_dt)
            _dt := SkipWeekend(_dt)
            continue
        else
            break

    _dt

y = year(timenow)
m = month(timenow)
d = dayofmonth(timenow)

start = timestamp(y, m, d, 09, 15)
end = start + 86400000

shouldPlotToday = timenow > start

tom_start = start
tom_end = end

if shouldPlotToday
    tom_start := GetNextWorkingDay(start)
    tom_end := tom_start + 86400000
    tom_end

getSeries(e, timeFrame) =>
    request.security(syminfo.tickerid, 'D', e, lookahead=barmerge.lookahead_on)
getwSeries(e, timeFrame) =>
    request.security(syminfo.tickerid, 'W', e, lookahead=barmerge.lookahead_on)

H = getSeries(high[1], 'D')
L = getSeries(low[1], 'D')
C = getSeries(close[1], 'D')

P = (H + L + C) / 3
TC = (H + L) / 2
BC = P - TC + P

R3 = H + 2 * (P - L)
R2 = P + H - L
R1 = P * 2 - L

S1 = P * 2 - H
S2 = P - (H - L)
S3 = L - 2 * (H - P)

Hw = getwSeries(high[1], 'W')
Lw = getwSeries(low[1], 'W')
Cw = getwSeries(close[1], 'W')

Pw = (Hw + Lw + Cw) / 3
TCw = (Hw + Lw) / 2
BCw = Pw - TCw + Pw

R3w = Hw + 2 * (Pw - Lw)
R2w = Pw + Hw - Lw
R1w = Pw * 2 - Lw

S1w = Pw * 2 - Hw
S2w = Pw - (Hw - Lw)
S3w = Lw - 2 * (Hw - Pw)

if not IsHoliday(start) and not IsWeekend(start) and shouldPlotToday
    if showR3S3
        _r3 = line.new(start, R3, end, R3, xloc.bar_time, color=color.new(rColor, lTransp), width=3)
        line.delete(_r3[1])
    _r2 = line.new(start, R2, end, R2, xloc.bar_time, color=color.new(rColor, lTransp), width=3)
    line.delete(_r2[1])
    _r1 = line.new(start, R1, end, R1, xloc.bar_time, color=color.new(rColor, lTransp), width=3)
    line.delete(_r1[1])

    _tc = line.new(start, TC, end, TC, xloc.bar_time, color=color.new(cprColor, lTransp))
    line.delete(_tc[1])
    _p = line.new(start, P, end, P, xloc.bar_time, color=color.new(cprColor, lTransp))
    line.delete(_p[1])
    _bc = line.new(start, BC, end, BC, xloc.bar_time, color=color.new(cprColor, lTransp))
    line.delete(_bc[1])

    _s1 = line.new(start, S1, end, S1, xloc.bar_time, color=color.new(sColor, lTransp), width=3)
    line.delete(_s1[1])
    _s2 = line.new(start, S2, end, S2, xloc.bar_time, color=color.new(sColor, lTransp), width=3)
    line.delete(_s2[1])
    if showR3S3
        _s3 = line.new(start, S3, end, S3, xloc.bar_time, color=color.new(sColor, lTransp), width=3)
        line.delete(_s3[1])
    if showPDHL
        _pdh = line.new(start, H, end, H, xloc.bar_time, color=color.new(rColor, 0), style=line.style_solid, width=3)
        line.delete(_pdh[1])
        _pdl = line.new(start, L, end, L, xloc.bar_time, color=color.new(sColor, 0), style=line.style_solid, width=3)
        line.delete(_pdl[1])
    if showPDC
        _pdc = line.new(start, C, end, C, xloc.bar_time, color=color.new(cColor, 0), style=line.style_solid, width=3)
        line.delete(_pdc[1])

if not IsHoliday(start) and not IsWeekend(start) and shouldPlotToday
    if showR3S3
        l_R3 = label.new(start, R3, text='R3', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
        label.delete(l_R3[1])
    l_R2 = label.new(start, R2, text='R2', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
    label.delete(l_R2[1])
    l_R1 = label.new(start, R1, text='R1', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
    label.delete(l_R1[1])

    l_tc = label.new(start, TC, text='TC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
    label.delete(l_tc[1])
    l_p = label.new(start, P, text='P', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
    label.delete(l_p[1])
    l_bc = label.new(start, BC, text='BC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
    label.delete(l_bc[1])

    l_s1 = label.new(start, S1, text='S1', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
    label.delete(l_s1[1])
    l_s2 = label.new(start, S2, text='S2', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
    label.delete(l_s2[1])
    if showR3S3
        l_s3 = label.new(start, S3, text='S3', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
        label.delete(l_s3[1])
    if showPDHL
        l_pdh = label.new(start, H, text='PD High', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
        label.delete(l_pdh[1])
        l_pdl = label.new(start, L, text='PD Low', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
        label.delete(l_pdl[1])
    if showPDC
        l_pdc = label.new(start, C, text='PD Close', xloc=xloc.bar_time, textcolor=cColor, style=label.style_none)
        label.delete(l_pdc[1])

if not IsHoliday(start) and not IsWeekend(start) and showWeeklyCPR
    if showR3wS3w
        _r3w = line.new(start, R3w, end, R3w, xloc.bar_time, color=color.new(rColor, lTransp))
        line.delete(_r3w[1])
    _r2w = line.new(start, R2w, end, R2w, xloc.bar_time, color=color.new(rColor, lTransp))
    line.delete(_r2w[1])
    _r1w = line.new(start, R1w, end, R1w, xloc.bar_time, color=color.new(rColor, lTransp))
    line.delete(_r1w[1])

    _TCw = line.new(start, TCw, end, TCw, xloc.bar_time, color=color.blue, style=line.style_solid, width=3)
    line.delete(_TCw[1])
    _Pw = line.new(start, Pw, end, Pw, xloc.bar_time, color=color.blue, style=line.style_solid, width=3)
    line.delete(_Pw[1])
    _BCw = line.new(start, BCw, end, BCw, xloc.bar_time, color=color.blue, style=line.style_solid, width=3)
    line.delete(_BCw[1])

    _s1w = line.new(start, S1w, end, S1w, xloc.bar_time, color=color.new(sColor, lTransp))
    line.delete(_s1w[1])

    if showR3wS3w
        _s3w = line.new(start, S3w, end, S3w, xloc.bar_time, color=color.new(sColor, lTransp))
        line.delete(_s3w[1])

tH = getSeries(high, 'D')
tL = getSeries(low, 'D')
tC = getSeries(close, 'D')

tP = (tH + tL + tC) / 3
tTC = (tH + tL) / 2
tBC = tP - tTC + tP

tR3 = tH + 2 * (tP - tL)
tR2 = tP + tH - tL
tR1 = tP * 2 - tL

tS1 = tP * 2 - tH
tS2 = tP - (tH - tL)
tS3 = tL - 2 * (tH - tP)

if showTomorrowCPR
    if showR3S3
        _t_r3 = line.new(tom_start, tR3, tom_end, tR3, xloc.bar_time, color=color.new(rColor, lTransp))
        line.delete(_t_r3[1])
    _t_r2 = line.new(tom_start, tR2, tom_end, tR2, xloc.bar_time, color=color.new(rColor, lTransp))
    line.delete(_t_r2[1])
    _t_r1 = line.new(tom_start, tR1, tom_end, tR1, xloc.bar_time, color=color.new(rColor, lTransp))
    line.delete(_t_r1[1])

    _t_tc = line.new(tom_start, tTC, tom_end, tTC, xloc.bar_time, color=color.new(cprColor, lTransp))
    line.delete(_t_tc[1])
    _t_p = line.new(tom_start, tP, tom_end, tP, xloc.bar_time, color=color.new(cprColor, lTransp))
    line.delete(_t_p[1])
    _t_bc = line.new(tom_start, tBC, tom_end, tBC, xloc.bar_time, color=color.new(cprColor, lTransp))
    line.delete(_t_bc[1])

    _t_s1 = line.new(tom_start, tS1, tom_end, tS1, xloc.bar_time, color=color.new(sColor, lTransp))
    line.delete(_t_s1[1])
    _t_s2 = line.new(tom_start, tS2, tom_end, tS2, xloc.bar_time, color=color.new(sColor, lTransp))
    line.delete(_t_s2[1])
    if showR3S3
        _t_s3 = line.new(tom_start, tS3, tom_end, tS3, xloc.bar_time, color=color.new(sColor, lTransp))
        line.delete(_t_s3[1])
    if showPDHL
        _pdth = line.new(tom_start, tH, tom_end, tH, xloc.bar_time, color=color.new(rColor, 0), style=line.style_solid, width=3)
        line.delete(_pdth[1])
        _pdtl = line.new(tom_start, tL, tom_end, tL, xloc.bar_time, color=color.new(sColor, 0), style=line.style_solid, width=3)
        line.delete(_pdtl[1])
    if showPDC
        _pdtc = line.new(tom_start, tC, tom_end, tC, xloc.bar_time, color=color.new(cColor, 0), style=line.style_solid, width=3)
        line.delete(_pdtc[1])

if showTomorrowCPR
    if showR3S3
        l_t_r3 = label.new(tom_start, tR3, text='R3', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
        label.delete(l_t_r3[1])
    l_t_r2 = label.new(tom_start, tR2, text='R2', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
    label.delete(l_t_r2[1])
    l_t_r1 = label.new(tom_start, tR1, text='R1', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
    label.delete(l_t_r1[1])

    l_t_tc = label.new(tom_start, tTC, text='TC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
    label.delete(l_t_tc[1])
    l_t_p = label.new(tom_start, tP, text='P', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
    label.delete(l_t_p[1])
    l_t_bc = label.new(tom_start, tBC, text='BC', xloc=xloc.bar_time, textcolor=cprColor, style=label.style_none)
    label.delete(l_t_bc[1])

    l_t_s1 = label.new(tom_start, tS1, text='S1', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
    label.delete(l_t_s1[1])
    l_t_s2 = label.new(tom_start, tS2, text='S2', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
    label.delete(l_t_s2[1])
    if showR3S3
        l_t_s3 = label.new(tom_start, tS3, text='S3', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
        label.delete(l_t_s3[1])
    if showPDHL
        l_pdth = label.new(tom_start, tH, text='PD High', xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
        label.delete(l_pdth[1])
        l_pdtl = label.new(tom_start, tL, text='PD Low', xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
        label.delete(l_pdtl[1])
    if showPDC
        l_pdtc = label.new(tom_start, tC, text='PD Close', xloc=xloc.bar_time, textcolor=cColor, style=label.style_none)
        label.delete(l_pdtc[1])

p_r3 = plot(showHistoricalCPR ? showR3S3 ? R3 : na : na, title=' R3', color=rColor, style=lStyle, transp=lTransp)
p_r2 = plot(showHistoricalCPR ? R2 : na, title=' R2', color=rColor, style=lStyle, transp=lTransp)
p_r1 = plot(showHistoricalCPR ? R1 : na, title=' R1', color=rColor, style=lStyle, transp=lTransp)

p_cprTC = plot(showHistoricalCPR ? TC : na, title=' TC', color=cprColor, style=lStyle, transp=lTransp)
p_cprP = plot(showHistoricalCPR ? P : na, title=' P', color=cprColor, style=lStyle, transp=lTransp)
p_cprBC = plot(showHistoricalCPR ? BC : na, title=' BC', color=cprColor, style=lStyle, transp=lTransp)

s1 = plot(showHistoricalCPR ? S1 : na, title=' S1', color=sColor, style=lStyle, transp=lTransp)
s2 = plot(showHistoricalCPR ? S2 : na, title=' S2', color=sColor, style=lStyle, transp=lTransp)
s3 = plot(showHistoricalCPR ? showR3S3 ? S3 : na : na, title=' S3', color=sColor, style=lStyle, transp=lTransp)

fill(p_cprTC, p_cprBC, color=color.blue, transp=fTransp)

Little = ta.wma(close, 9)
short = ta.ema(close, 21)
middle = ta.ema(close, 89)
longest = ta.ema(close, 175)

plot(middle, color=color.new(color.yellow, 0), linewidth=3)

PlotVWAP = input(title='Plot VWAP?', defval=true)
VWAPSource = input(title='VWAP Source', defval=hlc3)
VWAPrice = ta.vwap(VWAPSource)
plot(PlotVWAP ? VWAPrice : na, color=color.new(color.white, 0), title='VWAP', linewidth=2)

length = input(title='ATR Period', defval=10)
mult = input.float(title='ATR Multiplier', step=0.1, defval=2.2)
src = input(title='Source', defval=hlc3)
wicks = input(title='Take Wicks into Account ?', defval=true)
showLabels = input(title='Show Buy/Sell Labels ?', defval=true)
highlightState = input(title='Highlight State ?', defval=true)

atr = mult * ta.atr(length)

highPrice = wicks ? high : close
lowPrice = wicks ? low : close
doji4price = open == close and open == low and open == high

longStop = src - atr
longStopPrev = nz(longStop[1], longStop)

if longStop > 0
    if doji4price
        longStop := longStopPrev
        longStop
    else
        longStop := lowPrice[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop
        longStop
else
    longStop := longStopPrev
    longStop

shortStop = src + atr
shortStopPrev = nz(shortStop[1], shortStop)

if shortStop > 0
    if doji4price
        shortStop := shortStopPrev
        shortStop
    else
        shortStop := highPrice[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
        shortStop
else
    shortStop := shortStopPrev
    shortStop

var int dir = 1
dir := dir == -1 and highPrice > shortStopPrev ? 1 : dir == 1 and lowPrice < longStopPrev ? -1 : dir

var color longColor = color.green
var color shortColor = color.red

buySignal = dir == 1 and dir[1] == -1
plotshape(buySignal ? longStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(longColor, 0))
plotshape(buySignal and showLabels ? longStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=color.new(color.white, 0))

sellSignal = dir == -1 and dir[1] == 1
plotshape(sellSignal ? shortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(shortColor, 0))
plotshape(sellSignal and showLabels ? shortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=color.new(color.white, 0))

midPricePlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false)

changeCond = dir != dir[1]
alertcondition(changeCond, title='Alert: SuperTrend Direction Change', message='SuperTrend has changed direction!\nSymbol: {{exchange}}:{{ticker}}\nPrice: {{close}}')
alertcondition(buySignal, title='Alert: SuperTrend Buy', message='SuperTrend Buy!\nSymbol: {{exchange}}:{{ticker}}\nPrice: {{close}}')
alertcondition(sellSignal, title='Alert: SuperTrend Sell', message='SuperTrend Sell!\nSymbol: {{exchange}}:{{ticker}}\nPrice: {{close}}')

start2 = input.float(title='Start', step=0.001, defval=0.02)
increment = input.float(title='Increment', step=0.001, defval=0.02)
maximum = input.float(title='Maximum', step=0.01, defval=0.2)
width1 = input.int(title='Point Width', minval=1, defval=2)
highlightStartPoints = input(title='Highlight Start Points ?', defval=true)
showLabels1 = input(title='Show Buy/Sell Labels ?', defval=true)
highlightState1 = input(title='Highlight State ?', defval=true)

psar = ta.sar(start2, increment, maximum)
dir1 = psar < close ? 1 : -1

psarColor = dir1 == 1 ? #33fb06 : #fd0202

var color longColor1 = color.green
var color shortColor1 = color.red

buySignal1 = dir1 == 1 and dir1[1] == -1

sellSignal1 = dir1 == -1 and dir1[1] == 1

midPricePlot1 = plot(ohlc4, title='', display=display.none)

changeCond1 = dir1 != dir1[1]
alertcondition(changeCond1, title='Alert: PSAR Direction Change', message='PSAR has changed direction!')
alertcondition(buySignal1, title='Alert: PSAR Long', message='PSAR Long')
alertcondition(sellSignal1, title='Alert: PSAR Short', message='PSAR Sell')

src5 = close
len = input.int(14, minval=1, title='Length')

src1 = close
len1 = input.int(53, minval=1, title='Overbought')
src2 = close
len2 = input.int(47, minval=1, title='Oversold')
src3 = close
len11 = input.int(80, minval=1, title='Very Overbought')
src4 = close
len22 = input.int(25, minval=1, title='Very Oversold')

up = ta.rma(math.max(ta.change(src5), 0), len)
down = ta.rma(-math.min(ta.change(src5), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)

isBought() =>
    rsi > len1 and rsi < len11
isSold() =>
    rsi < len2 and rsi > len22
isVeryBought() =>
    rsi > len11 and rsi > len1
isVerySold() =>
    rsi < len22 and rsi < len2

barcolor(isBought() ? color.rgb(4, 247, 13) : isSold() ? color.rgb(246, 7, 7) : isVeryBought() ? color.rgb(255, 255, 255) : isVerySold() ? color.rgb(252, 228, 7) : na)

fastLength = input.int(12, minval=1, title='Fast Length')
slowLength = input.int(26, minval=1, title='Slow Length')
fastMA = ta.ema(src, fastLength)
slowMA = ta.ema(src, slowLength)
macd = fastMA - slowMA

signalLength = input.int(9, minval=1, title='Signal Length')
signal = ta.ema(macd, signalLength)
lookback = input.int(1, minval=0, title='Color Lookback (0 to disable)')
signalColor = lookback == 0 ? #009933 : ta.rising(signal, lookback) ? #5cd65c : ta.falling(signal, lookback) ? #ff3333 : #ff3333
plotchar(signal, char='¦', title='Signal', color=signalColor, location=location.bottom, size=size.tiny, transp=0)

len10 = input(20)
channelType = input.string(defval='Bollinger', title='Channel Type', options=['NONE', 'Donchian', 'Bollinger', 'Envelope'])
channelLen = input.int(14, minval=1, title='Channel Length')
envPer = input.float(4, title='Envelope %', minval=0) / 100

getChannels(src, len10) =>
    if channelType == 'Bollinger'
        ma = ta.ema(src, len10)
        dev = ta.stdev(src, len10)
        bbUp = ma + 2 * dev
        bbDown = ma - 2 * dev
        [bbUp, bbDown]
    else
        if channelType == 'Donchian'
            donUp = ta.highest(high[1], len10)
            donDown = ta.lowest(low[1], len10)
            [donUp, donDown]
        else
            if channelType == 'Envelope'
                ma = ta.ema(src, len10)
                envUp = ma * (1 + envPer)
                envDown = ma * (1 - envPer)
                [envUp, envDown]
            else
                [na, na]

[upperchannel, lowerchannel] = getChannels(src, len10)

amplitude = input(title='Amplitude', defval=2)
channelDeviation = input(title='Channel Deviation', defval=2)
showArrows = input(title='Show Arrows', defval=true)
showChannels = input(title='Show Channels', defval=true)

var int trend = 0
var int nextTrend = 0
var float maxLowPrice = nz(low[1], low)
var float minHighPrice = nz(high[1], high)

var float up1 = 0.0
var float down1 = 0.0
float atrHigh = 0.0
float atrLow = 0.0
float arrowUp = na
float arrowDown = na

atr2 = ta.atr(100) / 2
dev = channelDeviation * atr2

highPrice1 = high[math.abs(ta.highestbars(amplitude))]
lowPrice1 = low[math.abs(ta.lowestbars(amplitude))]
highma = ta.sma(high, amplitude)
lowma = ta.sma(low, amplitude)

if nextTrend == 1
    maxLowPrice := math.max(lowPrice1, maxLowPrice)

    if highma < maxLowPrice and close < nz(low[1], low)
        trend := 1
        nextTrend := 0
        minHighPrice := highPrice1
        minHighPrice
else
    minHighPrice := math.min(highPrice1, minHighPrice)

    if lowma > minHighPrice and close > nz(high[1], high)
        trend := 0
        nextTrend := 1
        maxLowPrice := lowPrice1
        maxLowPrice

if trend == 0
    if not na(trend[1]) and trend[1] != 0
        up1 := na(down1[1]) ? down1 : down1[1]
        arrowUp := up - atr2
        arrowUp
    else
        up1 := na(up1[1]) ? maxLowPrice : math.max(maxLowPrice, up1[1])
        up1
    atrHigh := up1 + dev
    atrLow := up1 - dev
    atrLow
else
    if not na(trend[1]) and trend[1] != 1
        down1 := na(up1[1]) ? up1 : up1[1]
        arrowDown := down1 + atr2
        arrowDown
    else
        down1 := na(down1[1]) ? minHighPrice : math.min(minHighPrice, down1[1])
        down1
    atrHigh := down1 + dev
    atrLow := down1 - dev
    atrLow

ht = trend == 0 ? up1 : down1

var color buyColor = color.rgb(59, 251, 6)
var color sellColor = color.red

htColor = trend == 0 ? buyColor : sellColor
htPlot = plot(ht, title='ultra', linewidth=2, color=htColor)

buySignal2 = not na(arrowUp) and trend == 0 and trend[1] == 1
sellSignal2 = not na(arrowDown) and trend == 1 and trend[1] == 0

alertcondition(buySignal2, title='Alert: ultra Buy', message='ultra Buy')
alertcondition(sellSignal2, title='Alert: ultra Sell', message='ultra Sell')

max_boxes_count=20

_v = input.string("1.0.2", title="Version", options=["1.0.2"], group="Sonarlab.io", tooltip="This is a free script based on our premium Smart Money Concepts (SMC) indicator." )
sens = input.int(28, minval=1, title='Sensitivity', group='Order Block', tooltip='Lower the sensitivity to show more order blocks. A higher sensitivity will show less order blocks.')
sens /= 100

OBMitigationType = input.string("Close", title="OB Mitigation Type", options=["Close", "Wick"], group="Order Block", tooltip="Choose how Order Blocks are mitigated")
OBBullMitigation = OBMitigationType=="Close" ? close[1] : low
OBBearMitigation = OBMitigationType=="Close" ? close[1] : high

col_bullish = input.color(#5db49e, title="Bullish OB Border", inline="a", group="Order Block")
col_bullish_ob = input.color(color.new(#64C4AC, 85), title="Background", inline="a", group="Order Block")

col_bearish = input.color(#4760bb, title="Bearish OB Border", inline="b", group="Order Block")
col_bearish_ob = input.color(color.new(#506CD3, 85), title="Background", inline="b", group="Order Block")

buy_alert = input.bool(title='Buy Signal', defval=true, group='Alerts', tooltip='An alert will be sent when price goes below the top of a bullish order block.')
sell_alert = input.bool(title='Sell Signal', defval=true, group='Alerts', tooltip='An alert will be sent when price goes above the bottom of a bearish order block.')

bool ob_created = false
bool ob_created_bull = false
var int cross_index = na

var box drawlongBox = na
var longBoxes = array.new_box()
var box drawShortBox = na
var shortBoxes = array.new_box()

pc = (open - open[4]) / open[4] * 100

if ta.crossunder(pc, -sens)
    ob_created := true
    cross_index := bar_index
    cross_index

if ta.crossover(pc, sens)
    ob_created_bull := true
    cross_index := bar_index
    cross_index

if ob_created and cross_index - cross_index[1] > 5
    float last_green = 0
    float highest = 0

    for i = 4 to 15 by 1
        if close[i] > open[i]
            last_green := i
            break

    drawShortBox := box.new(left=bar_index[last_green], top=high[last_green], bottom=low[last_green], right=bar_index[last_green], bgcolor=col_bearish_ob, border_color=col_bearish, extend=extend.right)
    array.push(shortBoxes, drawShortBox)

if ob_created_bull and cross_index - cross_index[1] > 5
    float last_red = 0
    float highest = 0

    for i = 4 to 15 by 1
        if close[i] < open[i]
            last_red := i
            break

    drawlongBox := box.new(left=bar_index[last_red], top=high[last_red], bottom=low[last_red], right=bar_index[last_red], bgcolor=col_bullish_ob, border_color=col_bullish, extend=extend.right)
    array.push(longBoxes, drawlongBox)

if array.size(shortBoxes) > 0
    for i = array.size(shortBoxes) - 1 to 0 by 1
        sbox = array.get(shortBoxes, i)
        top = box.get_top(sbox)
        bot = box.get_bottom(sbox)

        if OBBearMitigation > top
            array.remove(shortBoxes, i)
            box.delete(sbox)

        if high > bot and sell_alert
            alert('Price inside Bearish OB', alert.freq_once_per_bar)

if array.size(longBoxes) > 0
    for i = array.size(longBoxes) - 1 to 0 by 1
        sbox = array.get(longBoxes, i)
        bot = box.get_bottom(sbox)
        top = box.get_top(sbox)

        if OBBullMitigation < bot
            array.remove(longBoxes, i)
            box.delete(sbox)

        if low < top and buy_alert
            alert('Price inside Bullish OB', alert.freq_once_per_bar)

settings = "Settings"
zigzag_len = input.int(9, "ZigZag Length", group=settings)
show_zigzag = input.bool(true, "Show Zigzag", group=settings)
fib_factor = input.float(0.33, "Fib Factor for breakout confirmation", 0, 1, 0.01, group=settings)

tooltip_text = "Some timeframes may not be displayed in current timeframe. Zigzag lines only shows in current timeframe."
time_frame= input.string("Chart", "Timeframe", ["Chart", "5m", "15m", "30m", "1h", "2h", "4h", "D"], tooltip=tooltip_text)

tf = switch time_frame
    "5m" => "5"
    "15m" => "15"
    "30m" => "30"
    "1h" => "60"
    "2h" => "120"
    "4h" => "240"
    "D" => "D"
    => timeframe.period

text_size = input.string(size.tiny, "Text Size", [size.tiny, size.small, size.normal, size.large, size.huge])

bu_ob_inline_color = "Bu-OB Colors"
be_ob_inline_color = "Be-OB Colors"
bu_bb_inline_color = "Bu-BB Colors"
be_bb_inline_color = "Be-BB Colors"

bu_ob_display_settings = "Bu-OB Display Settings"
bu_ob_color = input.color(color.new(color.green, 70), "Color", group=bu_ob_display_settings, inline=bu_ob_inline_color)
bu_ob_border_color = input.color(color.green, "Border Color", group=bu_ob_display_settings, inline=bu_ob_inline_color)
bu_ob_text_color = input.color(color.green, "Text Color", group=bu_ob_display_settings, inline=bu_ob_inline_color)

be_ob_display_settings = "Be-OB Display Settings"
be_ob_color = input.color(color.new(color.red, 70), "Color", group=be_ob_display_settings, inline=be_ob_inline_color)
be_ob_border_color = input.color(color.red, "Border Color", group=be_ob_display_settings, inline=be_ob_inline_color)
be_ob_text_color = input.color(color.red, "Text Color", group=be_ob_display_settings, inline=be_ob_inline_color)

bu_bb_display_settings = "Bu-BB & Bu-MB Display Settings"
bu_bb_color = input.color(color.new(color.green, 70), "Color", group=bu_bb_display_settings, inline=bu_bb_inline_color)
bu_bb_border_color = input.color(color.green, "Border Color", group=bu_bb_display_settings, inline=bu_bb_inline_color)
bu_bb_text_color = input.color(color.green, "Text Color", group=bu_bb_display_settings, inline=bu_bb_inline_color)

be_bb_display_settings = "Be-BB & Be-MB Display Settings"
be_bb_color = input.color(color.new(color.red, 70), "Color", group=be_bb_display_settings, inline=be_bb_inline_color)
be_bb_border_color = input.color(color.red, "Border Color", group=be_bb_display_settings, inline=be_bb_inline_color)
be_bb_text_color = input.color(color.red, "Text Color", group=be_bb_display_settings, inline=be_bb_inline_color)

var float[] high_points_arr = array.new_float(5)
var int[] high_index_arr = array.new_int(5)
var float[] low_points_arr = array.new_float(5)
var int[] low_index_arr = array.new_int(5)

var box[] bu_ob_boxes = array.new_box(5)
var box[] be_ob_boxes = array.new_box(5)
var box[] bu_bb_boxes = array.new_box(5)
var box[] be_bb_boxes = array.new_box(5)

f_get_high(ind) =>
    [array.get(high_points_arr, array.size(high_points_arr) - 1 - ind), array.get(high_index_arr, array.size(high_index_arr) - 1 - ind)]

f_get_low(ind) =>
    [array.get(low_points_arr, array.size(low_points_arr) - 1 - ind), array.get(low_index_arr, array.size(low_index_arr) - 1 - ind)]

f_main1() =>
    to_up = high >= ta.highest(zigzag_len)
    to_down = low <= ta.lowest(zigzag_len)

    trend = 1
    trend := nz(trend[1], 1)
    trend := trend == 1 and to_down ? -1 : trend == -1 and to_up ? 1 : trend

    last_trend_up_since = ta.barssince(to_up[1])
    low_val = ta.lowest(nz(last_trend_up_since > 0 ? last_trend_up_since : 1, 1))
    low_index = bar_index - ta.barssince(low_val == low)

    last_trend_down_since = ta.barssince(to_down[1])
    high_val = ta.highest(nz(last_trend_down_since > 0 ? last_trend_down_since : 1, 1))
    high_index = bar_index - ta.barssince(high_val == high)

    if ta.change(trend) != 0
        if trend == 1
            array.push(low_points_arr, low_val)
            array.push(low_index_arr, low_index)
        if trend == -1
            array.push(high_points_arr, high_val)
            array.push(high_index_arr, high_index)

    [h0, h0i] = f_get_high(0)
    [h1, h1i] = f_get_high(1)

    [l0, l0i] = f_get_low(0)
    [l1, l1i] = f_get_low(1)

    market = 1
    market := nz(market[1], 1)
    last_l0 = ta.valuewhen(ta.change(market) != 0, l0, 0)
    last_h0 = ta.valuewhen(ta.change(market) != 0, h0, 0)
    market := last_l0 == l0 or last_h0 == h0 ? market : market == 1 and l0 < l1 and l0 < l1 - math.abs(h0 - l1) * fib_factor ? -1 : market == -1 and h0 > h1 and h0 > h1 + math.abs(h1 - l0) * fib_factor ? 1 : market

    alert_market = 1
    alert_market := nz(alert_market[1], 1)
    alert_market := last_l0 == l0 or last_h0 == h0 ? alert_market : alert_market == 1 and trend == -1 and close < l0 and close < l0 - math.abs(h0 - l0) * fib_factor ? -1 : alert_market == -1 and trend == 1 and close > h0 and close > h0 + math.abs(h0 - l0) * fib_factor ? 1 : alert_market

    bu_ob_index = bar_index
    bu_ob_index := nz(bu_ob_index[1], bar_index)
    for i=h1i to l0i[zigzag_len]
        index = bar_index - i 
        if open[index] > close[index]
            bu_ob_index := bar_index[index]

    bu_ob_since = bar_index - bu_ob_index

    be_ob_index = bar_index
    be_ob_index := nz(be_ob_index[1], bar_index)
    for i=l1i to h0i[zigzag_len]
        index = bar_index - i 
        if open[index] < close[index]
            be_ob_index := bar_index[index]

    be_ob_since = bar_index - be_ob_index

    be_bb_index = bar_index
    be_bb_index := nz(be_bb_index[1], bar_index)
    for i=h1i - zigzag_len to l1i
        index = bar_index - i
        if open[index] > close[index]
            be_bb_index := bar_index[index]

    be_bb_since = bar_index - be_bb_index

    bu_bb_index = bar_index
    bu_bb_index := nz(bu_bb_index[1], bar_index)
    for i=l1i - zigzag_len to h1i
        index = bar_index - i
        if open[index] < close[index]
            bu_bb_index := bar_index[index]

    bu_bb_since = bar_index - bu_bb_index

    bu_ob_since_high = high[bu_ob_since]
    bu_ob_since_low = low[bu_ob_since]
    be_ob_since_high = high[be_ob_since]
    be_ob_since_low = low[be_ob_since]
    be_bb_since_high = high[be_bb_since]
    be_bb_since_low = low[be_bb_since]
    bu_bb_since_high = high[bu_bb_since]
    bu_bb_since_low = low[bu_bb_since]

    [trend, h0i, h0, l0i, l0, market, h1i, h1, l1i, l1, bu_ob_since_high, bu_ob_since_low, be_ob_since_high, be_ob_since_low]

f_main2() =>
    to_up = high >= ta.highest(zigzag_len)
    to_down = low <= ta.lowest(zigzag_len)

    trendms = 1
    trendms := nz(trendms[1], 1)
    trendms := trendms == 1 and to_down ? -1 : trendms == -1 and to_up ? 1 : trendms

    last_trendms_up_since = ta.barssince(to_up[1])
    low_val = ta.lowest(nz(last_trendms_up_since > 0 ? last_trendms_up_since : 1, 1))
    low_index = bar_index - ta.barssince(low_val == low)

    last_trendms_down_since = ta.barssince(to_down[1])
    high_val = ta.highest(nz(last_trendms_down_since > 0 ? last_trendms_down_since : 1, 1))
    high_index = bar_index - ta.barssince(high_val == high)

    if ta.change(trendms) != 0
        if trendms == 1
            array.push(low_points_arr, low_val)
            array.push(low_index_arr, low_index)
        if trendms == -1
            array.push(high_points_arr, high_val)
            array.push(high_index_arr, high_index)

    [h0, h0i] = f_get_high(0)
    [h1, h1i] = f_get_high(1)

    [l0, l0i] = f_get_low(0)
    [l1, l1i] = f_get_low(1)

    market = 1
    market := nz(market[1], 1)
    last_l0 = ta.valuewhen(ta.change(market) != 0, l0, 0)
    last_h0 = ta.valuewhen(ta.change(market) != 0, h0, 0)
    market := last_l0 == l0 or last_h0 == h0 ? market : market == 1 and l0 < l1 and l0 < l1 - math.abs(h0 - l1) * fib_factor ? -1 : market == -1 and h0 > h1 and h0 > h1 + math.abs(h1 - l0) * fib_factor ? 1 : market

    alert_market = 1
    alert_market := nz(alert_market[1], 1)
    alert_market := last_l0 == l0 or last_h0 == h0 ? alert_market : alert_market == 1 and trendms == -1 and close < l0 and close < l0 - math.abs(h0 - l0) * fib_factor ? -1 : alert_market == -1 and trendms == 1 and close > h0 and close > h0 + math.abs(h0 - l0) * fib_factor ? 1 : alert_market

    bu_ob_index = bar_index
    bu_ob_index := nz(bu_ob_index[1], bar_index)
    for i=h1i to l0i[zigzag_len]
        index = bar_index - i 
        if open[index] > close[index]
            bu_ob_index := bar_index[index]

    bu_ob_since = bar_index - bu_ob_index

    be_ob_index = bar_index
    be_ob_index := nz(be_ob_index[1], bar_index)
    for i=l1i to h0i[zigzag_len]
        index = bar_index - i 
        if open[index] < close[index]
            be_ob_index := bar_index[index]

    be_ob_since = bar_index - be_ob_index

    be_bb_index = bar_index
    be_bb_index := nz(be_bb_index[1], bar_index)
    for i=h1i - zigzag_len to l1i
        index = bar_index - i
        if open[index] > close[index]
            be_bb_index := bar_index[index]

    be_bb_since = bar_index - be_bb_index

    bu_bb_index = bar_index
    bu_bb_index := nz(bu_bb_index[1], bar_index)
    for i=l1i - zigzag_len to h1i
        index = bar_index - i
        if open[index] < close[index]
            bu_bb_index := bar_index[index]

    bu_bb_since = bar_index - bu_bb_index

    bu_ob_since_high = high[bu_ob_since]
    bu_ob_since_low = low[bu_ob_since]
    be_ob_since_high = high[be_ob_since]
    be_ob_since_low = low[be_ob_since]
    be_bb_since_high = high[be_bb_since]
    be_bb_since_low = low[be_bb_since]
    bu_bb_since_high = high[bu_bb_since]
    bu_bb_since_low = low[bu_bb_since]

    [alert_market, be_bb_since_high, be_bb_since_low, bu_bb_since_high, bu_bb_since_low, bu_ob_index, bu_bb_index, be_ob_index, be_bb_index]

[trendms, h0i, h0, l0i, l0, market, h1i, h1, l1i, l1, bu_ob_since_high, bu_ob_since_low, be_ob_since_high, be_ob_since_low] = request.security(syminfo.tickerid, tf, f_main1())
[alert_market, be_bb_since_high, be_bb_since_low, bu_bb_since_high, bu_bb_since_low, bu_ob_index, bu_bb_index, be_ob_index, be_bb_index] = request.security(syminfo.tickerid, tf, f_main2())

if ta.change(trendms) != 0 and show_zigzag
    if trendms == 1
        line.new(h0i, h0, l0i, l0)
    if trendms == -1
        line.new(l0i, l0, h0i, h0)

if ta.change(market) != 0
    if market == 1
        line.new(h1i, h1, h0i, h1, color=color.green, width=2)
        label.new(int(math.avg(h1i, l0i)), h1, "MSB", color=color.new(color.black, 100), style=label.style_label_down, textcolor=color.green, size=size.small)
        bu_ob = box.new(bu_ob_index, bu_ob_since_high, bar_index + 10, bu_ob_since_low, bgcolor=bu_ob_color, border_color=bu_ob_border_color, text="Bu-OB", text_color=bu_ob_text_color, text_halign=text.align_right, text_size=text_size)
        bu_bb = box.new(bu_bb_index, bu_bb_since_high, bar_index + 10, bu_bb_since_low, bgcolor=bu_bb_color, border_color=bu_bb_border_color, text=l0 < l1 ? "Bu-BB" : "Bu-MB", text_color=bu_bb_text_color, text_halign=text.align_right, text_size=text_size)
        array.push(bu_ob_boxes, bu_ob)
        array.push(bu_bb_boxes, bu_bb)
    if market == -1
        line.new(l1i, l1, l0i, l1, color=color.red, width=2)
       

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

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

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

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

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

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

Стоимость полного кода
5 942,60₽ ≈ $72.61